DIY Zigbee water meter

Every litre,
accounted for.

A Seeed XIAO ESP32-C6 counts the pulses of a G3/4 Hall flow sensor and sends live flow and the running total to Home Assistant over Zigbee. It keeps counting on its 18650 backup when the power goes out.

  • 1–30 L/min
  • Zigbee router
  • Zigbee2MQTT 2.x
  • No WiFi, no cloud
Live demo Joined · router
m³ XIAO · C6 · ZIGBEE
Flow pulses
0.0L/min
Todaywater_daily
0.0L
● report sent// zigbee2mqtt/water_meter
Why this one

Your WiFi water monitor, minus the WiFi.

Same sensor, same numbers as an ESPHome build. It joins the Zigbee mesh your other sensors already use, and it doesn't stop counting when something else does.

Flow and total

Live flow in L/min and a total in litres, ready for the Home Assistant Energy dashboard.

Survives power cuts

Runs from USB with an 18650 backup. The total lives in flash and survives reboots too.

Hardware counting

The ESP32-C6 PCNT counter with a glitch filter. No pulse is lost while the radio talks.

Leak alerts

Water running non-stop, used overnight, meter offline, running on battery. All in the HA package.

Calibrate with a bucket

Pulses per litre are stored on the device. Two scripts compute the right value for you.

A router, too

Always powered, so it relays Zigbee traffic for the devices around your utility room.

Optional BME280

Temperature, humidity and pressure, detected at boot. No sensor, no empty entities to fight with.

Tested on every commit

Unit tests, two firmware builds, converter tests on Z2M's own library, Home Assistant's config checker.

How it works

From a spinning rotor to your Energy dashboard.

The rotor spins

Water turns a small turbine in the G3/4 sensor. A magnet on it passes a Hall sensor once per turn.

yellow wire → D2

Hardware counts

The PCNT peripheral counts every rising edge and drops spikes under 10 µs. The CPU just reads it once a second.

PCNT · 1 s

Pulses become litres

Flow is averaged over 5 s. The total is kept as a double, exact to the millilitre for decades, and saved when the water stops.

flow_logic.h

Zigbee reports

Start and stop go out at once; while flowing, every 5 s if something changed; everything again every 5 min.

Analog Input

Home Assistant

Zigbee2MQTT exposes flow and water_consumed, which Home Assistant knows as volume flow rate and water.

Energy · alerts
490 pulses=1 L 49 pulses/s=6 L/min a 10-minute shower ≈90 L
Home Assistant

Know where it goes. Hear about it when it shouldn't.

One Zigbee2MQTT converter, one package file. You get native entities, utility meters for today, this month and this year, and alerts that catch what a monthly bill never will.

Continuous flow. Water running without a break for an hour (you pick the delay): a leak, a hose or a tap left open.

Night usage. More than 2 L between 01:00 and 06:00: a dripping tap or a running toilet.

On battery. USB power is gone and the backup cell is draining. Plus meter offline after 15 minutes of silence.

Water consumption · last 7 days

Water this month

4.82 m³

Flow

0.0 L/min
Water meter

Water has been flowing without a break for 60 minutes (0.6 L/min right now). Leak or tap left open?

Entities

  • sensor.water_meter_flowvolume flow rate
  • sensor.water_meter_water_consumedwater · total
  • number.water_meter_pulses_per_literconfig
  • sensor.water_today · _this_month · _this_yearutility meters
Calibrate

A bucket beats a datasheet.

Hall sensors are sold with a rough "F = 5.5 × Q". The real number varies from unit to unit. Ten minutes with a bucket and the meter matches your utility bill.

  1. Start

    Run Water calibration - start in Home Assistant. It remembers the current total.

  2. Fill a bucket

    10 L, at your usual flow, with nothing else using water in the house.

  3. Wait for zero

    Close the tap and wait until the flow reads 0, so the last litres are reported.

  4. Finish

    Enter the real volume and run Water calibration - finish. The new value is written to the meter.

new = current ×countedreal
490 × 10.8 L counted / 10 L real = 529 pulses/L

Recalibrating never rewrites the litres already counted.

Flash

No toolchain. Just a USB cable.

Install the latest firmware from this page with Chrome or Edge on a computer. Prefer to build it yourself? It's one pio run away.

  • Disconnect the TP4056 OUT+ wire, then plug the XIAO into your computer.
  • Click Connect & install, pick the serial port, and choose to erase the device on a first install.
  • After a few seconds the LED blinks slowly: open Permit join in Zigbee2MQTT.

XIAO ESP32-C6 firmware

Zigbee router, pulse counter on D2, optional BME280. Calibration and total stay on the device across updates; only a full erase resets them.

Your browser doesn't support Web Serial. Open this page in Chrome or Edge on a computer. Web Serial needs a secure (https) page.
firmware · 30e677a · XIAO ESP32-C6 · Zigbee router
Build

About €25 of parts and an afternoon.

The TP4056 charges the cell and powers everything from it, so the meter doesn't even notice a power cut.

USB charger 5 V · 1 A TP4056 with protection 18650 B+ / B- XIAO ESP32-C6 5V · GND · D2 D7 · D8 (I2C) U.FL antenna Hall sensor G3/4 · 1–30 L/min BME280 optional 3.0–4.2 V red / black BAT85 yellow to D2 10 kΩ to 3V3 diode bar towards the sensor · dashed = optional
Check the pulse voltage first.

ESP32-C6 pins take 3.6 V at most, and many Hall sensors pull their signal up to their own supply. A Schottky diode (bar towards the sensor) and a 10 kΩ pull-up to 3V3 make any sensor safe. Why and how

To flash over USB, disconnect the TP4056 OUT+ wire first: the XIAO's 5V pin is its USB port.

PartRoleNotes
Seeed XIAO ESP32-C6Zigbee radio + MCUThe firmware switches to the external antenna
2.4 GHz U.FL antennaRange from a utility roomPipes and metal eat 2.4 GHz
G3/4 Hall flow sensorThe sensor1–30 L/min, ~490 pulses/L to start with
TP4056 USB-C moduleCharging and powerThe 6-pin version with protection (B± and OUT±)
18650 cell + holderBackupOne to two days without USB
BAT85 diode + 10 kΩSafe pulse signalA few cents
BME280optionalTemperature, humidity, pressureI2C, address 0x76 or 0x77
2 × 100 kΩ + 100 nFoptionalBattery voltageEnables the on-battery alert
FAQ

Good questions.

Does it lose water while the network or Home Assistant is down?

No. Counting is done by hardware and the total is kept on the device. When the network comes back, Home Assistant gets the new total, and total_increasing statistics catch up on their own.

Can it run on the battery alone?

Not for long. The Hall sensor draws 5–15 mA all the time and a router never sleeps, so an 18650 lasts one to two days. The battery is there to ride through power cuts.

Can I match it to my utility meter's reading?

Yes. Publish the reading in litres once, for example {"water_consumed": 254318} to zigbee2mqtt/water_meter/set. Use 0 to reset.

Will my history move if I recalibrate?

No. A new pulses_per_liter applies only to the water counted from then on.

Why Zigbee and not ESPHome over WiFi?

No credentials, no IP address, no API key: it joins the mesh your other sensors already use and keeps working when the WiFi doesn't. You give up WiFi OTA updates and the web UI; updates go over USB, which is rare once it's calibrated.

Will it see a dripping tap?

Sometimes. A 1–30 L/min turbine may not spin below about 1 L/min. The night usage alert catches slow leaks anyway, because even a few litres over five hours add up on the total.

Docs

Everything, step by step.

Find the leak before the bill does.

Open source, MIT licensed, built from parts you can order today.