Gas Monitoring

Hi everyone,

I have an emonpi (Raspberry Pi 3) with the bundled temperature sensor that I purchased in March 2018 and would now like to monitor my gas usage. I think I know how to do this but would welcome any advice or comments on my plan.

I have a Schlumberger R5 gas meter which has an RJ11 socket that gives out a pulse (probably a reed switch) on pins 3 & 4 for each cubic foot of gas used. I have tested this by connecting a cable from the meter to the GPIO on another Raspberry Pi 3 and using a python script, primarily to debounce the pulse and record the pulse count. The recorded pulse count plus the meter reading when the script started matches the new meter reading.

My plan is to connect the cable from the meter to the GPIO on the emonpi Raspberry Pi with the debounce script running and this script would also output a signal from a GPIO pin that I would feed to the digital pin 3 on the emonpi ATmega328 board.

You’re going round in circles there.
(a) the pulse input on the “emon” part of the emonPi is accessible via the “RJ45 I/O” socket, and debouncing is already present in the software, or
(b) You could go directly from your RPi into emonCMS and not back into the “emon” processor (don’t ask me how, @pb66 is the expert).

Robert, thanks for the information. I had assumed from some of the comments in the forum that switch bounce could be a problem and was therefore not handled by the software. I will use the RJ45 socket, a much simpler solution.



The way the debounce works is when the interrupt triggers, it ignores anything else for a defined time, the default is 110 ms from memory, thus allowing the normal 100 ms optical pulse to be counted, and one assumes a reed won’t bounce for that long. If it does, the time period can be changed. But that creates difficulties if you’re not aware of the side effects when you come to update your emonPi - your altered sketch will get overwritten unless you go about it the ‘wrong’ way.

Most of the info needed is in the Directly connecting to Optical Pulse Counter with RPi? and Pulse monitoring on a Pi threads.

If you hook up the pulsecounter to the emonPi rj45 and all is well, that is indeed the simpler option. If you find you need or want different debounce or any other changes, the Python to emonHub solution makes it easier to make changes and also retain those changes when updating via emoncms.