Automatic plant watering system
Build it step by step
0 of 5 doneCalibrate the sensor
Upload, push the sensor into dry soil up to the line and note the reading. Water the pot, wait a minute and note it again. Put those numbers in DRY and WET.
Wire the relay
VCC, GND and IN to D7. Check the relay clicks once at start-up.
Wire the pump
AA pack plus to relay COM, relay NO to the pump plus, pump minus back to the pack minus.
Place the pump
Put the pump in a water container and run its tube to the pot. Never run it dry.
Run and watch
Upload the calibrated sketch and watch the serial monitor through one watering cycle.
How do you build an automatic plant watering system?
A capacitive soil sensor checks the pot and a relay runs a small pump for a few seconds whenever the soil is dry. You need Arduino Uno R3, Capacitive Soil Moisture Module, Relay Module 5V, Mini submersible water pump (3 to 6 V), Battery holder 4 × AA with switch, AA alkaline battery × 4, Silicone wire 22 AWG (assorted colours) and Jumper wires male to female (40 pcs). It takes 5 steps and about 75 minutes.
- Level
- Beginner
- Time
- About 75 min
- Parts
- 8
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SensorsBuy
- InterfacesBuyRelay Module 5V × 1
- Motors & ActuatorsBuy
- PowerBuy
- BatteriesBuy
- Cables & WiresBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Soil sensor VCC / GND | Uno 5V / GND | Sensor power |
| Soil sensor AOUT | Uno A0 | Moisture reading (higher = drier) |
| Relay VCC / GND / IN | Uno 5V / GND / D7 | Relay control |
| AA pack + | Relay COM | Pump supply goes through the relay |
| Relay NO | Pump + (red) | Pump runs only when the relay closes |
| Pump − | AA pack − | Pump return |
Code
Arduino IDE, board "Arduino Uno". No extra libraries. Calibrate DRY and WET with your own soil before leaving it running.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const int SENSOR = A0, RELAY = 7;
const int DRY = 520, WET = 430; // calibrate: reading in dry and in just-watered soil
const unsigned long PUMP_MS = 3000, SOAK_MS = 60000;
const bool RELAY_ON = LOW; // most relay modules switch on with LOW
void setup() {
pinMode(RELAY, OUTPUT); digitalWrite(RELAY, !RELAY_ON);
Serial.begin(9600);
}
void loop() {
int raw = analogRead(SENSOR);
Serial.print("soil="); Serial.println(raw);
if (raw > DRY) {
Serial.println("Dry: watering");
digitalWrite(RELAY, RELAY_ON); delay(PUMP_MS);
digitalWrite(RELAY, !RELAY_ON);
delay(SOAK_MS); // let the water soak in before reading again
} else if (raw < WET) {
delay(10000); // wet enough: check again in 10 s
} else {
delay(5000);
}
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
soil=512 soil=513
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Sensor in air | About 550 to 620 |
| Sensor in water up to the line | About 250 to 320 |
| Dry soil | "Dry: watering", relay clicks, pump runs for 3 s |
| Just after watering | No more watering for at least 60 s |
If it does not work
The pump runs all the time
Your relay may switch on with HIGH. Change RELAY_ON to HIGH.
Readings jump around
Push the sensor to the same depth each time and keep the electronics above the line dry.
The pump hums but no water
Prime it under water and check the tube is not kinked.
Watering every minute
DRY is too low for your soil. Recalibrate.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the automatic plant watering system?
Arduino Uno R3, Capacitive Soil Moisture Module, Relay Module 5V, Mini submersible water pump (3 to 6 V), Battery holder 4 × AA with switch, AA alkaline battery × 4, Silicone wire 22 AWG (assorted colours) and Jumper wires male to female (40 pcs).
How long does the automatic plant watering system take to build?
About 75 minutes for a beginner maker, in 5 steps.
How do I know the automatic plant watering system works?
Sensor in air: About 550 to 620. Sensor in water up to the line: About 250 to 320. Dry soil: "Dry: watering", relay clicks, pump runs for 3 s.
The pump runs all the time: what should I check?
Your relay may switch on with HIGH. Change RELAY_ON to HIGH.
Readings jump around: what should I check?
Push the sensor to the same depth each time and keep the electronics above the line dry.
The pump hums but no water: what should I check?
Prime it under water and check the tube is not kinked.
Watering every minute: what should I check?
DRY is too low for your soil. Recalibrate.
