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...

Step 1: Preparing the RPi

Enter the Pi

I have fitted the rPi with a 8G class 4 sdcard containing the standard Debian ARM distribution of the raspberry pi foundation.

This can be found at http://www.raspberrypi.org/downloads. Write the default debian distribution to the sdcard using the dd command (patience!) and make sure the device boots correctly. Also check if it runs stable (the voltage of some power sources can be too much off-spec to drive the rPi in a stable manner) and connects to your network correctly.

I like to use SSH all the time to login into the rpi. I have included a sample session of connecting to the rPi using SSH:

chris@chris-xps15:~$ ssh pi@
pi@'s password:
Linux raspberrypi 3.1.9+ #66 Thu May 17 16:56:20 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu May 31 20:02:23 2012 from chris-xps15.home

If you use Windows, Putty is a good alternative to the Linux SSH shell.

Because we are doing some hardcore serial communications, I like to have minicom around. This can be installed by issuing the "apt get install minicom" command. Start it by issuing the "minicom" command. If you are as old as me and have owned one of those pre- internet modems, it should remind you of those wonderful years...

Our rPi is now completely configured to get things going!

Hi CPO ! <br>just a simple question... <br>i'm not so expert about curl. <br>i can't understand well the &quot;--data-binary @/tmp/cosm&quot; \ comman <br>i need to sent this string with negative, and decimal number <br> <br>i've a cron based poller that get from arduino the datas and write it into the following file /tmp/cosm/data-to-send <br> <br>cat /tmp/cosm/data-to-send <br>-1,18,12.22,-12,34,0 <br> <br>how can i send this (multi datastream ?) <br>thankyou !
Klopt het dat het juiste type van de ftdi kabel : &quot;FTDI TTL-232R (5V)&quot; is ? <br> <br>Alvast dank !
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? <a href="http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf" rel="nofollow">http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf </a>Could you please send me the correct links? thanks
Look good. Will a 5 volt FTDI cable like this one also work ? <br> <br>http://www.ebay.com/itm/FTDI-FT232RL-USB-to-TTL-Serial-cable-5V-Converter-Adapter-for-Arduino-CTS-RTS-/170918433764?pt=LH_DefaultDomain_0&amp;hash=item27cb8853e4
Not sure why you used the ftdi cable. To adjust the voltage of the signal coming from the Kamstrup ? <br>You do know what the raspberry pi has a UART with its pins exposed. Right ?
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 :) <br> <br>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.
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?
Thanks for your kind comment!<br /><br />You should download the FT_PROG first at http://www.ftdichip.com/Support/Utilities.htm<br /><br />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 &quot;Invert&quot; options in the tree. <br /><br />You should only invert the RX pin there.<br /><br />After modifying, program the settings back into the cable.<br /><br />Undoing this is simply the same, only disabling the invert option :)<br /><br />Easy peasy...
Many thanks for talking us through - awesome!
BTW: If you need any further assistance, please let me know; maybe I can add screenshots to this instructable to clarify the process.
I never thought to use RPi as a data logger like this, that's a great idea and a perfect use for it. <br> <br>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.
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. <br> <br>I like it a lot, if you make anything cool when you get yours, please let me know! :)

About This Instructable



More by cpo:Making a datalogger for a Kamstrup electricity / gas meter with Raspberry Pi! Create the Arduino driven LED growbox 
Add instructable to: