← Back to ideas

Redson Dev · Idea

IoTIntermediateAges 18+A weekend

Smart Garden Irrigation: Automated Watering with ESP32 & Soil Sensors

Published July 7, 2026

This project is for home gardeners or small community gardens in places like Phoenix, Arizona, who want to optimize water usage and ensure healthy plant growth without constant manual oversight. Build an automated irrigation system that uses soil moisture data to precisely water plants. The application could be deployed in a small xeriscape garden at a local community center, conserving water by only watering when truly needed.

What you'll need

  • 1x ESP32 Dev Kit C V4 board
  • 3x Capacitive Soil Moisture Sensor v1.2
  • 3x 5V DC Latching Solenoid Valve (1/2 inch) with connectors
  • 1x 5V 2A DC Power Supply
  • 1x Breadboard
  • Assorted Jumper Wires (male-to-female, male-to-male)
  • Small waterproof enclosure (e.g., IP65-rated junction box)
  • PVC pipes and fittings for water distribution

Step-by-step

  1. 01

    Assemble the Sensor & Valve Circuit

    Connect each capacitive soil moisture sensor to an analog input pin on the ESP32 (e.g., GPIO 34, 35, 36) and its VCC and GND pins to the respective 3.3V and GND pins on the ESP32. Wire each solenoid valve to a digital output pin on the ESP32 (e.g., GPIO 25, 26, 27) through a transistor or relay module, ensuring external 5V power is supplied to the valves directly.

  2. 02

    Program ESP32 with Arduino IDE

    Using the Arduino IDE, install the ESP32 board manager. Write a sketch that reads analog values from the soil sensors. Define moisture thresholds for each sensor. When a sensor reading falls below its threshold, activate the corresponding solenoid valve for a set duration, then deactivate it. Include Wi-Fi configuration to connect to a local network.

  3. 03

    Implement Web Interface for Monitoring

    Expand the ESP32 sketch to host a simple web server. This interface should display the current moisture levels from all sensors and show the status of each valve (open/closed). Consider adding basic controls to manually open or close valves for testing or exceptional circumstances. Ensure the web server is accessible from a browser on the local network.

  4. 04

    Integrate Physical Plumbing

    Connect the solenoid valves into your garden's existing or new PVC irrigation lines. Each valve should control a distinct watering zone or plant group. Ensure all electrical connections within the waterproof enclosure are sealed and protected from outdoor elements. Position soil sensors close to plant roots in their respective zones for accurate readings.

  5. 05

    Calibrate and Test the System

    Power on the system and connect to its web interface. Calibrate the soil moisture sensors by taking readings in dry and saturated soil, then adjust your code's thresholds accordingly. Manually trigger each valve to ensure water flows correctly to each zone. Monitor the system over a few days to fine-tune watering durations and frequencies. Confirm settings using tools like `esptool.py erase_flash` before final deployment.

Tips

  • Use a large capacitor across the power rails of the solenoid valves to smooth out current spikes when they activate, protecting the ESP32.
  • Consider adding a small OLED display to the enclosure for local real-time moisture readings without needing to access the web interface.
  • For long-term outdoor deployment, utilize robust, weather-resistant connectors and carefully seal all openings in the enclosure to prevent water ingress.
#esp32#iot#gardening#automation#soil-moisture