blog

IoT Greenhouse Project Using Blynk Arduino

Hello, and welcome to another tutorial project. In this session, we will be designing an IoT based greenhouse project. It can monitor the the soil moisture level, the air humidity and the temperature of the greenhouse. It can also automatically control these parameters by pumping more water into the soil through an underground pump network, making the air of the plant more humid using a humidifier, and controlling the temperature through ventilation fans.

The Materials Required for this Project

The table below is the materials required for this project construction. Also we have included the the quantity needed. You can head over to our online shop to get most of the items here.

ITEM DESCRIPTIONQUANTITYUNIT COSTTOTAL UNIT
LiPo CHARGING MODULE1
DHT221
3×6 INCH PATRESS BOX1
Connector3
RESISTORS2
CONNECTING WIRES3 yards
Sil Moisture sensor1
MQ135 SENSOR1
LIPO BATTERY1
SOLDER1
SOLDERING IRON1
Buzzer1
NodeMCU Board1
Acryllic glass1
Plastic container1
Plywood board1
Glue stick10
DC SWITCH1
FEMALE HEADERPIN2
MISCELLANEOUS
table of materials/components needed for the project design

Schematic Diagram for the IoT Based Green House Project

schematic diagram for IoT based green house project

The DC fans are connected in parallel to each other and are energized by an NPN transistor which is fired at the base by an 1k resistor. When the button on the web dashboard is pressed, the received signal indicates the state of the DC fan. Either to baise the base of the transistor or not. The DC pump is also controlled by the transistor since it demands some initial current at start up. The base of the resistor is connected to a 1k resistor that is connected to a GPIO pinon the NodeMCU. When this GPIO pin is high at 3.3V, the base of the transistor is biased, and when it is LOW it is not biased.

The soil moisture level sensor is connected to the only ACD pin on the NodeMCU, this is the A0 pin. The analog output pin (A0) was connected to this A0 on the NodeMCU. And a program was used to read the analog reading of the sensor. Alternatively, you can download the code and schematic diagram from the link here.

Programming the Project (Arduino Sketch)

 #define BLYNK_TEMPLATE_ID "xxxxxxxxxxxxxxxx" //replace with your unique ID
#define BLYNK_TEMPLATE_NAME "Green House Project"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxxxxxx" //replace with your token

#include "DHT.h"

// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "Galaxy A51 917E";
char pass[] = "ancsucre21";

#define DHTPIN D3     // Digital pin connected to the DHT sensor
//outline the actuATORS
#define dcFan D6
#define dcPump D8
#define humdifier D5
//state the inputs
#define soilMostureSensor A0
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);
//variables
float h, t, f;

int readSoil, pumpButton, tempButton, humidifierButton;

BLYNK_WRITE(V3) {
 pumpButton = param.asInt();
if((readSoil > 19) && (readSoil <= 54)){
  if (pumpButton==1){
  digitalWrite(dcPump, HIGH);
    }
  else if(pumpButton==0){
    digitalWrite(dcPump, LOW);
    }
  }
}

BLYNK_WRITE(V4) {
 tempButton = param.asInt();
 Serial.println(tempButton);
if((t > 19) && (t <= 40)){
    if (tempButton==1){
digitalWrite(dcFan, HIGH);
    }
else if(tempButton==0){
  digitalWrite(dcFan, LOW);
    }
  }
}

BLYNK_WRITE(V5) {
  humidifierButton = param.asInt();
    if (humidifierButton==1){
      pressHum();
    }
else if(tempButton==0){
  Serial.println("press again");
    }
}

void pressHum(){
  digitalWrite(humdifier, LOW);
 delay(100);
 digitalWrite(humdifier, HIGH);
}

void setup() {
  //begin serial comm.
  Serial.begin(9600);
    //state the actuators as outputs
  pinMode(dcPump, OUTPUT);
  pinMode(humdifier, OUTPUT);
  pinMode(dcFan, OUTPUT);

  //turn off humidifier
 pressHum();
 delay(3000);
 pressHum();
 delay(3000);
pressHum();
  //begin the dht sensor
   dht.begin();
  Blynk.begin(auth, ssid, pass);

 digitalWrite(dcFan, LOW);
 
}

void turnOffHumidifier(){
pressHum();
delay(3000);
pressHum();
delay(3000);
pressHum();
   }

void turnOnHumidifier1(){
pressHum();
   }

void turnOnHumidifier2(){
pressHum();
delay(3000);
pressHum();
  
}

//create a fxn to read the temp and hum
float readTempHum(){
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  h = dht.readHumidity();
  // Read temperature as Celsius (the default)
   t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
   f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    //return;
  }
  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  return t, h;
}

void conditionalStatements(){
  readTempHum();
  soilMoisture();
  
  if(t >= 40.00){
    digitalWrite(dcFan, HIGH);
 }

 if (t <= 15.00) {
 digitalWrite(dcFan, LOW);
 }

// if(h <= 15.00){
//   turnOnHumidifier1();
//    }
//    
//  if(h > 50.00)  {
//    turnOffHumidifier();
//  }

   if(readSoil < 18){
    digitalWrite(dcPump, HIGH);
  }

  if(readSoil >= 55){
    digitalWrite(dcPump, LOW);
  }
//  Serial.println(readSoil);
//  delay(500);
}

int soilMoisture(){
  readSoil = analogRead(soilMostureSensor);
  readSoil = map(readSoil, 0, 1023, 100, 0);
  readSoil = constrain(readSoil, 0, 100);
  
  return readSoil;
}


void loop() {
  conditionalStatements();
  Blynk.run();
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);
  Blynk.virtualWrite(V2, readSoil);
}

Read More

Web App Control and Result

This is displayed widgets on the web app. It has three (3) controls namely, the pump button which is a widget that controls the state of the DC pump of the greenhouse model, the temperature control button, which is responsible for turning on the DC fans; and the humidifier button, which controls the humidifier device in the greenhouse model farm. The Blynk web app has three (3) display widgets to monitor and track the state of the temperature, the humidity, and the soil moisture level. This is shown in the image above. The control widgets use a separate function code to send signals to the NodeMCU when they are switched or they change state while the display widgets use a different function in the program code to write to the Blynk cloud to only display.

Thinning, Soldering and Casing the IoT Based Greenhouse Project

Thinning involves the smooth scrapping of terminal components, either by knife or sand paper, before soldering.

Soldering involves the joining of the conductors or components terminals to the circuit board by means of soldering iron and soldering wire. This process was carried out after the terminals of the component have been thinned and positive results have been obtained from the testing of the component.

The casing was made to be a house for some of the components. The casing encased the most of the components and modules use in the project design. It was made from a (3×6) inch pattress box.

The greenhouse model was made using a transparent encasing as shown above. It measured 50cm x 60cm x 40cm in dimension. The model roof was an acrylic glass that was also transparent. The inside of the box was modelled to perform underground irrigation by placing hose running beneath a soil layer. Two openings were cut for the fan inflow of air and outflow of air. This was to control the temperature through natural means. When the greenhouse model was hot or above optimum temperature, cool air was supplied inside.

The greenhouse model was fabricated from a transparent plastic box . It was modelled in such a way that vents were created to allow air passage. Two DC fans were placed on the adjacent sides. This will serve as the extractor fan and the air inlet fan. To control the humidity in the model, a humidifier is mounted at the center of the model. This will automatically and user-based input, control the rate of humid air plants leaves are exposed to.

The Result

The IoT based greenhouse project was made to control the humidity of the plants inside the model greenhouse by increasing the level of moisture around the plants through the spraying of moist air using a humidifier. This is remotely controlled also through the Blynk IoT app. And also controlled automatically by the brain of the project which is the microcontroller. As shown in the image above, the level of water in the soil will determine if the pump should turn on automatically or remain turned off. The user can also control these parameters by online dashboard.

Conclusion

The IoT-based Green House Project has been designed and tested to work. Let us know in the comment section if you were able to replicate this project or if you made some modifications of your own to it.

smartechlabs

Recent Posts

Embracing Imperfections: The Path to a Happier Life

embracing imperfections  Let’s talk about something that touches each of our lives in one way…

7 hours ago

History of The Cold War: A Tense Standoff

The Cold War: A Tense Standoff Introduction The Cold War was not just a period…

13 hours ago

The Birth of Bitcoin: A Digital Revolution

The Birth of Bitcoin Introduction In a world where traditional finance often feels cumbersome and…

14 hours ago

Read The Broken Mute’s Revenge Ebook Here

The Broken Mute’s Revenge In "The Broken Mute's Revenge," the story revolves around a young…

15 hours ago

Fostering Student Autonomy: Self-Directed Learning Strategies for Success

Introduction Imagine a classroom where students take the reins of their own education, setting their…

2 days ago

The Science of Learning: Applying Cognitive Psychology to Educational Design

Introduction Imagine stepping into a classroom where every lesson is meticulously crafted, not just with…

2 days ago

This website uses cookies.