Pulse meters - part 3

Last part of my solution to connect the smart gas meter 'Gazpar'.


On the Gazpar and most (gas and water) meters, there a pulse for every rotation of the second wheel from the right. In this case, every 10 litres of gas (or 0.01 m3). This becomes the base unit for this circuit which doesn't count decimal values.

For example, on figure below, the value is 191675. The shift will have to be done on the computer.

Gas meter

Note also that the change of unit/pulse is sometimes done when the smallest value is "6", not "0". Which means that with the figure above, it would be as follow:

  • Either: "01916754" => 191675 and later "01916758" => 191676 (overshoot mode)
  • Or: "01916754" => 191674 and later "01916758" => 191675 (undershoot mode)

Your call. Confusing? Oh yes... but there is nothing to do about it. And it doesn't make much difference in the end.


The serial speed is unsually slow (by today's standards) for 2 main reasons:

  • The microcontroller has to be flashed to run at 1Mhz in order to keep consumption as low as possible and to work even at a low voltage
  • On these mini microcontollers, there is no hardware UART. It's basically a SoftwareSerial implementation

That said 1200 bit/s is more than enough in our case.

2 modes

  • Relative: each pulse will increment the counter starting from zero (default mode). Values are prefixed by a star ('*')
  • Absolute: the counter is initialised to match the real/physical one. Values are prefixed by a superior sign ('>')

The idea of the relative is that in case of reset, by adding the value to the last known value, it is possible to track the reading.

For example, the last recorded value is 14568 on the computer. There is a reset of the microcontroller and it loses its memory. Next pulses will therefore return '*1 ', '*2 ', etc... The computer just has to add 14568 + 1 = 14569, 14568 + 2, etc... to guess the right values.

Initialising the value

Using a terminal (or from the reading software), just send a inferior sign ('<') followed by the value followed by Carriage Return with 5 seconds.

The stored value will be returned (absolute mode above).

Querying the value

Each pulse will send over the wire the new value but it is also possible to query it by sending a question mark ('?').

The stored value will be returned.

Hooking it

Idealy, the pulse meter should be within meters of the meter (sorry for the pun). The capacitance on the wires is not really an issue but it seems more logical this way (your point of view may be different).

Several possibillities of attachments are possible. Among them:

Using a ESP8266 as a relay

The same way I am using a ESP8266 to forward the reading from the electricity smart meter, it is possible to use it to send the reading periodically. Either by keeping the ESP8266 running, in the case the notification is Synchronous or by waking it up every x minutes and polling the current value (by sending a '?').

Using the serial port on the Raspberry

or a USB Serial adapter if the computer and the meter are not too far apart.

In this case, the shorter the better on the serial side but at 1200 bits/s the risk of trouble is low.

Using a RS-422 or RS-485 link

In this case, the distance can be quite long.

Other meters

This solution was developped initially for a gas meter but it can be used for any kind of pulse meter: water, door, etc...

The code and schematics are available (AS IS) on github.