An automatic irrigation system is one of the few smart home projects where a bug costs real money: a valve that stays open overnight can waste a lot of water, and a schedule that silently stops can cost you a lawn. The electronics are simple, though. A controller switches low-voltage solenoid valves, one per zone, and decides when and for how long. This guide covers the valves first, because they decide what the controller must be able to do, then two local options: OpenSprinkler and a DIY ESP32 controller with ESPHome.

Autumn is a good time to plan this. The system is drained for the winter anyway, and in spring you can install it without hurrying.

How a zone valve is wired

Each zone (a section of the garden watered at the same time) has its own solenoid valve. In a typical residential system each valve has two wires. One goes to the controller's common terminal (COM), the other to that zone's terminal. All the common wires can be joined, so a cable with one more core than the number of valves is enough.

Valves like Rain Bird's DV series are pilot-operated: the water pressure does the work of opening the diaphragm, and the solenoid only opens a small pilot passage. That is why a few watts are enough.

Standard 24 VAC valves

Most mains-powered systems use 24 VAC solenoids. Rain Bird's specification for the solenoid used on its DV series and other residential valves gives concrete numbers:

  • supply 24 VAC, 50/60 Hz;
  • inrush current 0.30 A (7.2 VA);
  • holding current 0.19 A (4.6 VA);
  • coil resistance 38 Ω.

The DV valve itself works at 1.0 to 10.4 bar.

Those numbers matter in two places. First, the power supply: a valve draws more at the moment it opens than while it is held open, and several valves opening at once add up. OpenSprinkler's FAQ says the number of zones that can run at the same time is limited by the adapter's power and the valves' current draw. The maker has tested up to 8 internally and generally recommends no more than 4. Second, the switching element: a relay or triac must handle the inrush current and AC voltage, which a typical small relay module does easily.

Cable length depends on wire gauge. OpenSprinkler gives up to 200 m for 20 AWG (about 0.5 mm²), 300 m for 18 AWG (about 0.8 mm²) and 450 m for 16 AWG (about 1.3 mm²) between the controller and the valves.

Latching (DC pulse) valves

Battery-powered controllers use latching solenoids instead. A short DC pulse opens the valve, and a pulse of the opposite polarity closes it. Between pulses the solenoid draws nothing. Rain Bird's DC latching solenoid, for example, is specified for 9.0 V DC with an inrush current of 400 mA and a coil resistance of about 4.5 Ω.

A latching valve has two consequences. It cannot be driven by a 24 VAC controller, and it needs a circuit that can reverse polarity, usually an H-bridge. It also stays in its last state if the controller loses power. With a standard valve, a power cut closes everything. With a latching valve, a controller that dies while a zone is running leaves that zone open until something sends the closing pulse.

OpenSprinkler sells a separate Latch model for this reason, and its FAQ is explicit that this is the only model that works with latching valves, which it says usually have two wires of different colours, such as black and red.

Option 1: OpenSprinkler

OpenSprinkler is an open-source controller designed as a drop-in replacement for a conventional one: you label the wires, move them to its terminals and connect it to the network. According to its FAQ:

  • It runs locally. Programs run without internet access, and the controller has a real-time clock with a backup battery. Internet is needed only for remote access through its OTC service, weather data and one-click firmware updates.
  • Zones. The controller has 8 zones, and each expander adds 16, up to 72 on v3 and v4. A master valve or pump counts as a zone, and up to four can be defined.
  • Hardware. v3 uses an ESP8266, v4 an ESP32-C6. Wi-Fi works on 2.4 GHz only, and a wired Ethernet module is optional.
  • Models. The AC model is powered by 24 VAC and also drives 24 VAC pump start relays. The DC model drives 24 VAC valves from a DC adapter, plus DC non-latching valves. The Latch model drives latching valves only. v4 is currently AC only.
  • Sensors. Each sensor port can be a rain sensor (normally open or normally closed), a flow sensor (SN1 only), a digital soil moisture sensor or a program start button. v4 also reads analogue sensors.
  • Weather. Watering times can be scaled using weather data from providers that include Open-Meteo, so it works outside North America.
  • Fault detection. Current firmware has adjustable overcurrent and undercurrent thresholds that help spot faulty valves and wiring.
  • Integration. It can send notifications by MQTT, has a documented HTTP API, and a third-party Home Assistant integration exists.

One warning from the same FAQ: a dotted version update, such as 2.2.0 to 2.2.1, triggers a factory reset and erases all settings. Back up the configuration before you update.

The FAQ lists prices of $130 to $160 for v3 and v4.

Option 2: an ESP32 with ESPHome

If you prefer to build it, ESPHome has a sprinkler component written to behave like a Rain Bird or Hunter controller. It switches other switches on and off in order: typically GPIO pins driving relays, or H-bridge switches for latching valves. It supports a pump or a main valve upstream of the zone valves, a multiplier that scales all run times, repeated cycles, pausing, and a queue for running single zones.

A minimal controller for two zones started every morning at 5:30 looks like this:

time:
  - platform: sntp
    id: sntp_time
    on_time:
      - seconds: 0
        minutes: 30
        hours: 5
        then:
          - sprinkler.start_full_cycle: garden_ctrl

sprinkler:
  - id: garden_ctrl
    main_switch: "Garden irrigation"
    auto_advance_switch: "Garden irrigation auto advance"
    valve_overlap: 5s
    valves:
      - valve_switch: "Lawn"
        run_duration: 1200s
        valve_switch_id: valve_lawn
      - valve_switch: "Flower beds"
        run_duration: 600s
        valve_switch_id: valve_beds

switch:
  - platform: gpio
    id: valve_lawn
    pin: GPIOXX
    internal: true
  - platform: gpio
    id: valve_beds
    pin: GPIOXX
    internal: true

Replace GPIOXX with the pins that drive your relays. A few details in this configuration come straight from the documentation:

  • The relay switches are internal: true. The documentation asks you to control zones only through the switches the sprinkler component creates, not through the underlying GPIO switches, and recommends hiding them from the front end. If you switch a valve directly, the controller loses track of the state, and with a pump in the system that can mean the pump runs against a closed valve.
  • valve_overlap keeps the next valve open for a few seconds together with the previous one. The documentation describes this as a way to reduce pipe banging (water hammer) when a valve closes. The alternative, valve_open_delay, inserts a pause between zones for valves that need pressure to close fully. You can use one or the other, not both.
  • The schedule comes from the on_time trigger of the time component, which uses a subset of cron syntax. The sprinkler component itself starts cycles when told to. You can start them from Home Assistant instead, but then irrigation stops when the server is down.

Keep in mind that SNTP needs the network. If the ESP32 reboots without Wi-Fi, it has no time and the morning trigger will not fire. That is a reason to add a status LED or a notification, or to buy a controller with a battery-backed clock.

For latching valves, the hbridge switch platform pulses one GPIO pin to switch on and another to switch off, with a configurable pulse_length. You still need an H-bridge driver between the ESP32 and the valve.

Sensors that make it smarter

A schedule alone waters the garden after a night of rain. Three additions help:

  • Rain sensor. The simplest skip condition. OpenSprinkler accepts both normally open and normally closed sensors. In ESPHome you read it as a binary sensor and check it in the automation before starting a cycle.
  • Flow sensor. It measures how much water actually flows. A zone using much more than usual suggests a broken pipe or a sprinkler head knocked off, and flow when no zone is active points to a leaking valve.
  • Soil moisture. Useful for beds and pots more than for a whole lawn, because one sensor describes one spot.

Weather data is the other route. Both OpenSprinkler's weather adjustment and the ESPHome multiplier let you shorten or lengthen all run times at once instead of editing each zone.

Water hammer and pressure

Rain Bird recommends keeping water velocity in the supply line at or below 2.3 m/s to reduce water hammer. If pipes bang when zones change, the overlap or delay options mentioned above are the first thing to try, before anything else is changed in the installation.

Getting it through the winter

Water left in pipes, valves and the backflow preventer can freeze and crack them. Hunter's winterization guide describes two methods. In the manual drain method you close the irrigation supply and open the drain valves at the low points. In the blowout method compressed air pushes the water out zone by zone, and Hunter recommends leaving that to a qualified contractor because of the injury risk. If you do it yourself, Hunter's guide says:

  • never exceed 80 psi (about 5.5 bar) with PVC pipe or 50 psi (about 3.4 bar) with polyethylene pipe;
  • remove flow sensors first and seal the pipe;
  • do not blow air through the backflow preventer or the pump;
  • never run the compressor without at least one valve open;
  • stop as soon as a zone is dry, because air in dry pipes heats them through friction.

For the controller, Hunter advises leaving it powered with the dial set to OFF over the winter. With a smart controller, the equivalent is a standby or disabled state: ESPHome's sprinkler component has a standby_switch for exactly that, which stops the controller from starting any valve.

Common mistakes

  • Mixing valve types. A latching valve on a 24 VAC controller will not work, and a standard 24 VAC valve on a latching controller will not either.
  • Undersized power supply. Several valves opening at the same time draw several inrush currents at once.
  • Exposing raw relay switches. Control zones through the sprinkler component, not through the GPIO switches underneath.
  • Relying on server time. If the schedule lives on a server or depends on network time, a power cut or router fault can skip a watering day without anyone noticing.
  • Forgetting the update warning. On OpenSprinkler, a dotted version update erases the settings.
  • Blowing out with too much pressure. Respect the 80 psi and 50 psi limits, and do not blow through the backflow preventer.