Instructables

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

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!


Chris

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


 
Remove these adsRemove these ads by Signing Up
niomix1 year 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
-1,18,12.22,-12,34,0

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

Alvast dank !
petje721 year 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
jslegers1 year ago
Look good. Will a 5 volt FTDI cable like this one also work ?

http://www.ebay.com/itm/FTDI-FT232RL-USB-to-TTL-Serial-cable-5V-Converter-Adapter-for-Arduino-CTS-RTS-/170918433764?pt=LH_DefaultDomain_0&hash=item27cb8853e4
pgrassia2 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)  pgrassia2 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 cpo2 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)  slona2 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 cpo2 years ago
Many thanks for talking us through - awesome!
cpo (author) 2 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.
enderval2 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)  enderval2 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! :)