Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Automatic Plant Watering System with Soil Moisture Sensing and I2C LCD Display

Image of Arduino UNO Based Automatic Plant Watering System with Soil Moisture Sensing and I2C LCD Display

Circuit Documentation

Summary

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.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P
  • It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

Humidity Sensor (YL-69)

  • A soil moisture sensor that can be used to detect the moisture of soil.
  • It outputs an analog signal which is proportional to the amount of moisture in the soil.

1-Channel Relay (5V 10A)

  • An electromechanical switch that allows you to control a high power circuit with a low power signal.
  • It has a normally closed (NC) and normally open (NO) contact, a common (C) terminal, a signal input, power, and ground.

I2C LCD 16x2 Screen

  • A liquid crystal display capable of displaying 16 characters per line in 2 lines.
  • It uses the I2C communication protocol for interfacing with the Arduino.

Mini Water Pump

  • A small pump that can be used to move water from one place to another.
  • It operates on 5V DC and can be controlled via a relay module.

5V Adapter

  • A power supply that converts AC mains power to 5V DC.
  • It provides power to the circuit components.

Adafruit JTAG 2x10 to SWD 2x5

  • An adapter board that converts from the standard 2x10 JTAG pinout to a 2x5 SWD connector.
  • It is used for programming and debugging purposes.

Wiring Details

Arduino UNO

  • 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.

Humidity Sensor (YL-69)

  • 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.

1-Channel Relay (5V 10A)

  • 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.

I2C LCD 16x2 Screen

  • 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.

Mini Water Pump

  • VCC pin is connected to the NO contact of the Relay module.
  • GND pin is connected to the ground rail.

5V Adapter

  • 5V and GND outputs are connected to the C contact of the Relay module and the ground rail, respectively.

Documented Code

#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.