Embedded VJ
Published © Apache-2.0

Smart Greenhouse Monitoring and controlling using iot

How to make a smart greenhouse using Arduino and Node MCU for IoT

BeginnerFull instructions providedOver 1 day825
Smart Greenhouse Monitoring and controlling using iot

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Gravity: Analog Soil Moisture Sensor For Arduino
DFRobot Gravity: Analog Soil Moisture Sensor For Arduino
×1
Grove - Gas Sensor(MQ2)
Seeed Grove - Gas Sensor(MQ2)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Breadboard (generic)
Breadboard (generic)
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
1-Channel Signal Relay 1A SPDT I²C Mini Module
ControlEverything.com 1-Channel Signal Relay 1A SPDT I²C Mini Module
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Hand tools and fabrication machines

Premium Female/Female Jumper Wires, 40 x 3" (75mm)
Premium Female/Female Jumper Wires, 40 x 3" (75mm)

Story

Read more

Schematics

Schematics and circuit diagrams

PROTEUS SIMULASION IMAGE

Code

ARDUINO PROGRAM

Arduino
// ARDUINO PROGRAM 
// smart greenhouse monitoring and controlling using iot--------by VIJAY S
//PHN NO: 9791224530
//vijayvjecs@gmail.com
#include<LiquidCrystal.h>
#include <DHT.h>
#include <SoftwareSerial.h>
#define DHTPIN A0
#define DHTTYPE DHT11 
SoftwareSerial nodemcu(2, 3);
LiquidCrystal lcd(12,11,7,8,9,10);
DHT dht(DHTPIN, DHTTYPE);

String sensor1; 
String sensor2;
String sensor3; 
String sensor4;
String cdata = "";

int soil;
int ldr;
int mq2;
int  ldrStatus =0;
int ledPin = 13;
int waterpump = 6;
int fan = 5;
int buz = 4;

void setup()
{ 
 
  pinMode(ledPin, OUTPUT);
  pinMode(waterpump, OUTPUT);
  pinMode(fan, OUTPUT);
  pinMode(buz, OUTPUT);
  lcd.begin(16, 2);
  dht.begin();
  nodemcu.begin(9600);
  
  lcd.setCursor(0, 0);
  lcd.print("SMART");
  lcd.setCursor(0, 1);
  lcd.print("  GREENHOUSE   ");
  delay(1000);
  lcd.clear();
  }
void loop()
  {
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  int soil=0; 
  int mq2=0;
   
  ldrStatus = analogRead(A2);
  soil = analogRead(A1);
  mq2 =  analogRead(A3);

  cdata = cdata + h + "," + t + "," + soil + "," + ldrStatus + "," + mq2 + "," + sensor1 +"," + sensor2 + ","+ sensor3 + ","+ sensor4 + ",";     
  Serial.println(cdata);
  nodemcu.println(cdata);
  delay(600);
  cdata = "";
  (h, HIGH);
  (t, HIGH);
  (soil, HIGH);
  (ldrStatus, HIGH);
  (mq2, HIGH);
  (sensor1, HIGH);
  (sensor2, HIGH);
  (sensor3, HIGH);
  (sensor4, HIGH);
  
  if (ldrStatus >= 200) {
  digitalWrite(ledPin, HIGH);
  sensor2 = "1023"; 
  delay(200);
  lcd.setCursor(4,1);
  lcd.print("ON ");
  } else {
  digitalWrite(ledPin, LOW);
  sensor2 = "0"; 
  delay(200);
  lcd.setCursor(4,1);
  lcd.print("OFF");
  }
  
  if (soil > 300) {
  digitalWrite(waterpump, HIGH);
  sensor1 = "1023";
  delay(200); 
  lcd.setCursor(12,1);
  lcd.print("ON ");
  }
  if (soil < 300) {
  digitalWrite(waterpump, LOW);
  sensor1 = "0";  
  delay(200);  
  lcd.setCursor(12,1);
  lcd.print("OFF");
  }
  
  if(t>35){               
  digitalWrite(fan, HIGH);
  sensor3 = "1023";
  } 
  if(t<35){
  digitalWrite(fan, LOW);
  sensor3 = "0";
  }
  
  if(mq2>250){           
  digitalWrite(buz, HIGH);
  sensor4 = "1023";
  } 
  if(mq2<250){
  digitalWrite(buz, LOW);
  sensor4 = "0";
  }
  
  lcd.setCursor(0,0);
  lcd.print("H:");
  lcd.setCursor(2,0);
  lcd.print(h);
  lcd.setCursor(5,0);
  lcd.print("T:");
  lcd.setCursor(7,0);
  lcd.print(t);
  lcd.setCursor(10,0);
  lcd.print("SM:");
  lcd.setCursor(13,0);
  lcd.println(mq2);
  lcd.setCursor(0,1);
  lcd.print("LED:");
  lcd.setCursor(8,1);
  lcd.print("MTR:");
  }

NODE MCU PROGRAM

Arduino
// NODEMCU PROGRAM 
// smart greenhouse monitoring and controlling using iot--------by VIJAY S
//PHN NO: 9791224530
//vijayvjecs@gmail.com
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SoftwareSerial.h>
char auth[] = "IsqnzwR0PnkEm93o-Q4PrV51devzAa6_";
char ssid[] = "Lenovo132";
char pass[] = "144144@@@@";

SimpleTimer timer;

String myString; // complete message from arduino, which consistors of snesors data
char rdata; // received charactors
String vdata = "";
String vdata1 = "";
String vdata2 = "";
String vdata3 = "";
String vdata4 = "";
int firstVal,secondVal,thirdVal; // sensors
int h,t,soil,mq2,ldr;
int light,waterpump,fan,buz;
void myTimerEvent()
{
  Blynk.virtualWrite(V1, millis() / 1000);
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(10L, sensorvalue1);
  timer.setInterval(100L,sensorvalue2); 
  timer.setInterval(100L,sensorvalue3);
  timer.setInterval(100L,sensorvalue4); 
  timer.setInterval(100L,sensorvalue5);
}
void loop()
      {
      if (Serial.available() == 0 )
      { 
      Blynk.run();
      timer.run(); // Initiates BlynkTimer
      }

      if (Serial.available() > 0 )
      {
      rdata = Serial.read();
      myString = myString + rdata;
      if ( rdata == '\n')
      {
      Serial.println(myString);
      String l = getValue(myString, ',', 0);
      String m = getValue(myString, ',', 1);
      String n = getValue(myString, ',', 2);
      String o = getValue(myString, ',', 3);
      String p = getValue(myString, ',', 4);
      String q = getValue(myString, ',', 5);
      String r = getValue(myString, ',', 6);
      String s = getValue(myString, ',', 7);
      String v = getValue(myString, ',', 8);
      h         = l.toInt();
      t         = m.toInt();
      soil      = n.toInt();
      ldr       = o.toInt();
      mq2       = p.toInt();
      light     = q.toInt();
      waterpump = r.toInt();
      fan       = s.toInt();
      buz       = v.toInt();
      myString = "";
      }}}
void sensorvalue1()
{
  int sdata = h;
  Blynk.virtualWrite(V10, sdata);
  int sdata1 = t;
  Blynk.virtualWrite(V11, sdata1);
  int sdata2 = soil;
  Blynk.virtualWrite(V12, sdata2);
  int sdata3 = ldr;
  Blynk.virtualWrite(V13, sdata3);
   int sdata4 = mq2;
  Blynk.virtualWrite(V14, sdata4);
  
  vdata = vdata + sdata;
  Blynk.virtualWrite(V2, vdata);
  vdata = "";
  vdata1 = vdata1 + sdata1;
  Blynk.virtualWrite(V2, vdata1);
  vdata1 = "";
  vdata2 = vdata2 + sdata2;
  Blynk.virtualWrite(V2, vdata2);
  vdata2 = "";
  vdata3 = vdata3 + sdata3;
  Blynk.virtualWrite(V2, vdata3);
  vdata3 = "";
  vdata4 = vdata4 + sdata4;
  Blynk.virtualWrite(V2, vdata4);
  vdata4 = "";
  delay(1000);
  }
void sensorvalue2()
     {
     int sdata5 = light;
     Blynk.virtualWrite(V15, sdata5);
      }
void sensorvalue3()
      {
      int sdata6 = waterpump;
       Blynk.virtualWrite(V16, sdata6);
       }
void sensorvalue4()
       {
       int sdata7 = fan;
       Blynk.virtualWrite(V17, sdata7);
       }
void sensorvalue5()
       {
       int sdata8 = buz;
       Blynk.virtualWrite(V18, sdata8);
       }
       
      String getValue(String data, char separator, int index)
      {
      int found = 0;
      int strIndex[] = { 0, -1 };
      int maxIndex = data.length() - 1;

      for (int i = 0; i <= maxIndex && found <= index; i++) {
      if (data.charAt(i) == separator || i == maxIndex) {
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
      }}
      return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
      }

Credits

Embedded VJ

Embedded VJ

1 project • 4 followers
Iam creating industrial projects. Iam learning embedded system.

Comments

Add projectSign up / Login