LoRa Pulse Counter
Monitoring of gas meters and other pulse sensors via LoRaWAN
As part of integrating more devices into my smart home, I came up with the idea of also monitoring the gas consumption of the central heating. The Elster Kromschröder BK-G4 meter installed by my energy provider has a permanent magnet in the last position of the mechanical counter. A reed contact can be fitted below this, which generates a pulse with each rotation.
Unfortunately, there is no power socket nearby, so a battery-powered wireless solution would be ideal. I noticed a LoRaWAN rain gauge circuit board lying around that I had recently developed. It could be modified for this!
Modifications
With the rain gauge, the magnet moves past the sensor as soon as the tipping bucket is filled on one side, which generates a very short pulse. With the gas meter, on the other hand, the pulses are significantly longer. It is also possible for the counter to stop in such a way that the reed contact remains permanently activated. The current then flowing through the internal pull-up resistor in the microcontroller significantly increases the quiescent current consumption. I have therefore adapted the firmware to deactivate it by setting the “-D USE_EXTERNAL_PULLUP” flag. Instead, the otherwise unpopulated resistor R3 is populated with a significantly higher impedance value of 100 kOhm. The flag is added to the line beginning with “build_flags” in the platformio.ini file before compilation. To debounce the contact, a 100nF capacitor was additionally connected on the back of the board across the connections of the reed contact.
Instead of the rain gauge battery board, a 2xAA battery holder is soldered directly to the original contacts. An SMD button is also placed directly on the main board. The 868MHz antenna of type Yageo ANTX150P116B08683 is attached to the upper part of the housing.
Reed contact
I am using a 3D printed holder to mount the reed contact. The model with the number 2749173 can be downloaded free of charge from Thingiverse. The wired contact is embedded in a suitable mounting position using 2-component glue. For the wiring, I use shielded diode cable with the shield connected to earth.
Enclosure
The assembly fits into a Hensel DP9025 junction box. I designed a retaining plate for this, which is also 3D printed. It is screwed into the box. The circuit board can be snapped into place and a separator fixes the battery holder in the lower part. This can also be secured against falling out with a Velcro cable tie.
Payload decoder
A small adjustment to the payload decoder is also necessary, as instead of mm of rainfall the gas consumption should be measured in cubic meters. Line 40 is modified as follows:
The returned value is an absolute value of the counter reading in the microcontroller, so the change over the desired period must be calculated just as it is done for the rain gauge.