Electricity Meter

How to use a Raspberry Pi for reading a Kamstrup Omnipower Electricity Meter

Realising that the documentation for the different components and packages is very I have made this brief summary of how I managed to pick up readings from my Omnipower Meter with a Raspberry Pi.

For me the interesting electricity data is Meter status (as seen on the display) and actual total power consumption and consumption for each phase.

I prefer to extract the data as readable raw data so it can be used directly by other applications. Then data can simply be shared with other devices and web services over UDP or as plain csv files etc.

Monitoring daily and yearly power consumption from a Kamstrup Meter

First of all Push messages needs to be enabled from the meter even though the documentation indicates that this is done by default. So contact your power supplier and request push messages and also two keys as the information is encrypted. You will then get a mail from Kamstrup with the keys. It comes in a tabulated setup which will be probably distorted in the mail.

So a message like this

KeyType Generation Key
64 1 0x34706890A462483973431E01C8914E21
65 1 0x946F0B5C495176089391783F32C4E33A

Should be reformatted to


64 = gpk60 = encryption_key
65 = gpk61 = authentication_key

Connect your RPi serial ports to the CCC connector at the Meter like this:

CCC RPi pinGPIOFunction (RPi)
2814Data from RPi (Tx)
51015Data from Meter (Rx)

For a RPi4 (green frame) the above serial port to use is called ttyS0 when listening to the Meter. GPIO14 is not necessary in this setup but can be used for other applications that makes queries for the Meter.

For listening to the Meter Gurux has a good library that can be installed from https://github.com/Gurux/Gurux.DLMS.Python and they also have an excellent support so sign up at the forum if you have troubles. I didn’t succeed with a RPi3 with Gurux but switching to a RPi4 suddenly made things going.

When ready you can make a test drive in order to see if the Meter is pushing messages which it should do every 10 sec. I prefer connecting to the RPi with SSH and Putty and here at the command prompt first change directory to the Gurux listener script:

cd /home/pi/Gurux.DLMS.Python/Gurux.DLMS.Push.Listener.Example.python

Then run the main.py so you can see the options:

python main.py

Now try main.py with addition of the serial port:

python main.py -S ‘/dev/ttyS0:2400:8None1’

Please notice 2400 bps is important. The above should give some initial readings (encrypted) to confirm that the connection is working.

Finally run the application with the encryption keys (maybe swop A and B).

python main.py -S ‘/dev/ttyS0:2400:8None1’ -B 34706890A462483973431E01C8914E21 -A 946F0B5C495176089391783F32C4E33A

In my case I needed to swop -A and -B as encryption_key and authentication_key was mixed up probably by Kamstrup. You will then see readings presented in different formats. Each Data Object has its own ID as can be seen at page 4 in this list: https://radiuselnet.dk/wp-content/uploads/DLMS-COSEM.pdf

Meter status (as seen on the display) and actual power consumption are all represented by number 14 in the list.

I added some OBIS variables to the python script (ask for full code):


            if OBIS==”01 01 01 08 00 FF “:


            if OBIS==”01 01 01 07 00 FF “:


            if OBIS==”01 01 15 07 00 FF “:


            if OBIS==”01 01 29 07 00 FF “:


            if OBIS==”01 01 3D 07 00 FF “:


Now that data is identified you can develop your own version of main.py for sharing the data as you like with other devices.