Starting point
I read three meters in the flat automatically: two Zenner cold water meters (kitchen and bathroom) and an Itron G4 RF1 gas meter. Each has an ESP8266 (ESP-12E) and a GY-271 magnetometer board on it, running the tronikos/esphome-magnetometer-water-gas-meter ESPHome package. The water meters have a small magnet cube on the ×0.001 pointer. The gas meter’s last drum also has a factory magnet, behind the digit 6; the “RF1” pulse output uses it too.
The electricity meter is read by a separate ESP32-C3 Piggymeter over the IEC 62056-21 optical interface, giving the meter’s absolute reading.
The two water meters are linked, by the way: the combi boiler takes its water from the kitchen branch, so a shower spins both meters.
The symptom: stalled sensors
My magnetometer readers had never worked properly, but I had never
got to the bottom of it; this time I had had enough. The bathroom
water meter’s temperature was unknown, the kitchen one had been
lying dismounted since the kitchen drain was unblocked, and the gas
meter counted pulses at a quite different rhythm than it should have.
The Piggymeter fared perhaps even worse: it sent nothing for ten days,
and when it came back, Home Assistant booked the whole outage,
21.5 kWh, into a single five-minute slot.
My suspect was the EFHW antenna in the attic. While I’m on FT8, the coax runs up to the attic alongside a UTP cable, and that one is plugged into the router. So the RF made its way nicely to every sensor. As a fix, all three meters got a clip-on ferrite on their cables.
Claude as a debugging assistant
For debugging I connected Home Assistant to Claude through HA’s built-in Model Context Protocol Server integration, over a Cloudflare Tunnel. This let Claude see the entities, the long-term statistics and the logs, and call HA actions too: start a calibration, set thresholds and volume, set a counter. Meanwhile I stood in front of the meters with a stopwatch and a phone. This division of labour worked surprisingly well.
Pitfall 1: the firmware update reset everything
All three meters were still running ESPHome 2025.7.5, so first I updated them to 2026.11.1. The package had developed a lot in the meantime, and after the update:
- every calibration was lost (axis
None, thresholds ±9999 µT), - the counters started from zero,
- the default detection became Quadrature.
Quadrature mode watches the phase shift between two axes. In my setup the calibration found only one usable axis. The LED did blink at the threshold crossings, yet the counter stood still. After switching to Threshold mode the first pulse came within seconds.
Pitfall 2: the calibration has to see a full revolution
After the update the calibration time on the water meters became 5 seconds. The calibration puts the thresholds between the minimum and maximum of the measured field, so it has to see the full swing, that is, at least one full revolution. Timed with a stopwatch, with the tap fully open, one revolution takes 55 seconds in the kitchen and about 90 in the bathroom. The new settings became 120 and 240 seconds respectively, and 300 for the gas.
Pitfall 3: the gas meter that counted now half, now double
The water was fine after that, but the gas meter behaved unpredictably. For every trial I photographed the drums and compared them with HA over 10–15 minute windows:
| Trial | HA / meter |
|---|---|
| Original holder, dangling | ~40–60% |
| Holder fixed with hot glue, recalibrated | ~240% |
| Same place, Adaptive mode | ~58%, decreasing |
| Sensor closer to the drum, sticking out | ~50% |
After every move the baseline jumped by 10–30 µT, and the LED would get stuck now on, now off.
The turning point was a close-up photo of the board. The chip is marked “DB 5883”, which is actually a QMC5883L, not an HMC5883L, even though the latter is printed on the board. And under the chip there was an empty SMD pad: a year earlier I had accidentally knocked a part off it. According to the datasheet this is the 220 nF capacitor between the SETP and SETC pins, through which the chip periodically demagnetises the sensing element with a set/reset current pulse. Without it the offset drifts, and after a strong magnetic field or RF it can get stuck.
After soldering back a 0603 220 nF X7R capacitor the sensor became stable, and worked in the original position too, where it doesn’t cover the dial. There, however, the ratio came out at a steady 49%.
Pitfall 4: what counts as a pulse?
A steady 49% no longer pointed to missed pulses, but to a wrong setting. The firmware source made it clear: the counter steps when the measured field crosses the upper threshold from below (that’s when the LED lights up). Falling below the lower threshold only re-arms the state. So one magnetic cycle per revolution is one pulse.
The package calls the setting “volume per half rotation”, because it assumes a setup with two cycles per revolution (e.g. a diametrically magnetised rotor). My meters, however, have a single magnet on the pointer or in the drum, so:
- gas: one pulse = one revolution of the last drum = 0.01 m³ (the dial says so too: “1 imp. = 0,01 m³”),
- water: one pulse = one revolution of the ×0.001 pointer = 10 litres. I checked this with a 10-litre bucket: exactly one pulse came on both water meters.
So the default 0.005 measured half the real consumption everywhere. When the sensor hung directly above the magnet, the shape of the field gave two crossings per revolution. That’s why I saw doubling there.
Checking back against the MVM readings
The MVM app keeps the earlier gas meter readings, so they could be compared with the HA statistics:
| Period | Meter (MVM) | HA | Ratio |
|---|---|---|---|
| 2026-08-19 → 10-22 | 24 m³ | 15.1 m³ | 0.63 |
| 2026-10-22 → 11-07 | 35 m³ | 22.6 m³ | 0.65 |
A ratio of about 0.64 corresponds to 1.28 pulses per revolution on average. For months the sensor mostly counted one per revolution, but the offset drifting because of the missing capacitor tipped in a second one in about a quarter of the revolutions. Both faults were present at once.
Absolute readings
The package has a set_total action; with it I set all three
counters to the meter readings. This way a glance tells me any time
if they drift apart. There is one detail to watch, though: changing
the volume also re-values the pulses counted since boot, so
set_total has to be called after setting the volume.
HA’s total_increasing statistics book the jumps as consumption.
These had to be zeroed by hand under Developer tools → Statistics.
Check the next morning, with the taps closed and the heating off:
| Meter | Dial | HA |
|---|---|---|
| Kitchen | 262.073 m³ | 262.073 m³ |
| Bathroom | 273.163 m³ | 273.162 m³ |
| Gas | 937.406 m³ | 937.403 m³ |
Bonus: a watchdog for the Piggymeter
During the Piggymeter’s ten-day outage the ESP was online the whole time, and HA could reach it. Only the optical readout got stuck, and only the next restart helped. So the YAML got a simple watchdog: if there is no successful readout for 30 minutes, the ESP restarts.
globals:
- id: last_readout_ms
type: uint32_t
restore_value: no
initial_value: '0'
sensor:
- platform: iec62056
obis: 15.8.0
# ...
on_value:
then:
- lambda: id(last_readout_ms) = millis();
interval:
- interval: 5min
then:
- lambda: |-
uint32_t elapsed = millis() - id(last_readout_ms);
if (elapsed > 30UL * 60UL * 1000UL) {
ESP_LOGW("watchdog", "No readout for %u s, restarting", (unsigned) (elapsed / 1000));
App.safe_reboot();
}
Alongside it went a restart button and a “Seconds since last
readout” diagnostic sensor.
Lessons
- A firmware update isn’t free. Afterwards it’s worth reviewing every setting: algorithm, calibration time, volume.
- Check against the meter, not by feel. A stopwatch, a 10-litre bucket and a few photos of the drums were worth more than any algorithm tuning.
- Read the code. What counts as a pulse came down to a single
if, and that decided the correct volume. - One missing passive part is enough. The magnetometer gave readings without the capacitor too, just not reliable ones.
- RFI has to be caught at the source as well. The ferrites helped, but the shared route of the coax and the UTP is still a risk.
The next parts of the series bring automatic monthly meter readings written to a Google Sheet, and hooking up the boiler with OpenTherm.





