#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <DHT.h>
#define DHTPIN 26
#define SoilPIN 34
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
// Create the lcd object address 0x3F and 16 columns x 2 rows
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// Initialize the LCD connected
lcd.init();
// Turn on the backlight on LCD.
lcd.backlight();
// Print the message on the LCD.
Serial.begin(115200);
lcd.print("Temp, Hum & Soil");
delay(1000);
lcd.clear();
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
float i = analogRead(SoilPIN);
String msg = i < 2165 ? "DRY" : i > 3135 ? "WET" : "OK";
Serial.println("Temp: " + String(t));
Serial.println("Hum: " + String(h));
Serial.println("Soil: " + String(i));
lcd.setCursor(0, 0);
lcd.print(t);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print(h);
lcd.print("%");
lcd.setCursor(8, 1);
lcd.print("Soil:");
lcd.print(msg);
delay(5000); // Reduce delay to 1 second for faster updates
}