DIY Rain Gauge for ZoneFlow: From Misol Bucket
Rain-aware watering is one of ZoneFlow's headline tricks — it holds off, or skips a cycle outright, if it's already rained. But that only works when something in your yard is actually measuring rain, in millimetres, in real time. A weather API's forecast is a guess about rain that hasn't happened yet; ZoneFlow wants to know about rain that already fell in your yard.
A proper tipping-bucket rain gauge does that job well, and the mechanism itself is cheap: a small funnel drains into a two-sided seesaw bucket, and every time one side fills and tips, a magnet swings past a reed switch. Count the tips, multiply by however many millimetres each tip represents, and you have real rainfall. The expensive part of a commercial weather station is everything around that mechanism — the radio, the battery, the console. This build skips all of it.
There are two ways to turn each tip into something Home Assistant can see: an ESP32 board running ESPHome, or an Aqara Zigbee door sensor you may already own. Both are covered below. I started with the Aqara sensor and later moved to an ESP32 because the Aqara one wasn't reliable enough for me, but your experience may differ, so use whichever suits what you have.
What you'll need
- A Misol-style tipping-bucket rain gauge — the plastic funnel-and-seesaw mechanism sold under the Misol, Ambient Weather and Fine Offset family of clone weather stations. You want the mechanical gauge itself, not a full weather-station console.
- Something to detect the tips. Pick one:
- An ESP32 board (any ESP32 dev board with a free input pin) running ESPHome, and a USB power supply.
- Or an Aqara Zigbee Door and Window Sensor (the small two-piece contact sensor), plus a Zigbee coordinator already paired with Home Assistant.
- For the ESP32 option: a length of twisted-pair cable such as Cat5 network cable, up to about 15 metres.
- A small screwdriver, some thin wire, and a soldering iron if you want a tidy joint rather than a twist-and-tape one.
- Heat-shrink tubing and clear RTV silicone sold for electronics, for the joints (and, on the Aqara route, for the whole board — see the weatherproofing note below).
ESP32 or Aqara?
Both work, and both end up the same way: every tip of the bucket shows in Home Assistant as a sensor turning on and off, like a door opening and closing.
The Aqara sensor is the quick way to start with parts you may have in a drawer, but it was built to sit on a door frame, not outside in rain and heat, and it wasn't reliable enough for me as a rain gauge. An ESP32 is a plain wired input, which has worked better for me. It also has one more advantage: the board doesn't have to live outside. A rain gauge's reed switch is just a contact, so you can run a cable to the board and keep the electronics indoors, dry, powered by a USB charger. No battery to run flat and no Zigbee link to drop.
Option A: an ESP32 with ESPHome
How it works
The gauge's reed switch closes briefly every time the bucket tips. The ESP32 watches an input pin and reports each closing to Home Assistant as a sensor that turns on. Home Assistant then counts those, which is the next section.
Wiring
- Open the gauge's small housing and find the two wires from its reed switch. On a Misol they usually end in a small telephone-style plug that would normally go to the weather-station console. Cut that plug off, or use the two centre wires.
- Connect one wire to a free input pin on the ESP32 and the other to GND. A reed switch is a plain contact, so it doesn't matter which wire goes where.
- The ESPHome config below switches on the pin's internal pull-up, so no extra parts are needed.
Put the board indoors, up to 15 metres away
Because the reed switch is just a contact, the ESP32 does not have to sit next to the gauge. A run of twisted-pair cable such as Cat5 up to about 15 metres works, and the board can then live indoors, under a roof, where it never meets rain, condensation or direct sun.
- You only need one pair of the cable's four pairs. Use the two wires that are twisted together.
- Keep the cable away from mains wiring. Don't run it alongside a mains cable for any distance, because switching noise can make the pin see extra tips. If you do see false tips, raise the delay in the config below to 50 ms.
- Make the joint at the gauge weatherproof: solder, add heat-shrink, then a coat of clear silicone. Let the cable hang in a downward loop (a drip loop) just before it enters the housing, so rain runs off instead of into it.
- Tie the cable down so wind can't pull on the joint.
The ESPHome config
This is the config I run, on an ESP32-C3 board with the pin set to GPIO4. Use your own board and pin, and keep your Wi-Fi name, password and API key in ESPHome's secrets file as shown.
esphome:
name: raingauge
friendly_name: RainGaugeESP
esp32:
variant: esp32c3
flash_size: 4MB
framework:
type: esp-idf
logger:
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: RainGaugeESP Fallback Hotspot
password: !secret ap_password
captive_portal:
binary_sensor:
- platform: gpio
name: "Rain Gauge Tip"
pin:
number: GPIO4
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 0ms # set 50ms if you get interference
- lambda: |-
static uint32_t last_tip = 0;
if (x) {
uint32_t now = millis();
if (last_tip != 0 && (now - last_tip) < 300) return {};
last_tip = now;
}
return x;
- delayed_off: 50ms
What the pin and filters do:
- INPUT_PULLUP with inverted: true. The pin is held high by the internal pull-up and goes low when the reed switch closes. Inverted means a closed switch reads as "on", which is a tip.
- The 300 ms lock-out. After a tip, any further closing within 300 milliseconds is ignored. Reed switches bounce for a few milliseconds, and without this one tip could count several times. A bucket in even heavy rain tips far less often than that, so no real tips are lost.
- delayed_off: 50ms keeps the sensor on for a moment so Home Assistant sees every tip as a clean on and off, even though the contact closes only briefly.
- delayed_on: 0ms. This is where you can add a delay if interference gives you false tips. Set it to 50 ms and the sensor only turns on if the contact stays closed that long.
Calibrate
Misol-style buckets commonly work out to somewhere around 0.2–0.3 mm per tip, but that varies by unit. Calibrate yours by pouring a measured amount of water slowly through the funnel and counting the tips it produces. For example, 100 ml through a funnel with a 100 cm² opening is 10 mm of rain, so divide 10 mm by the number of tips you counted.
Option B: the Aqara hack
Both halves of this build already contain a reed switch and a magnet — the gauge's seesaw trips one every time it tips, and the Aqara sensor's own contact mechanism uses the same principle to sense a door opening. The hack is simply to let the gauge's reed switch, instead of the Aqara sensor's own magnet, be the thing that closes the Aqara sensor's contact.
Open the gauge's small electronics housing and find the two wires coming off its internal reed switch — normally they'd run to a weather-station console. Open the Aqara sensor and bridge those same two wires onto its own reed-switch leads, in place of (or in parallel with) its magnet. Every tip of the bucket now reads to Home Assistant exactly like a door opening and closing, except it's really a fixed, tiny slug of rainwater going by.
Because the Aqara sensor supplies its own battery and its own Zigbee radio, there's no wiring back to the house and nothing else to power — you're reusing a sensor that was probably sitting in a drawer. The trade-off is that the sensor lives outside with the gauge, and a door sensor on a battery isn't always a dependable rain gauge. If you find it missing tips or dropping off the network, an ESP32 is the next thing to try.
Here's a walkthrough of one build showing the wiring in detail:
Wiring it into Home Assistant
With either option, Home Assistant now has a sensor that turns on at every tip. ZoneFlow wants a running count, so count the tips: make a counter helper in Home Assistant, and an automation that adds one to it each time the tip sensor turns on. In YAML the automation looks like this. Replace the two entity names with your own, which you can find under Settings, Devices.
alias: Rain gauge tip counter
triggers:
- trigger: state
entity_id: binary_sensor.raingaugeesp_rain_gauge_tip
to: "on"
actions:
- action: counter.increment
target:
entity_id: counter.rain_tips
Then pick the counter as the zone's rain gauge sensor (Configure → Zone settings → Rain gauge sensor), leave Rain gauge sensor type on Tip counter, and set Rain Gauge mm per Tip to your gauge's value. ZoneFlow does the multiplying itself, so don't convert the count to millimetres first. The water already received step of every run can then deduct real rainfall instead of relying on a forecast alone. See Rain gauges and weather stations for the details.
Protecting it from moisture
ESP32 route: the board is indoors, so it needs no coating. The parts that get wet are the gauge and the cable joint, which is why the heat-shrink, silicone and drip loop above matter.
Aqara route: a rain gauge's whole job is to sit outside and get wet, and a Zigbee sensor board was designed to live indoors on a door frame — not next to a stream of rainwater and condensation. Once the wiring is bridged and tested, brush a thin coat of a clear, moisture-proof RTV silicone over the populated side of the board before you close everything back up. We use Kafuter K-705 (a clear RTV silicone sold specifically for insulating and moisture-proofing electronics), but any similar hobbyist "conformal coating" silicone sold for PCB protection will do the job.
A few things worth doing before you seal it up:
- Let the silicone cure fully (RTV silicones cure at room temperature over a day or so) before closing the housing — sealing in uncured solvent fumes does more harm than good.
- Keep it off the battery contacts and away from the antenna trace, so you don't affect the connection you're relying on.
- Recoat every season or two if you notice the gauge losing connectivity after heavy rain — silicone coatings aren't forever outdoors.
The result
This isn't going to replace a certified weather-station-grade rain gauge, and it's worth double-checking your calibration against a measuring cup before you trust it fully. But for the price of a $10–$15 tipping-bucket mechanism and an ESP32 board (or an Aqara sensor you probably already own), it gives ZoneFlow the one input a forecast can't: how much water actually landed in your garden today.
If several zones sit in the same part of the garden, put the gauge on an area and they all use it.
Already have a weather station with a rain sensor? You may not need to build anything. See Use your weather station's rain sensor for irrigation.