This is program is a spin-off from this project, as it reads both the Elster A100C electricity meter using this DIY hardware, and uses the spare CTS/RTS lines of the same serial port to read the status of a gas meter incorporating a magnet on the least significant digit, as shown here by somebody else. As it happens, my meter looks exactly the same.


With the ever rising cost of electricy I became interested in knowing what the money is being spent on, is it that computer running 24x7? Is it the electric oven? Maybe the fridge freezer? Some of these can be measured at one moment to give an accurate long term average, others will always vary from day to day, so although they could all be estimated it is better to get the true figure of power consumption over the medium term.

Which is where this little program steps in. The Elster A100C, and probably many others - though not necessarily in the same format, continuously outputs its status using invisable infrared pulses. Specifically, every second it outputs 110 bytes containing, amongst other things, the total amount of energy consumed in WattHours. This is 1000 times more resolution than displayed on the lcd - it is WattHours not just KiloWattHours.

The output of the gas meter is much more crude, a hidden magnet is embedded in the least significant digit. No idea how common this is, but given the limitations of having no electrical power, this signal is probably as good as it gets. A reed switch can detect the presence of this magnet, in my case closing the contacts when the digit reads 4.5 to 7. Timing how long it takes to make a full revolution gives an average gas consumption over that duration. As this is the thousandths digit, a full revolution means one hundreth of a unit (1 cubic meter) has been used. Putting all this together and using my latest bill, that means an open to close transition of the read switch costs 0.323 pence.

The program

The program rdmeters.c is the culmination of the data gathering and comparison process. This program reads irda serial data from electric meter, in my case an Elster A100C and displays per line:
1. The E character.
2. Current system time in UNIX time.
3. WattHours used.
4. Two unknown but surely meaningful bytes. Does anybody know?
5. An estimate of the Watts (ie. energy per second) consumed since the WHs counter changed.
and when a open to close gas meter signal arrives, it outputs in the format:
1. The G character.
2. System time in UNIX time of the previous open to close transition, with millisecond resolution.
3. Duration of the open to close, to, open to close. ie. Seconds between digit rotations.
4. Based on duration, average number of cubic meters used in that period.

This program can be compiled with the line:
gcc -Wall rdmeters.c -o rdmeters
and then run with the line:
./rdmeters /dev/ttyUSB1 "Elster A100C" 2> /dev/null
where the /dev/ttyUSB1 is the second usb-serial dongle. The string "Elster A100C" helps rdmeters locate a known position in the data stream, from this it can work out the beginning and the end of each data frame.

Get it wrong and rdmeters will be unable to find the frame, and will instead print out raw hex of the first 256 bytes of irda stream and then quit, leaving you to find the make/model name in the hex and use it as the correct option to rdmeters.

It is assumed that the make and model fields are always in the same part of the data frame relative to the checksum and WHours counters. You will know that assumption is wrong if the unit counter don't match what you see on your meter.

The 2> /dev/null throws away all mentions of checksum failure, which is probably what you want when it working. I see maybe 1 checksum failure per minute, with the laptop in a cupboard with the plastic near the ir sensor leaning against the eletricity meter by the ir sender.

For the gas meter reader to work, the serial port must support the TIOCMGET ioctl to directly read the status of the CTS pin. The statserial utility can be used to test for this, as it uses the same access method. This was tested with an on-board serial port and an FDTI based usb-serial dongle (watch out for the FDTI bug in 2.6.28.x).

Data format

See rdmeter for a description.


See rdmeter for a description.


While building this circuit, the voltages of the 9 pins was measured on both a real onboard serial port and a USB to serial converter. They are provided here for reference. The serial port was active but not sending or receiving any data.



1. Find a source of the docs that specify the actual A100C data format.
2. Tidy up the references between rdmeter_hw, rdmeter and rdmeters.
3. Supply and describe the AWK script that parses this output into per day files.


Thanks to Iain for bits of information and helpful links to the gas meter.


Written by greg on 14/10/2009, : r.gregory at liv ac uk. Would welcome any comments.