Arduino-Controlled Soil Moisture Monitoring and Water Pump System
View and Edit Project In Cirkit Designer
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 and then drives a relay to turn on or off a 5V mini water pump based on the moisture level. The system also includes an I2C LCD 16x2 Screen to display the status of the soil moisture and the water pump.
Component List
1 Channel 5V Relay Module
- Description: A relay module that can be controlled by a digital signal to switch a separate power circuit.
- Pins: VCC+, VCC- (GND), IN, N.O., COM, N.C.
5V Mini Water Pump
- Description: A small pump that operates at 5 volts for pumping water.
- Pins: Positive pin, Negative pin
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
9V Battery
- Description: A standard 9V battery used to provide power to the circuit.
- Pins: -, +
Soil Moisture Module
- Description: An electronic module used to measure the moisture level in the soil.
- Pins: Positive, Negative, Analog, Digital, Ground, VCC
Soil Moisture Sensor
- Description: A sensor that measures the volumetric content of water in the soil.
- Pins: VCC, GND, SIG
I2C LCD 16x2 Screen
- Description: A 16x2 character LCD display that uses the I2C communication protocol.
- Pins: SCL, SDA, VCC (5V), GND, VDD, VO, RS, RW, E, D0-D7, BLA, BLK
Wiring Details
1 Channel 5V Relay Module
- VCC+ connected to Arduino UNO 5V
- VCC- (GND) connected to Arduino UNO GND
- IN connected to Arduino UNO D7
- N.O. connected to 5V Mini Water Pump Positive pin
- COM connected to 9V Battery +
5V Mini Water Pump
- Positive pin connected to Relay Module N.O.
- Negative pin connected to 9V Battery -
Arduino UNO
- 5V connected to Relay Module VCC+, Soil Moisture Module VCC, and I2C LCD 16x2 Screen VCC (5V)
- GND connected to Relay Module VCC- (GND), Soil Moisture Module Ground, and I2C LCD 16x2 Screen GND
- D7 connected to Relay Module IN
- A0 connected to Soil Moisture Module Analog
- A4 connected to I2C LCD 16x2 Screen SDA
- A5 connected to I2C LCD 16x2 Screen SCL
9V Battery
-
- connected to Relay Module COM
-
- connected to 5V Mini Water Pump Negative pin
Soil Moisture Module
- VCC connected to Arduino UNO 5V
- Ground connected to Arduino UNO GND
- Analog connected to Arduino UNO A0
- Positive connected to Soil Moisture Sensor VCC
- Negative connected to Soil Moisture Sensor GND
Soil Moisture Sensor
- VCC connected to Soil Moisture Module Positive
- GND connected to Soil Moisture Module Negative
I2C LCD 16x2 Screen
- VCC (5V) connected to Arduino UNO 5V
- GND connected to Arduino UNO GND
- SDA connected to Arduino UNO A4
- SCL connected to Arduino UNO A5
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.println(sensor_data);
if(sensor_data > 950){
Serial.println("No moisture, Soil is dry");
digitalWrite(relay_pin, HIGH);
lcd.setCursor(0,0);
lcd.print("Soil Dry");
lcd.setCursor(0,1);
lcd.print("Water Pump ON");
}
else if(sensor_data >= 500 && sensor_data <= 700){
Serial.println("Little Moisture is Present");
digitalWrite(relay_pin, LOW);
lcd.setCursor(0,0);
lcd.print("Soil MEDIUM");
lcd.setCursor(0,1);
lcd.print("Water Pump OFF");
}
else if(sensor_data <= 400){
Serial.println("Soil is Wet. Moisture is Maximum.");
digitalWrite(relay_pin, LOW);
lcd.setCursor(0,0);
lcd.print("Soil WET");
lcd.setCursor(0,1);
lcd.print("Water Pump OFF");
}
}
This code is responsible for reading the moisture level from the soil moisture sensor and controlling the relay to power the water pump. It also updates the LCD display with the current soil moisture status and the state of the water pump.