#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <Wire.h>
#define DHTPIN 2
#define DHTTYPE 22
LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht(DHTPIN,DHTTYPE);
#define pot A0
#define buz 6
#define relay 4
void setup() {
  dht.begin();
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  pinMode(pot, INPUT);
  pinMode(buz, OUTPUT);
}
void loop() {
  soilmoisture();
}
void soilmoisture()
{
  int a=analogRead(pot);
  float temp=dht.readTemperature();
  if(a>600)
  {
    digitalWrite(relay, HIGH);
    digitalWrite(buz,HIGH);
    Serial.println("motor turn off");
    lcd.setCursor(0,0);
    lcd.println("motor off");
  }
  else
  {
    digitalWrite(relay, LOW);
    digitalWrite(buz, LOW);
    Serial.println("Motor turn on");
    lcd.setCursor(0,0);
    if(temp>25)
    { 
      lcd.println("motor on");
      lcd.println(" MW"); 
    }
    else{
      lcd.println("motor on");
      lcd.println(" LW"); 
    }
  }
}
NOCOMNCVCCGNDINLED1PWRRelay Module