Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Smart Soil Moisture Monitoring System with LCD Display and Automatic Water Pump Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Soil Moisture Monitoring System with LCD Display and Automatic Water Pump Control

Circuit Documentation

Summary

This circuit is designed to monitor soil moisture levels using a capacitive soil moisture sensor and display the status on a 16x2 I2C LCD. Depending on the moisture level, it controls a water pump via a 5V relay and indicates the status using three LEDs (green, yellow, and red). The entire system is controlled by an Arduino UNO.

Component List

  1. Capacitive Soil Moisture Sensor V1.2

    • Pins: GND, VCC, AOUT
    • Description: Measures the moisture level in the soil.
    • Purpose: Provides analog output corresponding to soil moisture level.
  2. Arduino UNO

    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
    • Description: Microcontroller board based on the ATmega328P.
    • Purpose: Central control unit for the circuit.
  3. 16x2 I2C LCD

    • Pins: GND, VCC, SDA, SCL
    • Description: 16x2 character LCD with I2C interface.
    • Purpose: Displays the soil moisture status and sensor readings.
  4. LED: Two Pin (green)

    • Pins: cathode, anode
    • Description: Green LED.
    • Purpose: Indicates that the soil is wet.
  5. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: Red LED.
    • Purpose: Indicates that the soil is dry and needs water.
  6. LED: Two Pin (yellow)

    • Pins: cathode, anode
    • Description: Yellow LED.
    • Purpose: Indicates that the soil moisture is sufficient.
  7. Resistor (220 Ohms)

    • Pins: pin1, pin2
    • Description: 220 Ohm resistor.
    • Purpose: Current limiting resistor for LEDs.
  8. 5V Relay

    • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
    • Description: 5V relay module.
    • Purpose: Controls the water pump based on soil moisture level.
  9. 5V Mini Water Pump

    • Pins: positive pin, negative pin
    • Description: Small water pump.
    • Purpose: Waters the soil when moisture level is low.

Wiring Details

Capacitive Soil Moisture Sensor V1.2

Arduino UNO

16x2 I2C LCD

LED: Two Pin (green)

LED: Two Pin (red)

LED: Two Pin (yellow)

Resistor (220 Ohms)

5V Relay

5V Mini Water Pump

Code Documentation

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

const int pinDigital = A0;  // Initialize sensor pin
const int relay = 6;        // Initialize relay pin
const int ledGreen = 11;    // Initialize green LED pin
const int ledYellow = 12;   // Initialize yellow LED pin
const int ledRed = 13;      // Initialize red LED pin

// Initialize LCD with I2C address 0x27 and size 16x2
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);          // Start serial monitor
  
  // Initialize LCD
  lcd.init();
  lcd.backlight();
  
  pinMode(pinDigital, INPUT);   // Set A0 as input
  pinMode(relay, OUTPUT);       // Set pin 6 as output
  pinMode(ledGreen, OUTPUT);    // Set pin 11 as output
  pinMode(ledYellow, OUTPUT);   // Set pin 12 as output
  pinMode(ledRed, OUTPUT);      // Set pin 13 as output
}

void loop() {
  int dataAnalog = analogRead(pinDigital);  // Read value from sensor pin
  
  // Print result to serial monitor
  Serial.print("A0 : ");
  Serial.print(dataAnalog);

  // Clear LCD before writing
  lcd.clear();
  
  // If A0 value is less than 250, print message and turn on green LED, turn off yellow, red LEDs and relay
  if (dataAnalog < 250) { 
    Serial.println(". Media Masih Basah"); 
    digitalWrite(ledGreen, HIGH);
    digitalWrite(ledYellow, LOW);
    digitalWrite(ledRed, LOW);
    digitalWrite(relay, LOW);
    
    // Display status on LCD
    lcd.setCursor(0, 0);
    lcd.print("Status: Basah");
    lcd.setCursor(0, 1);
    lcd.print("Nilai: ");
    lcd.print(dataAnalog);
  }

  // If A0 value is less than or equal to 400, print message and turn on yellow LED and relay, turn off green and red LEDs
  else if (dataAnalog <= 400) {
    Serial.println(". Kelembaban Tanah Masih Cukup"); 
    digitalWrite(ledGreen, LOW);
    digitalWrite(ledYellow, HIGH);
    digitalWrite(ledRed, LOW);
    
    // Display status on LCD
    lcd.setCursor(0, 0);
    lcd.print("Status: Cukup");
    lcd.setCursor(0, 1);
    lcd.print("Nilai: ");
    lcd.print(dataAnalog);
  }

  // If A0 value is greater than 400, print message and turn on red LED and relay
  else if(dataAnalog > 400){ 
    Serial.println(". Perlu Tambahan Air"); 
    digitalWrite(ledGreen, LOW);
    digitalWrite(ledYellow, LOW);
    digitalWrite(ledRed, HIGH);
    digitalWrite(relay, HIGH);
    
    // Display status on LCD
    lcd.setCursor(0, 0);
    lcd.print("Status: Kering");
    lcd.setCursor(0, 1);
    lcd.print("Nilai: ");
    lcd.print