Simple IoT Home Irrigation / Watering System on ESP8266 / ESP32
by alxrvn in Circuits > Microcontrollers
44 Views, 0 Favorites, 0 Comments
Simple IoT Home Irrigation / Watering System on ESP8266 / ESP32

Build a complete IoT plant watering system in just 2 hours! This ESP8266/ESP32-powered project transforms your garden into a smart, remotely controlled watering system that you can monitor and control from anywhere in the world!
This project shows how quickly you can create sophisticated IoT systems using ESP8266/ESP32 and modern libraries - perfect for weekend makers who want immediate results.
What makes this special?
- Remote Control: Water your plants from anywhere via MQTT/WiFi
- Optional Smart Safety: Water level detection prevents dry running (if sensor added)
- Optional Soil Monitoring: Real-time soil moisture readings (if sensor added)
- Time Limits: Configurable maximum watering time protection
- Home Assistant Ready: Full smart home integration
- Emergency Stop: Physical button always works
- Ultra-Budget Friendly: Start from just $15 and expand later!
Ever killed plants by forgetting to water them? Or maybe you travel frequently and worry about your green friends? This system solves both problems while teaching you valuable IoT skills. Unlike expensive commercial systems ($150-300), this DIY version costs under $25 and gives you complete control over every feature.
Supplies

Skills Required
This project is suitable for intermediate makers. You should have:
- Basic Electronics Knowledge: Understanding of circuits, voltage, current
- Soldering Skills: Clean joints essential for reliability
- Arduino/ESP8266 Experience: Basic programming knowledge helpful
- WiFi/MQTT Familiarity: Understanding of IoT concepts
- Patience: Testing and debugging IoT systems takes time
- Safety Awareness: Working with water and electricity requires care
Difficulty Level: ⭐⭐⭐☆☆ (3/5 stars) Build Time: 2 hours total - perfect weekend project!
Gather Your Parts
Essential Components:
- ESP8266 NodeMCU or Wemos D1 Mini
- 5V Relay Module
- Push Button
- 12V Water Pump
- 12V Power Supply
- DC-DC Step Down Module 12V→5V
- Connecting wires and breadboard
Optional Sensors (you can add them later):
- Water Level Float Sensor ($2-3)
- Soil Moisture Sensor ($1-2)
Using 5V water pump
Note that you can use a 5V water pump - it will be enough to water your home plants. If you are using a 5V relay and a 5V water pump, you won't need a 12V-to-5V DC-DC converter: you can power the whole device with a 5V/2A phone charger. Please remember that you need to connect the 5V water pump directly to the PSU and not to the VIN pin on the ESP, because the ESP's onboard regulator has limited current capacity (~500mA) and connecting the water pump through the ESP can overheat the regulator and potentially damage your board.
Wiring and Assembly
Power Connections:
- 12V PSU → DC-DC Step Down IN+ and IN-
- DC-DC Step Down OUT+ (5V) → ESP8266 VIN and Relay VCC
- DC-DC Step Down OUT- (GND) → ESP8266 GND and Relay GND
Control Wiring:
- ESP8266 D1 pin → Relay IN pin
- ESP8266 D2 pin → Button (other side to GND)
Pump Wiring:
- Water pump negative (-) → 12V PSU negative (-)
- Water pump positive (+) → Relay NO (Normally Open) pin
- Relay COM pin → 12V PSU positive (+)
Optional Sensors (if adding):
- Float sensor signal → ESP8266 D5 pin
- Soil sensor analog → ESP8266 A0 pin
- Both sensors VCC → 3.3V, GND → GND
Important Safety Note: Never connect ESP power through VIN and USB simultaneously! This can very likely damage your ESP board and/or your computer's USB port!
Software Setup
Install Arduino IDE and Libraries:
- Add ESP8266 board package: http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Install libraries: WiFiManager, PubSubClient, NTPClient, Button2
Download and Configure Code:
- Download project files from GitHub
- Edit defaults.h:
Upload:
- Select Board: "NodeMCU 0.9" or "ESP32"
- Connect ESP8266 via USB and upload
WiFi and MQTT Setup
First Boot Configuration:
- Power on ESP8266 → creates "ESP-Watering" hotspot
- Connect with phone/laptop (no password)
- Browser opens automatically to 192.168.4.1
- Configure:
- Select your WiFi network and enter password
- MQTT Host: broker.hivemq.com (leave user/pass empty)
- Save settings
Install MQTT Control App:
- Download MQTT Explorer from mqtt-explorer.com
- Connect to broker.hivemq.com port 1883
- Find your topics: water_yourgarden_2024/
Testing and Control
Manual Test:
- Press physical button → pump should start/stop
- Check serial monitor (115200 baud) for "Relay ON/OFF" messages
MQTT Control: Send these commands to water_yourgarden_2024/ topic:
- 30 → Water for 30 seconds
- off → Stop watering
- status → Get system status
- max → Show max watering time
Settings (send to water_yourgarden_2024/set):
- max,600 → Set max time to 10 minutes
Mobile Control:
- Download "IoT MQTT Panel" (Android) or "MQTTool" (iOS)
- Connect to broker.hivemq.com and control your system!
Safety and Troubleshooting
Safety Features Built-in:
- Maximum time limit prevents overwatering (default 5 minutes)
- Manual button always works as emergency stop
- System auto-reconnects if WiFi drops
Common Issues:
- Pump won't start: Check D1→Relay IN wiring and 12V power
- WiFi problems: Hold button 5+ seconds to reset WiFi settings
- MQTT not working: Verify unique suffix in your topic name
Future Upgrades:
- Add water level sensor to prevent dry running
- Add soil moisture sensor for smart automation
- Integrate with Home Assistant for advanced scheduling
Enjoy Your Smart Garden!
Your system can now:
- Water plants remotely from anywhere
- Set custom watering times (1-3600 seconds)
- Work offline via manual button
- Auto-reconnect after power/WiFi outages
- Expand with sensors later
Total Build Time: ~2 hours Total Cost: $20-30 vs $150-300 commercial systems
Next Steps:
- Test for a few days with different watering times
- Add sensors for monitoring
- Set up automation schedules
- Share your success photos in comments!
Happy Growing! 🌱💧
Project Repository and Demo
You can take the working code from my Github repository: https://github.com/esiteq/ESP-Watering/
The demo video shows using MQTT to launch watering from remote computer for few seconds (5, 3, 5).