

The circuit is designed to monitor the moisture level of a plant's soil and automatically water the plant when the soil becomes too dry. It consists of an Arduino UNO microcontroller, a humidity sensor (YL-69), a 1-channel relay module to control a mini water pump, an I2C LCD 16x2 screen for displaying moisture levels and status messages, and a 5V adapter to power the system.
5V and GND pins are used to distribute power to the I2C LCD screen, Humidity sensor, and Relay module.A0 pin is connected to the analog output of the Humidity sensor.D2 pin is connected to the signal input of the Relay module.A4 (SDA) and A5 (SCL) pins are connected to the I2C data and clock lines of the LCD screen.VCC and GND pins are connected to the 5V and ground rails, respectively.A0 pin is connected to the A0 pin on the Arduino UNO for analog signal reading.power and ground pins are connected to the 5V and ground rails, respectively.signal pin is connected to the D2 pin on the Arduino UNO.C (common) pin is connected to the 5V output from the 5V Adapter.NO (normally open) pin is connected to the VCC pin of the Mini Water Pump.VCC (5V) and GND pins are connected to the 5V and ground rails, respectively.SDA and SCL pins are connected to the A4 and A5 pins on the Arduino UNO, respectively.VCC pin is connected to the NO contact of the Relay module.GND pin is connected to the ground rail.5V and GND outputs are connected to the C contact of the Relay module and the ground rail, respectively.#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD with I2C address 0x27 and 16x2 dimensions
LiquidCrystal_I2C lcd(0x27, 16, 2);
int moisturePin = A0; // Moisture sensor connected to A0
int relayPin = 7; // Relay signal connected to digital pin 7
int moistureValue = 0; // Variable to store moisture sensor value
int threshold = 500; // Moisture level threshold (adjust as needed)
void setup() {
// Initialize the LCD
lcd.begin();
lcd.backlight();
// Initialize the relay pin as an output
pinMode(relayPin, OUTPUT);
// Ensure the relay is off initially
digitalWrite(relayPin, HIGH); // Relay is LOW-active, so HIGH means OFF
// Begin serial communication for debugging (optional)
Serial.begin(9600);
// Welcome message on the LCD
lcd.setCursor(0, 0);
lcd.print("Plant Monitor");
delay(2000);
lcd.clear();
}
void loop() {
// Read moisture sensor value (analog)
moistureValue = analogRead(moisturePin);
// Display moisture level on the LCD
lcd.setCursor(0, 0);
lcd.print("Moisture: ");
lcd.print(moistureValue);
// Determine if soil is dry or wet
if (moistureValue < threshold) {
// Soil is dry, activate the water pump
digitalWrite(relayPin, LOW); // Turn ON the pump (relay is LOW-active)
lcd.setCursor(0, 1);
lcd.print("Watering Plant");
} else {
// Soil is wet, turn off the pump
digitalWrite(relayPin, HIGH); // Turn OFF the pump
lcd.setCursor(0, 1);
lcd.print("Soil is Moist ");
}
// Optional: print sensor values to Serial Monitor for debugging
Serial.print("Moisture: ");
Serial.println(moistureValue);
// Small delay before next reading
delay(1000);
}
This code is designed to run on the Arduino UNO microcontroller. It initializes the LCD screen, reads the moisture level from the humidity sensor, and controls the relay to power the water pump based on the soil's moisture content. The LCD displays the current moisture level and the watering status.