Measuring gas consumption

Those of you who are regulars on the blog already know that I like to measure everything, and gas could not be less.

One thing that not many people know is that it is often very easy to measure because the meters have a "magnetic output" that can be easily read.

The difficulty, more than anything else, is in how to send data from the meterwhich is often inaccessible and has no nearby power sockets.

For a while I was reading the gas consumption using a Jeenode (a kind of Arduino with a radio frequency module for low consumption applications). The system worked very well for a few months until, well, until it was stolen from my meter box! One fine day the readings simply stopped coming in, I went to see what was going on, and my beloved little gadget had disappeared.

I haven't read the gas for almost a year now, and with the changes I have made this year to the boiler and the heating control system, it would be good to have real-time data again so that I can optimise its operation and know if the changes I am implementing are resulting in gas savings.

Measuring gas consumption is not difficult, in most cases. Fortunately, gas meters usually have a magnet that moves with the little numbers that go round and round, so we can detect each turn of the number and calculate the consumption that way.

I originally wanted to do the metering system using an ESP8266 and MQTT (and I set it up). The problem is that I don't have an electrical socket near the gas meter and the ESP8266 is a bit hungry for battery power. On the other hand, the Jeenodes are a bit expensive, for what is out there nowadays. Since I already have a Jeenode receiver installed and integrated through Nodered (my EmonTX power reading system is based on and compatible with Jeenode), and all the components to make a home-made Jeenode for little money, I decided to do it this way.

With an Arduino Pro Mini, one of those that you can get in AliExpress for less than 2€, duly modified to improve its power consumption (removing the power led, which consumes a lot for this application and eliminating the voltage regulator, since I'm going to use it with batteries and I hope they will last several months), and a RFM12B radio module that I already had, I have built a homemade Jeenode in a couple of hours.

The biggest problem is the sketch that has to be loaded in the Arduino, and after a couple of years since I wrote the old one, I don't know where it is, I can't find it, neither dead nor alive, so I had to write a new one. The sketch, in itself, is very simple, the difficulty comes because you have to optimise it so that it consumes as little as possible, which means some additional headache.

As in the previous version, I have used the great Arduino Jeelib library. This library is great for implementing low-power modules with radio communication. It's a bit old, but it's just what I need and I'm familiar with it.

Edito: The truth is that optimising its consumption has taken me much longer than I thought it would. In the end I spent a week testing, measuring and changing the code until I got what I wanted. 

This is the finished device:

Arduino Gas Meter

Edito 2: I include this graph one year later (February 2018), where you can see that the invention is working spectacularly well. After a year of uninterrupted use, the battery (two 1.5 Volt AA batteries) is still above 3 Volts, so many more months of operation are expected before the batteries need to be replaced.

Edito 3: I include this graph three years later (February 2021).

The system is still in operation after more than four years of uninterrupted operation with the same batteries (which were not even new when I put them in to test them for the first time)!

The battery voltage is still above the 2.92Vand therefore there is still plenty of battery life leftHow far will it go?

3 thoughts on “Midiendo el consumo de gas”

  1. How do you do it? I think it's great but I don't know where to start to do something like this and you don't give many clues. How did you do it in arduino?

    • Hello Fernando.

      This is a very old project that was done as a "quick and dirty" solution to the problem.

      I'm currently working on a new version with ESP32. I'm not going very fast, but there is some progress. I will publish it when I have finished a first version.

      Best regards.

      • It better be quick and dirty to see where we're going with this 😉

        It would be interesting to at least see how you read the magnet issue and its algorithm.

        Could you put the code for the meter reading in download or on this website?

        Thank you very much!


Leave a comment