Making a datalogger for a Kamstrup electricity / gas meter with Raspberry Pi!

Picture of Making a datalogger for a Kamstrup electricity / gas meter with Raspberry Pi!
Schermafdruk van 2012-06-02 15:53:09.png
About Raspberry Pi

So finally I received my new Raspberry Pi. This is a small, low power ARM linux board featuring a ethernet adapter, 2 USB ports and even a full-HD HDMI port for a mere $30!. Check out www.raspberrypi.org for more information.

After running XBMC on it (no mpeg2 decoding, lame) and trying it out as a NAS (no SATA interfaces, sloooow) i decided to use it as a combined hardware / software project.

Sparks all around

The energy company here in The Netherlands made the mistake to install a Kamstrup 162 J series meter in my home with an mysterious looking phone jack on it. The phone jack kept intriguing me day after day. A small investigation on the internet indicated it to be a serial interface to get the meter counters and LOTS more information.

This instructable describes all the hardware and software I used to create this interface. The end result will be nice looking graphs on cosm, a free data collecting service found on the internet.

What it will give you

At least you will have fun making this interface. It will teach you about the raspberry pi, compiling a C program, interfacing to your FTDI board. And when things start to work: ultimate satisfaction :^)

And last but not least: it wil make you aware of the footprint you leave on this earth. I wanted to understand how much resources our household uses and in time, reduce the amount of gas and electricity we use.

What you will need

* An electrical meter fitted with a P1 port. In my case this is a Kamstrup 162, other Kamstrups will most likely work in the same manner.
* Linux commandline experience.
* Some basic TTL electrical knowlegde.
* A working Raspberry Pi;
* A FTDI cable or breakout board (as found on Sparkfun);
* A mini-usb cable.

All set?

Let's go!


PS: Because Raspberry Pi is a long word, I will (lovingly) refer to it as rPi...

niomix2 years ago
Hi CPO !
just a simple question...
i'm not so expert about curl.
i can't understand well the "--data-binary @/tmp/cosm" \ comman
i need to sent this string with negative, and decimal number

i've a cron based poller that get from arduino the datas and write it into the following file /tmp/cosm/data-to-send

cat /tmp/cosm/data-to-send

how can i send this (multi datastream ?)
thankyou !
embezon2 years ago
Klopt het dat het juiste type van de ftdi kabel : "FTDI TTL-232R (5V)" is ?

Alvast dank !
petje722 years ago
Great instruction, but... I can't figure which TFDI cable or FTDI breakoutboard to order... I can't find the breakoutboard on their site and/or do I order this cable? http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf Could you please send me the correct links? thanks
jslegers2 years ago
Look good. Will a 5 volt FTDI cable like this one also work ?

pgrassia3 years ago
Not sure why you used the ftdi cable. To adjust the voltage of the signal coming from the Kamstrup ?
You do know what the raspberry pi has a UART with its pins exposed. Right ?
cpo (author)  pgrassia3 years ago
Yes it has an UART, but working on 3.3v levels. Anything above 3.3v that will destroy your little friend. Also, I had the FTDI around to it seemes the next logical step :)

The Kamstrup also features an IR port. When I get around to it, I will create a bidirectional IR device to communicate with the meter.
slona cpo3 years ago
this is a great project! Can you talks through the process for configuring the FTDI cable to invert the RXD pin using the FT_PROG tool with a windows Machine - is that by connecting the cable to raspberry first?
cpo (author)  slona3 years ago
Thanks for your kind comment!

You should download the FT_PROG first at http://www.ftdichip.com/Support/Utilities.htm

The cable does not need to be connected to the raspberry pi. After installing the FT_PROG the cable will be detected. When you start the FT_PROG, press F5 to load the cable eeprom. Now find the "Invert" options in the tree.

You should only invert the RX pin there.

After modifying, program the settings back into the cable.

Undoing this is simply the same, only disabling the invert option :)

Easy peasy...
slona cpo3 years ago
Many thanks for talking us through - awesome!
cpo (author) 3 years ago
BTW: If you need any further assistance, please let me know; maybe I can add screenshots to this instructable to clarify the process.
enderval3 years ago
I never thought to use RPi as a data logger like this, that's a great idea and a perfect use for it.

I just ordered mine through www.tinyputers.com so should get mine... eventually. The confirmation email said mid-August. My first project will be an advanced alarm clock. Hopefully there's some good instructables available for that once the time comes.
cpo (author)  enderval3 years ago
It's a very nice platform to work with. The Linux system has all the tools you need to easily parse the data from the meter.

I like it a lot, if you make anything cool when you get yours, please let me know! :)