Checks the soil every second and runs the pump only when it is dry.
Built and tested by Drisya K S · Industrial Robotics Institute

A fully automatic plant watering system using an ESP32. A soil moisture sensor reports how wet the soil is; when it crosses your calibrated dry level, a relay switches on a DC pump, and switches it off again once the soil is wet. Live readings appear in the Serial Monitor.
| Component | Qty |
|---|---|
| ESP32 Dev Board | 1 |
| Soil Moisture Sensor | 1 |
| 5V Single-Channel Relay Module | 1 |
| DC Water Pump | 1 |
| Jumper Wires | As needed |
| Breadboard (optional) | 1 |
| External Power Supply (5–12V for pump) | 1 |
| From | Connect to |
|---|---|
| Moisture sensor VCC | 3.3V |
| Moisture sensor GND | GND |
| Moisture sensor AO | GPIO 34 |
| Relay VCC | 5V |
| Relay GND | GND |
| Relay IN | GPIO 26 |
| Relay COM | External supply + |
| Relay NO | Pump + |
| Pump − | External supply − |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32.
#define soilPin 34
#define relayPin 26
int threshold = 500; // calibrate for your sensor and soil
void setup() {
Serial.begin(115200);
pinMode(relayPin, OUTPUT);
Serial.println("Plant Watering System Started");
}
void loop() {
int soilValue = analogRead(soilPin);
Serial.print("Soil Moisture Value: ");
Serial.println(soilValue);
if (soilValue > threshold) {
digitalWrite(relayPin, HIGH);
Serial.println("Soil Dry - Pump ON");
} else {
digitalWrite(relayPin, LOW);
Serial.println("Soil Wet - Pump OFF");
}
delay(1000);
}A fully automatic plant watering system using an ESP32. A soil moisture sensor reports how wet the soil is; when it crosses your calibrated dry level, a relay switches on a DC pump, and switches it off again once the soil is wet.
You need: ESP32 Dev Board (1), Soil Moisture Sensor (1), 5V Single-Channel Relay Module (1), DC Water Pump (1), Jumper Wires, Breadboard (optional) (1), External Power Supply (5–12V for pump) (1). Software: Arduino IDE, ESP32 board package.
Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP32. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-132). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.