Water Irrigation System
Forgetting to water your plants or overwatering them out of guilt is a problem almost everyone with houseplants has run into. This project solves that with a simple Arduino-based irrigation system: a capacitive soil moisture sensor that checks how dry the soil is, a temperature sensor keeps the system from watering during near-freezing conditions and a relay-controlled pump delivers water automatically when it's needed. A small LCD screen shows live readings so you can see what the system is "thinking" at any moment.
This guide is designed for beginners and assumes no previous electronics experience beyond installing the Arduino IDE. Even if you've never used a breadboard, handled a soldering iron or written Arduino code before, you can follow along with confidence. Any technical terms or concepts that may be unfamiliar will be explained clearly as they are introduced.
Supplies
Materials (Click each material to check the location to buy):
- 5V Relay Module (1)
- 4-Pin I2C LCD Display (1)
- Breadboard (1)
- Arduino Uno (1)
- Capacitive Soil Moisture Sensor v1.2 (1)
- Temperature Sensor - DS18B20 (1) + 220 Ω resistor (1)
- 5V DC Motor Pump (1)
- 9V battery (1) + Snap Connector (1)
- Wires
- 6 male-to-male jumper wires for the relay module and motor pump
- Standard hookup wires: red, black and one other colour (yellow used here)
- 2 heavier-gauge wires for the high-current side of the relay module
Tools:
Circuit Diagram
Before connecting any wires, it helps to understand where each component needs to be connected. The diagram included here uses a breadboard-style layout instead of a traditional circuit schematic because it is much easier for beginners to follow. If you have never learned circuit symbols or read electronic schematics before, a breadboard diagram provides a clearer visual guide. The following summary explains each connection in simple terms:
The signal (SIG) pin on the soil moisture sensor connects to Arduino pin A0. This allows the Arduino to measure the moisture level in the soil and determine whether watering is needed.
The data pin on the DS18B20 temperature sensor connects to Arduino pin A1. Although A1 is usually described as an analog pin, Arduino pins can also function as digital pins when required, which is how the DS18B20 communicates with the Arduino.
The input (IN) pin on the relay module connects to digital pin 7 on the Arduino. This connection lets the Arduino control when the relay switches the pump on or off.
The relay module's VCC and GND pins connect to the Arduino's 5V and GND pins to provide power for the relay.
The LCD uses I²C communication. I²C (Inter-Integrated Circuit) is a communication protocol that allows multiple electronic devices to exchange data using only two signal wires. Its SDA and SCL pins connect to the dedicated SDA and SCL pins located beside the AREF pin on the Arduino. These pins are internally linked to A4 and A5, so no additional setup is required in the code. The LCD's VCC and GND pins also connect to the Arduino's 5V and GND pins.
For the pump circuit, the positive terminal of the battery connects to the relay's COM terminal. The relay's NO (normally open) terminal connects to the positive wire of the pump. The pump's negative wire connects directly to the negative terminal of the battery, completing the circuit.
The pump and its battery are powered separately from the Arduino for an important reason. Small water pumps often require more current than the Arduino's 5V supply can safely provide. Using a relay allows the Arduino to control the pump without supplying power to it directly, helping protect the Arduino and ensuring the pump receives the power it needs to operate reliably.
Making the Circuit
Steps:
- Start by connecting the Arduino Uno to its USB cable, but leave the cable unplugged from your computer for now. Keeping the board unpowered while wiring helps prevent accidental short circuits and makes the setup process safer.
- Arrange the breadboard, soil moisture sensor, DS18B20 temperature sensor, relay module and LCD display according to the wiring diagram. Leave enough space between components so the jumper wires can be routed neatly and remain easy to identify.
- Connect the soil moisture sensor by wiring its VCC pin to the 5V rail, its GND pin to the ground rail and its SIG pin to Arduino pin A0. This connection allows the Arduino to monitor the moisture level of the soil.
- Wire the DS18B20 temperature sensor by connecting its VCC and GND pins to the power and ground rails. Connect the data pin to Arduino pin A1 and install a pull-up resistor between the data pin and the 5V rail to ensure reliable communication with the Arduino.
- Connect the relay module's control pins. Wire the VCC and GND pins to the Arduino's 5V and GND connections and connect the IN pin to digital pin 7. This allows the Arduino to control when the relay switches on and off.
- Connect the relay's switching terminals to the pump circuit. Wire the battery's positive terminal to the relay's COM terminal and connect the relay's NO (normally open) terminal to the pump's positive wire. Connect the pump's negative wire directly to the battery's negative terminal. This creates a separate power circuit for the pump.
- Connect the LCD display by wiring its VCC and GND pins to the power and ground rails and connecting its SDA and SCL pins to the corresponding SDA and SCL pins on the Arduino.
- Carefully inspect all wiring and compare it with the diagram before applying power. Once every connection has been verified, plug the Arduino into your computer and connect the battery to the pump circuit. This final check can help prevent wiring errors and protect the components from damage.
Warnings:
- Do not place the breadboard, Arduino, relay module or LCD display in water or wet soil. These components are not waterproof and can be permanently damaged by moisture. Only the two metal probes of the soil moisture sensor should be inserted into the soil.
- Avoid running the water pump without water for more than a few seconds. Many small pumps depend on the water flowing through them to provide cooling and lubrication. Running the pump dry for extended periods can cause it to overheat and reduce its lifespan.
- Wait to connect the battery until all wiring has been completed and carefully checked. Troubleshooting and correcting wiring mistakes is much safer and easier when the circuit is not powered. Taking a few extra minutes to verify every connection can help prevent damage to the components and ensure the system works properly when powered on.
Common Mistakes:
- The breadboard's center gap isn't electrically connected, so a wire on one side won't reach a component on the other.
- A0 and A1 are easy to swap, since the moisture sensor and DS18B20 sit right next to each other.
- The relay's NC terminal sits next to NO and is easy to grab by mistake, leaving the pump always-on.
- The relay's control side (Arduino) and switching side (battery/pump) can get crossed on a crowded breadboard.
Code
Before uploading the code, you will need to install the required libraries through the Arduino IDE's Library Manager. Libraries are collections of prewritten code that allow the Arduino to communicate with specific hardware components without requiring you to program every function from scratch.
To install a library, open the Arduino IDE and select Tools > Manage Libraries. In the search bar, type the name, "<LiquidCrystal_I2C.h>" and click Install when it appears.
Here is the code:
#define moisturePin A0
#define tempPin A1
#define pump 7
//Variables
int moistureValue = 0;
float temperatureC = 0;
void setup()
{
//Serial Monitor
Serial.begin(9600);
//Pin Modes
pinMode(pump, OUTPUT);
pinMode(moisturePin, INPUT);
pinMode(tempPin, INPUT);
digitalWrite(pump, LOW);
//LCD
lcd.init();
lcd.backlight();
//Startup Screen
lcd.setCursor(0, 0);
lcd.print("Smart Irrigation");
lcd.setCursor(0, 1);
lcd.print("System Starting");
Serial.println("====================");
Serial.println("SMART IRRIGATION");
Serial.println("SYSTEM STARTING...");
Serial.println("====================");
delay(2000);
lcd.clear();
}
void loop()
{
//Read Soil Moisture Sensor
moistureValue = analogRead(moisturePin);
//Read Temperature Sensor
int tempReading = analogRead(tempPin);
float voltage = tempReading * (5.0 / 1023.0);
//Conversion formula
temperatureC = (voltage - 0.5) * 100.0;
//Pump Control
bool pumpStatus = false;
if (moistureValue <= 300)
{
digitalWrite(pump, HIGH);
pumpStatus = true;
}
else
{
digitalWrite(pump, LOW);
pumpStatus = false;
}
//Serial Monitor Output
Serial.print("Soil Moisture: ");
Serial.print(moistureValue);
Serial.print(" | Temperature: ");
Serial.print(temperatureC);
Serial.print(" C");
Serial.print(" | Pump: ");
Serial.println(pumpStatus ? "ON" : "OFF");
//LCD Line 1
lcd.setCursor(0, 0);
lcd.print("Soil:");
lcd.print(moistureValue);
lcd.print(" ");
//LCD Line 2
lcd.setCursor(0, 1);
lcd.print("T:");
lcd.print(temperatureC, 1);
lcd.print((char)223);
lcd.print("C ");
if (pumpStatus)
{
lcd.print("ON ");
}
else
{
lcd.print("OFF");
}
delay(1000);
}
Demonstration
That's it for the tutorial!