Skip to content
Pulse counter with ESP8266 and Domoticz
C++ C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
schematic First working version May 7, 2018

Pulse counter with ESP8266

This simple sketch detects magnetic pulse thanks to a reed switch, and sends it immediately to a Domoticz instance AND an MQTT broker.

It is used with a Kent V100 (PSM) water meter, which is heavily used in Belgium. It generates one pulse per 0.5 liter.

The hardware schematic is quite simple:



Digital input D1 is set to ground thanks to a pull down resistor R2. When the reed switch is closed, the input is raised to VCC and an interrupt is detected. The LED1 is flashing to provide a visual control when a pulse is detected.


Initially, the sketch was foreseen to Domoticz only. But MQTT has been added in order to use Grafana & InfluxDB as database and visualization tool, allowing greater flexibility in the aggregation and custom made dashboards.


Before compiling, create a private.h file based on the provided private_example.h file: it should contain your Wifi settings, as well as the Domoticz parameters. The domoticz_counter_idx parameter refers to the ID of the "incremental counter" created in Domoticz.

The code contains a lot of debug statements. If those are not required, comment the #define DEBUG at the beginning of the main file.

You can’t perform that action at this time.