Skip to content

romlisrl/nRF52PulseCounter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buy Me a Coffee ESP-IDF Zigbee

nRF52840 Pulse Counter with Zigbee2MQTT

nRF52840-based pulse counter that counts pulses from utility meters with magnetic impulse output and sends data to Zigbee2MQTT.


🚀 Quick Start

  1. Copy the external converter to Zigbee2MQTT.
    👉 See External Converter
  2. Restart Zigbee2MQTT completely (full restart required).
  3. Enable Zigbee pairing (permit join)
  4. Flash the firmware onto your nRF52840 Supermini board.
  5. Create Home Assistant helper.

⚠️ Power Notes

  • 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).

✨ Features

Zigbee2MQTT

  • 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.

🔧 Hardware

nRF52840 Supermini


📦 Software Requirements


🔌 Wiring Example

nRF52840 Pin Connection
P0.06 Reed sensor signal
GND Reed sensor GND
P0.04 +VDDH (+ 3.0–4.2V)
GND Battery '-'

nRF52840 Supermini wiring


🚀 How It Works

  1. nRF52840 Supermini counts pulses from the source.
  2. Pulses are stored in NVS flash to survive power loss.
  3. The counter value and battery voltage are sent to Zigbee2MQTT.

Zigbee2MQTT

🏠 Home Assistant Configuration

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.

📊 Template

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: 

⚡ Installation

⚠️ 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)

📝 Notes

  • 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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors