Build an ESP32 Drip Irrigation Controller: Soil Moisture, Solenoid Valves, and Scheduled Watering
- ESP32 Dev Board
Capacitive Soil Moisture Sensor (one per zone)
ADS1115 16-bit I2C ADC Module (if monitoring more than a couple of zones)
24V AC Irrigation Transformer
24V AC Rated Relay Module or SSR (one channel per zone)
24V AC Irrigation Solenoid Valves (one per zone)
MOV Snubber / Surge Suppressor for relay contacts
Irrigation-Rated Direct Burial Wire
Waterproof Wire Nuts or Heat-Shrink Butt Splices
Weatherproof Project Enclosure (IP65-rated or 3D-printed per the gasket/gland guide)
Prices and availability as of Nov 22, 6:28 PM ET and subject to change. The price shown on Amazon at the time of purchase applies.
Commercial smart sprinkler timers are built around a fixed schedule and a vague "smart" rain-skip feature that rarely accounts for what your soil is actually doing. An ESP32-based drip irrigation controller lets you water based on real soil moisture readings instead of a guessed schedule, run multiple independently-scheduled zones off a single controller, and log exactly when and how much each zone watered — all integrated into Home Assistant if you're already running it. This project covers the valve-driving hardware (which trips up more people than the sensor side), multi-zone soil moisture sensing, and the scheduling logic that actually saves water instead of just automating a guess.
Why Soil Moisture Beats a Fixed Timer
A fixed-schedule timer waters the same amount whether it rained yesterday or it's been three weeks of drought — it's automating convenience, not actually optimizing water use. Capacitive soil moisture sensors placed at root depth in each zone let the controller water only when the soil has actually dried past a threshold, which both saves meaningful water over a season and avoids the root rot and fungal problems that come with overwatering beds that didn't need it.
Driving Irrigation Solenoid Valves: The Part That Trips People Up
Most residential irrigation solenoid valves are 24V AC, not 12V DC — a detail that catches first-time builders off guard when they wire a standard 12V relay module and get nothing. You need a 24V AC transformer (the kind sold specifically for irrigation valves) and a relay or SSR rated to switch AC loads, not a DC-only logic relay board. A few valve lines (notably some drip-specific low-flow valves) do run on 12V DC or even 9V latching solenoids — check your specific valve's nameplate before wiring, since mixing this up either does nothing or risks damaging the relay.
| Component | Specification | Why |
|---|---|---|
| Valve type | 24V AC solenoid, confirmed from the valve's own label — don't assume | Wiring a DC relay to an AC valve, or vice versa, simply won't actuate it correctly |
| Relay/SSR | Rated for AC switching at the valve's current draw (check the valve datasheet, typically 200-400mA per valve) | A DC-only relay module won't reliably switch an AC inductive load and can arc or fail |
| Transformer | 24V AC irrigation-rated transformer, sized for total simultaneous valve current if running more than one zone at once | Standard 24V DC wall adapters will not actuate an AC solenoid valve |
| Flyback protection | MOV or snubber across the relay contacts if switching inductive valve coils directly | Solenoid valves are inductive loads; switching them without snubbing shortens relay life and can cause ESP32 brownouts from EMI |
Multi-Zone Soil Moisture Sensing
Use capacitive soil moisture sensors (not the cheap resistive probe type, which corrode within a season of continuous outdoor contact with wet soil) — one per zone, buried at the root depth appropriate to what's planted there. Wire each sensor's analog output to the ESP32's ADC pins, or go through an ADS1115 external ADC if you need more analog channels than the ESP32 exposes cleanly, since the ESP32's native ADC has known nonlinearity issues that matter more for soil moisture thresholds than for rough indication. Calibrate each sensor in place: take a reading in bone-dry soil and another right after a thorough watering, and set your "needs water" threshold somewhere in that measured range rather than trusting an out-of-the-box percentage scale, since sensor response varies by soil type (sandy vs. clay-heavy soil reads very differently at the same actual moisture content).
Scheduling and Override Logic
Build the control loop around a simple rule per zone: check soil moisture on a schedule (every 30–60 minutes is plenty for irrigation decisions), and open that zone's valve only if moisture is below threshold AND it's within an allowed watering window (typically early morning, to minimize evaporation loss and fungal risk from evening watering). Add a manual override and a "rain delay" input — either a simple physical switch or, better, pulling local rainfall data via a weather API if the ESP32 has internet access — so a real rainstorm actually skips the cycle instead of the controller watering an already-soaked bed an hour later.
Avoiding the Failure Mode That Kills Plants
The single most damaging failure mode for an automated irrigation system isn't under-watering — it's a stuck-open valve or a controller that loses its sensor reading and defaults to "keep watering," which can flood and kill plants in a single malfunction while you're away. Build in a hard maximum run time per zone per cycle regardless of sensor state (a valve that's been open for more than, say, 20 minutes straight closes automatically no matter what), and treat a sensor read failure (an open circuit or clearly out-of-range ADC value) as "don't water" rather than "water anyway." A missed watering is a minor setback; a flooded bed or a valve left open for a week while you're on vacation is not.
Enclosure and Field Wiring
The controller box itself needs genuine weatherproofing if it's mounted outdoors near the valve manifold — see dedicated guidance on gasket channels, cable glands, and vent membranes for 3D-printed enclosures, since this is exactly the kind of outdoor electronics project where a bare printed box with hot-glued cable entries fails within a season. Run sensor and valve wiring in irrigation-rated direct-burial wire if it's going underground between zones, not generic hookup wire, and use waterproof wire nuts or heat-shrink butt splices at every underground joint.
Done right, this setup pays for itself in water savings within a season or two on anything beyond a small garden bed, and the real advantage over a commercial smart controller is that every threshold, schedule, and override is something you configured and understand rather than a black-box algorithm you're hoping is doing the right thing.