Gas Meter

A few month ago, the gas supplier changed our meter for a new one (NPL 12/110 Gas Meter). Nothing fancy, still non-smart but with the possibility of connection for remote reading.

I found a compatible device referenced TD027825 but wasn't keen in spending almost 40€ just for this.

I ended up buying some cheap reed switchs on Ebay (~ 3€ a batch of 4) and it worked! Every time the last digit of the counter reaches '5', the switch closes and is released when the counter reaches '6'.

Hooking it on the Raspberry Pi

Using a free GPIO pin (#7), it was just a matter of detecting low pulses. Using a simple while loop, it worked first time!

But a loop is not a really option when one wants to deal with several synchronous and asynchronous events. Trouble started with the use of the callback mode.

RPi.GPIO now having a bounce parameter, it should have been easy to ignore the reed switch bounce. And actually this seemed to work well at the begining. Then I started to notice that the counting was usually out of sync. Mainly going too fast on the raspberry side.

For example, the meter would count 160 litres while the Raspberry would return anything between 150 and 300! After extensive research, it turned out that I had to deal with 3 differents problems:

Serious measures were needed...

Improving acuracy

First I added a 100nF capacitor which helped a lot but was not enough. Then I introduced a bit of intelligence in the process with a tick/tock system:

Both going up and down events now call the event function.

With this mechanisms almost all the bounces and spikes are stopped but there are still cases when it is counting too fast, especially when the wheels are turning very slowly. There is a hysteresis on the reed switch but nothing is perfect.

To filter further, a delay has been added. Since it physically impossible to have 10 litres used in less than 5 seconds then any pulse happening too soon after another is rejected as bogus.

I can't guarantee an accuracy of 100% but so far so good!

Schematic

Schematic Gas Meter

« Page 3 / 3

    « Page 3 / 3