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

IMG_20250823_120226.jpg

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?

  1. Remote Control: Water your plants from anywhere via MQTT/WiFi
  2. Optional Smart Safety: Water level detection prevents dry running (if sensor added)
  3. Optional Soil Monitoring: Real-time soil moisture readings (if sensor added)
  4. Time Limits: Configurable maximum watering time protection
  5. Home Assistant Ready: Full smart home integration
  6. Emergency Stop: Physical button always works
  7. 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

components.png

Skills Required

This project is suitable for intermediate makers. You should have:

  1. Basic Electronics Knowledge: Understanding of circuits, voltage, current
  2. Soldering Skills: Clean joints essential for reliability
  3. Arduino/ESP8266 Experience: Basic programming knowledge helpful
  4. WiFi/MQTT Familiarity: Understanding of IoT concepts
  5. Patience: Testing and debugging IoT systems takes time
  6. 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:

  1. ESP8266 NodeMCU or Wemos D1 Mini
  2. 5V Relay Module
  3. Push Button
  4. 12V Water Pump
  5. 12V Power Supply
  6. DC-DC Step Down Module 12V→5V
  7. Connecting wires and breadboard

Optional Sensors (you can add them later):

  1. Water Level Float Sensor ($2-3)
  2. 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:

  1. 12V PSU → DC-DC Step Down IN+ and IN-
  2. DC-DC Step Down OUT+ (5V) → ESP8266 VIN and Relay VCC
  3. DC-DC Step Down OUT- (GND) → ESP8266 GND and Relay GND

Control Wiring:

  1. ESP8266 D1 pin → Relay IN pin
  2. ESP8266 D2 pin → Button (other side to GND)

Pump Wiring:

  1. Water pump negative (-) → 12V PSU negative (-)
  2. Water pump positive (+) → Relay NO (Normally Open) pin
  3. Relay COM pin → 12V PSU positive (+)

Optional Sensors (if adding):

  1. Float sensor signal → ESP8266 D5 pin
  2. Soil sensor analog → ESP8266 A0 pin
  3. 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:

  1. Add ESP8266 board package: http://arduino.esp8266.com/stable/package_esp8266com_index.json
  2. Install libraries: WiFiManager, PubSubClient, NTPClient, Button2

Download and Configure Code:

  1. Download project files from GitHub
  2. Edit defaults.h:
#define DEFAULT_MQTT_HOST "broker.hivemq.com"
#define DEFAULT_WATER_SUFFIX "_yourgarden_2024" // Change this!

Upload:

  1. Select Board: "NodeMCU 0.9" or "ESP32"
  2. Connect ESP8266 via USB and upload

WiFi and MQTT Setup

First Boot Configuration:

  1. Power on ESP8266 → creates "ESP-Watering" hotspot
  2. Connect with phone/laptop (no password)
  3. Browser opens automatically to 192.168.4.1
  4. Configure:
  5. Select your WiFi network and enter password
  6. MQTT Host: broker.hivemq.com (leave user/pass empty)
  7. Save settings

Install MQTT Control App:

  1. Download MQTT Explorer from mqtt-explorer.com
  2. Connect to broker.hivemq.com port 1883
  3. Find your topics: water_yourgarden_2024/

Testing and Control

Manual Test:

  1. Press physical button → pump should start/stop
  2. Check serial monitor (115200 baud) for "Relay ON/OFF" messages

MQTT Control: Send these commands to water_yourgarden_2024/ topic:

  1. 30 → Water for 30 seconds
  2. off → Stop watering
  3. status → Get system status
  4. max → Show max watering time

Settings (send to water_yourgarden_2024/set):

  1. max,600 → Set max time to 10 minutes

Mobile Control:

  1. Download "IoT MQTT Panel" (Android) or "MQTTool" (iOS)
  2. Connect to broker.hivemq.com and control your system!

Safety and Troubleshooting

Safety Features Built-in:

  1. Maximum time limit prevents overwatering (default 5 minutes)
  2. Manual button always works as emergency stop
  3. System auto-reconnects if WiFi drops

Common Issues:

  1. Pump won't start: Check D1→Relay IN wiring and 12V power
  2. WiFi problems: Hold button 5+ seconds to reset WiFi settings
  3. MQTT not working: Verify unique suffix in your topic name

Future Upgrades:

  1. Add water level sensor to prevent dry running
  2. Add soil moisture sensor for smart automation
  3. Integrate with Home Assistant for advanced scheduling

Enjoy Your Smart Garden!

Your system can now:

  1. Water plants remotely from anywhere
  2. Set custom watering times (1-3600 seconds)
  3. Work offline via manual button
  4. Auto-reconnect after power/WiFi outages
  5. Expand with sensors later

Total Build Time: ~2 hours Total Cost: $20-30 vs $150-300 commercial systems

Next Steps:

  1. Test for a few days with different watering times
  2. Add sensors for monitoring
  3. Set up automation schedules
  4. 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).