A ₹1,102 watering system that gives a pot water only when the soil is dry and never floods it. A capacitive soil moisture sensor is read as a percentage, a relay switches a small pump, and the sketch has two safety limits so a stuck sensor cannot empty the bucket.
Scope: intermediate. This is a design worksheet with illustrative costs. It has not been bench-tested by this site. The percentage table and run limits below were computed by script. The raw sensor numbers in the sketch are placeholders: you must calibrate your own sensor in dry air and in a glass of water. Keep the pump and water away from the Arduino and mains.
How it works
A capacitive soil sensor outputs a voltage that falls as the soil gets wetter, so a dry sensor reads a high number and a wet one a low number. The sketch stores two calibration readings, DRY and WET, and converts any reading to a percentage with a straight line between them.
The pump starts when the moisture falls below 30 percent and stops when it rises above 45 percent. The gap between the two numbers is called hysteresis; without it the pump would switch on and off around a single threshold. Two extra limits protect the plant: the pump never runs for more than 10 seconds at a time, and after a run it waits 10 minutes for the water to soak through before reading again.
Bill of materials
| Part | Qty | Unit | Total |
|---|---|---|---|
| Arduino Uno R3 (or compatible) | 1 | ₹550 | ₹550 |
| Capacitive soil moisture sensor | 1 | ₹120 | ₹120 |
| 5 V relay module | 1 | ₹70 | ₹70 |
| Mini submersible pump, 5 V | 1 | ₹150 | ₹150 |
| Silicone tube, 1 m | 1 | ₹40 | ₹40 |
| 5 V power adapter for the pump | 1 | ₹120 | ₹120 |
| 1N4007 diode | 1 | ₹2 | ₹2 |
| Jumper wires | 1 | ₹50 | ₹50 |
| Parts total | ₹1,102 | ||
Scroll the table sideways to see every column.
Prices checked Nov 2026. Shipping and tools are not included.
Prices are illustrative figures for Indian sellers in November 2026, before shipping, and have not been checked against current listings.
The numbers
| Raw reading (example DRY 620, WET 300) | Moisture | Action |
|---|---|---|
| 620 | 0% | Water |
| 524 | 30% | Start pump (below 30%) |
| 476 | 45% | Stop pump (above 45%) |
| 380 | 75% | Leave alone |
| 300 | 100% | Leave alone |
Water per run is only a rough guess. Mini pumps are often listed around 80 litres per hour, about 22 ml per second, so a 10 second run is roughly 220 ml. Measure your own pump by running it for 10 seconds into a measuring jug, and adjust the limit.
Power and wiring
| Part | Connects to | Note |
|---|---|---|
| Sensor VCC, GND, AOUT | 5V, GND, A0 | Check the sensor’s voltage range |
| Relay IN | D7 | Many relay modules switch on a LOW signal |
| Relay VCC and GND | 5V and GND | |
| Pump | Relay contacts and the separate 5 V adapter | Do not run the pump from the Uno pin |
| 1N4007 diode | Across the pump terminals | Stripe toward the positive side; it absorbs the kick when the pump stops |
The sketch
// Automatic plant watering: Uno + capacitive soil sensor + relay + pump
// Design worksheet: DRY and WET are placeholders; calibrate your own sensor.
const int SENSOR = A0;
const int RELAY = 7;
const bool RELAY_ON = LOW; // many modules are active-low
const int DRY = 620; // reading in dry air
const int WET = 300; // reading in a glass of water
const int START_BELOW = 30; // percent
const int STOP_ABOVE = 45; // percent
const unsigned long MAX_RUN = 10000UL; // 10 s
const unsigned long SOAK_WAIT = 600000UL; // 10 min
bool pumping = false;
unsigned long runStart = 0, lastRun = 0;
int moisture() {
long raw = analogRead(SENSOR);
long pct = (long)(DRY - raw) * 100 / (DRY - WET);
return constrain(pct, 0, 100);
}
void pump(bool on) { digitalWrite(RELAY, on ? RELAY_ON : !RELAY_ON); pumping = on; }
void setup() {
pinMode(RELAY, OUTPUT);
pump(false);
Serial.begin(9600);
}
void loop() {
int m = moisture();
unsigned long now = millis();
if (!pumping) {
bool waited = (lastRun == 0) || (now - lastRun >= SOAK_WAIT);
if (m < START_BELOW && waited) { pump(true); runStart = now; }
} else if (m > STOP_ABOVE || now - runStart >= MAX_RUN) {
pump(false); lastRun = now;
}
Serial.println(m);
delay(500);
}If the relay clicks the wrong way, change RELAY_ON. If the sensor ever reads outside the DRY to WET range, the constrain call keeps the percentage between 0 and 100, but a reading far outside it probably means a wiring fault. The sketch has been proofread but not compiled on this site.
Test plan
- Calibrate: print raw readings with the sensor in dry air and in a glass of water, and set DRY and WET.
- Dry run: run the pump into a jug with the sensor out of the soil and check the 10 second limit stops it.
- Measure the pump: time 10 seconds of flow and write down the volume.
- Soil test: use a pot with dry soil and see how the reading changes over the 10 minute soak.
- Fault test: unplug the sensor and confirm the pump still stops at the run limit.
- Leak check: look over the tube joints before leaving it unattended.
What usually goes wrong
| Symptom | Likely cause | Fix |
|---|---|---|
| Pump never starts | Calibration values reversed or relay logic wrong | Print raw values and swap DRY and WET or RELAY_ON |
| Pump runs the full 10 s every time | Sensor reads dry because it is not touching soil | Push the probe in firmly |
| Reading drifts over weeks | Probe corrosion or soil salts | Choose a capacitive sensor and recheck calibration monthly |
| Arduino resets when the pump starts | Pump on the Uno supply | Use a separate 5 V adapter with a common ground |
| Overwatering | Soak wait too short | Lengthen the wait or shorten the run limit |
Upgrades
- Water level: add a float switch so the pump never runs dry.
- Logging: record the moisture each hour to see the drying rate.
- Several pots: add a sensor and a relay channel per pot.
- Remote alert: move to an ESP32 and send a message when the tank is low.
Cost and parts notes
The ₹1,102 total is an illustration and does not include shipping. Use the cost calculator to compare sellers.
Common questions
Why a capacitive sensor and not the two-prong type?
Two-prong resistive probes tend to corrode in wet soil. Capacitive sensors have no exposed metal in the soil.
Why wait 10 minutes after watering?
Water takes time to spread to the sensor. Reading too soon makes the soil look dry and starts another run.
What if the power fails?
The pump stops, because the relay returns to off. The sketch restarts and reads the soil again.
Can I use mains water?
Use any clean water. Keep every mains connection away from this circuit.
Last reviewed: November 2026. This is a design worksheet with illustrative costs. It has not been bench-tested by this site; library names, pins and limits must be checked against your board and the current library versions, and measurements from your build are welcome.