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

Arduino UNO Based Soil Moisture Monitoring and Water Pump Control System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Soil Moisture Monitoring and Water Pump Control System

Circuit Documentation

Summary

This circuit is designed to monitor soil moisture levels and control a water pump accordingly. It uses an Arduino UNO as the central microcontroller to read data from a soil moisture sensor (YL-69 Sonda) through an LM393 comparator module (YL-83 Module LM393). The system drives a relay module (KY-019 Relay module 1 channel) to turn a water pump on or off based on the moisture level. Additionally, an I2C LCD screen (16x2) displays the status of the soil moisture and the state of the water pump. The circuit is powered by a 9V battery.

Component List

Arduino UNO

KY-019 Relay module 1 channel

YL-69 Sonda

YL-83 Module LM393

I2C LCD 16x2 Screen

Water Pump

9V Battery

Wiring Details

Arduino UNO

KY-019 Relay module 1 channel

YL-69 Sonda

YL-83 Module LM393

I2C LCD 16x2 Screen

Water Pump

9V Battery

Documented Code

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

int sensor_pin = A0;
int relay_pin = 7;

void setup() {
  Serial.begin(9600);
  lcd.begin(16,2);
  lcd.backlight();
  lcd.setBacklight(HIGH);

  pinMode(sensor_pin,INPUT);
  pinMode(relay_pin,OUTPUT);

}

void loop() {
  int sensor_data = analogRead(sensor_pin);
  Serial.print("Sensor_data: ");
  Serial.print(sensor_data);
  Serial.print("\t | ");

  if(sensor_data > 950){
    Serial.print("No Moisture, Soil is Dry");
    digitalWrite(relay_pin, HIGH);

    lcd.setCursor(0,0);
    lcd.print("Soil is Dry");
    lcd.setCursor(0,1);
    lcd.print("Motor On");
  }
  else if(sensor_data >= 400 && sensor_data <=950){
    Serial.print("There is Some Moisture, Soil is Stable");
    digitalWrite(relay_pin, LOW);

    lcd.setCursor(0,0);
    lcd.print("Soil is Stable");
    lcd.setCursor(0,1);
    lcd.print("Motor Off");
  }
  else if(sensor_data < 400){
    Serial.print("Soil is Wet");
    digitalWrite(relay_pin, LOW);

    lcd.setCursor(0,0);
    lcd.print("Soil is Wet");
    lcd.setCursor(0,1);
    lcd.print("Motor Off");
  }

  delay(100);

}

This code is designed to run on the Arduino UNO. It initializes the LCD screen and sets up the sensor and relay pins. In the main loop, it reads the moisture level from the sensor and prints the value to the serial monitor. Depending on the moisture level, it controls the relay to turn the water pump on or off and updates the LCD display with the current soil status and pump state.