Arduino-Controlled Soil Moisture Monitoring and Water Pump System
View and Edit Project In Cirkit Designer
Automated Irrigation System Circuit Documentation
Summary
This document describes an automated irrigation system designed to monitor soil moisture levels and activate a water pump when the soil becomes dry. The system is built around an Arduino UNO microcontroller, which interfaces with a soil moisture sensor module and controls a relay to power a 5V mini water pump. A 9V battery provides power to the pump through the relay, and the Arduino is powered via its onboard voltage regulator.
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.
1-Channel Relay (5V 10A)
- An electrically operated 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 input, and ground.
Soil Moisture Module
- A sensor that measures the volumetric content of water in the soil and outputs this information as an analog or digital signal.
- It has power (VCC), ground (GND), analog output (Analog), digital output (Digital), and additional power and ground pins for daisy-chaining.
5V Mini Water Pump
- A small pump that operates at 5 volts, suitable for pumping water in small-scale irrigation systems.
SparkFun Soil Moisture Sensor
- A simple breakout for measuring the moisture in soil and similar materials.
- It has a VCC pin for power, a GND pin for ground, and a SIG pin for the analog signal.
9V Battery
- A standard 9V battery used to provide power to the water pump through the relay.
Wiring Details
Arduino UNO
- 3.3V connected to Soil Moisture Module VCC
- 5V connected to 1-Channel Relay power
- GND connected to Soil Moisture Module Ground, 1-Channel Relay ground
- D6 connected to Soil Moisture Module Digital
- D3 connected to 1-Channel Relay signal
1-Channel Relay (5V 10A)
- C (Common) connected to 5V Mini Water Pump negative pin
- NO (Normally Open) connected to 9V Battery positive terminal
- Signal connected to Arduino UNO D3
- Power connected to Arduino UNO 5V
- Ground connected to Arduino UNO GND
Soil Moisture Module
- VCC connected to Arduino UNO 3.3V
- Ground connected to Arduino UNO GND
- Digital connected to Arduino UNO D6
- Positive connected to SparkFun Soil Moisture Sensor VCC
- Negative connected to SparkFun Soil Moisture Sensor SIG
5V Mini Water Pump
- Positive Pin connected to 9V Battery negative terminal
- Negative Pin connected to 1-Channel Relay C (Common)
SparkFun Soil Moisture Sensor
- VCC connected to Soil Moisture Module Positive
- SIG connected to Soil Moisture Module Negative
9V Battery
- + (Positive) connected to 1-Channel Relay NO (Normally Open)
- - (Negative) connected to 5V Mini Water Pump Positive Pin
Documented Code
int water; // Variable to store the soil moisture status
void setup() {
pinMode(3, OUTPUT); // Output pin for relay board, controls the water pump
pinMode(6, INPUT); // Input pin for soil moisture sensor
}
void loop() {
water = digitalRead(6); // Read the digital signal from the soil sensor's DO pin
if (water == HIGH) { // If soil is dry, deactivate the relay (cut power to pump)
digitalWrite(3, HIGH); // Deactivate the relay, turning off the water pump
} else { // If soil is moist, activate the relay (power to pump)
digitalWrite(3, LOW); // Activate the relay, turning on the water pump
}
delay(400); // Wait for 400 milliseconds before checking again
}
This code is designed to run on the Arduino UNO microcontroller. It reads the digital output from the soil moisture sensor and controls the relay to power the water pump accordingly. If the sensor indicates dry soil (output HIGH), the relay is deactivated, and the pump is turned off. If the soil is moist (output LOW), the relay is activated, and the pump is turned on to water the plants. The system checks the soil moisture level every 400 milliseconds.