#include <WiFi.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);

#define soil_PIN 34
#define relay 15

const char *ssid = "Wokwi-GUEST";          // Change this to your WiFi SSID
const char *password = "";  // Change this to your WiFi password

void setup() {
  // put your setup code here, to run once:
  pinMode(soil_PIN, INPUT);
  pinMode(relay, OUTPUT);
  Wire.begin(21, 22);
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  while (!Serial) {
    delay(100);
  }

  // We start by connecting to a WiFi network
  Serial.println();
  Serial.println("******************************************************");
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password, 6);
  lcd.setCursor(0, 0);            //line 1st column, 1st row
  lcd.print("Connecting to");

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    lcd.setCursor(0, 1);
    lcd.print(ssid);
    lcd.print("...");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  lcd.setCursor(0,2);
  lcd.print("WiFi connected");
  delay(250);
  lcd.clear();
  lcd.setCursor(2,1);
  lcd.print("AUTOMATED URBAN");
  lcd.setCursor(0,2);
  lcd.print("ALGRICULTURE SYSTEM");
  delay(500);
  lcd.clear();
}

void loop() {
  // put your main code here, to run repeatedly:
int val = analogRead(soil_PIN);
float soil_percent = (val==0)?0.0000:(val+1)*0.024414;
lcd.setCursor(0,0);
lcd.print("Soil Moist: " + String(soil_percent));
lcd.setCursor(18,0);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print("Water Sprinkle: ");
String waterSprinkle = "\0";
if(soil_percent < 30)
  {
    waterSprinkle = "1";
    digitalWrite(relay, HIGH);
    delay(100);
  }
  else 
  {
    waterSprinkle = "0";
    digitalWrite(relay, LOW);
    delay(100);
  }
  lcd.print(waterSprinkle);
}
NOCOMNCVCCGNDINLED1PWRRelay Module