#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define RELAY_PIN 18 // Pin where the relay module is connected
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Wire.begin(23, 22);
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(RELAY_PIN, OUTPUT); // Set the relay pin as an output
}
void loop() {
int16_t i = analogRead(34);
// Check soil moisture level and control water pump accordingly
if (i < 2165) {
lcd.clear();
lcd.print("Soil:UBUTAKA BURATOSHYE");
digitalWrite(RELAY_PIN, LOW); // Turn off the water pump
} else if (i > 3135) {
lcd.clear();
lcd.print("Soil: DRY");
lcd.print(" pump: ON");
digitalWrite(RELAY_PIN, HIGH); // Turn on the water pump
} else {
lcd.clear();
lcd.print("Soil:is OK");
digitalWrite(RELAY_PIN, LOW); // Turn off the water pump
}
delay(500);}