CurrentCost and Ubuntu
December 15th, 2008
Uncategorized
I received my CurrentCost unit today from the Eco Gadget Shop. I’m impressed with their service, it only took a few days to arrive. Anyway, as soon as I unpacked the unit and installed the cable grip, it was time to have a play.
As any self-respecting Linux geek would do, the first thing I did was try to hook the unit up to my Ubuntu Intrepid Ibex box. Theres quite a bit of information out there on logging the data that the CurrentCost unit spits out but most of it tends to lean towards the Windows/Mac OS X side or concentrates on the serial port interface of the older cables. What I wanted was a Linux and USB serial cable solution.

The first thing you need to do is setup the USB serial cable. This is pretty trivial if you know what you are doing but can be quite daunting if you don’t. First plug in the USB cable and verify that it has indeed been recognised.
A lsusb should show something along the lines of this (your output will vary but the important bit is the part that reads:

Bus 004 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Take note of the ID, its in two parts, the 067b bit and the 2303 (your numbers will most likely be different). Then its time to modprobe the USB serial driver in.

Notice that the two numbers from the previous command have been used with a ‘0x’ added to the front of them. Issuing the dmesg command should show you that the USB serial driver has been loaded (look near the end of the output) and that /dev/ttyUSB0 is now available for you to read.
From this point on I really recommend you read the excellent how-to by Paul Mutton over on his website. The perl script he supplies only needs two lines changing. Change:
my $PORT = "/dev/ttyS0"; to my $PORT = "/dev/ttyUSB0"; and $ob->baudrate(2400); to $ob->baudrate(9600);
The first change is to point to the USB serial port and the second to set the baud rate to the newer units speed of 9600.
The rest of Pauls how-to will get you up and running, logging the data and producing nice looking graphs.
7 Responses
-
-
[...] CurrentCost and Ubuntu « linuxuk.org A couple of interesting commands to run when setting up the CC128 with the data cable. (tags: currentcost serial ubuntu) [...]
-
JeremyG December 18, 2009 at 9:52 pm
Hi there, just to say thanks! Your post saved me from pulling my hair out
My data now logging nicely to cacti server!
-
JamieBennett December 18, 2009 at 10:26 pm
That’s great to hear!
-
skyewright February 4, 2010 at 7:05 pm
Very useful thanks. I’ve just followed your procedure to set up reading of data from the new Current Cost model, the CC128. The only change needed was to use a baud rate of 57600 instead of 9600. Thanks.
-
There is another change needed to use the script on http://www.jibble.org/currentcost/.
The regexp has to be changed to
m! *([\-\d.]+).*0*(\d+)!
since the CC128 sends the temperature before the power not the other way around like the older devices do.
I had a lot of problems before I disabled the regexp and could see what was actually coming out.
-
Sorry, the regexp was filtered by this commenting function since it contained xml-tags. Hope you understand what I meant anyway…
Hi, my name is Jamie Bennett. I'm a technologist, programmer, researcher, tech evangelist, open source monkey, linux user and self confessed gadget freak.

[...] on the web. Connecting under Linux is fairly straight forward, there is fantastic article at http://www.linuxuk.org/2008/12/currentcost-and-ubuntu/. This explains how make the USB device available to read from as a device. Next you can use a Perl [...]