nRF52840-based pulse counter that counts pulses from utility meters with magnetic impulse output and sends data to Zigbee2MQTT.
- Copy the external converter to Zigbee2MQTT.
👉 See External Converter - Restart Zigbee2MQTT completely (full restart required).
- Enable Zigbee pairing (permit join)
- Flash the firmware onto your nRF52840 Supermini board.
- Create Home Assistant helper.
- The P0.04 pin operates at VDD levels (typically 3.3V).
- The pin P0.04 is NOT 5V tolerant.
- Use a voltage regulator or voltage divider if needed.
- Can also be powered from USB (3.3V internally regulated).
- Counts pulses from a source using a reed sensor connected to the board.
- Stores pulse count in non-volatile memory (NVS).
- Sends data to Zigbee2MQTT.
- LED indication for battery charging.
- nRF52840 Supermini board
- Utility meter with pulse output (e.g., BK-G4MT, Honeywell BK-G6M or similar)
- Reed sensor (<20 AT recommended, Normally Open (NO))
- tested with GPS-01 Reed Switch 4×18 (not sensitive enough)
- Battery power supply (tested with 18650
⚠️ use at your own risk)- (supports USB-C power banks)
- Zigbee2MQTT with external converter configured
- EspHome
- MQTT broker
- Home Assistant server
| nRF52840 Pin | Connection |
|---|---|
| P0.06 | Reed sensor signal |
| GND | Reed sensor GND |
| P0.04 | +VDDH (+ 3.0–4.2V) |
| GND | Battery '-' |
- nRF52840 Supermini counts pulses from the source.
- Pulses are stored in NVS flash to survive power loss.
- The counter value and battery voltage are sent to Zigbee2MQTT.
To correctly interpret the counter values as gas consumption, create a Helper in Home Assistant Settings → Devices & services → Helpers → Create helper → Template → Sensor with the following parameters.
5720.17- is the initial reading of your utility meter.
sensor.0xf4ce3662f44a0e45_total_count- your sensor entity in Home Assistant.
Name: Gas meter
State: {{ (states('sensor.0xf4ce3662f44a0e45_total_count') | float(0) * 0.01 + 5720.17) | round(2) }}
Device class: Gas
State class: Total increasing
Unit of measurement: m³⚠️ Don't forget to create an external converter in Zigbee2MQTT first!
- git clone https://github.com/romlisrl/nRF52PulseCounter
- cd nRF52PulseCounter
- esphome compile gas-counter.yaml
- adafruit-nrfutil dfu serial --package .\firmware.zip -p COM15 -b 115200 or
- uf2conv.py firmware.hex -c -o firmware.uf2 (copy UF2 file to the board in DFU mode)
- Make sure the Zigbee coordinator is running and permit join is enabled
- After modifying the external converter, restart Zigbee2MQTT completely (do not use Settings → Tools → Restart Zigbee2MQTT)




