Interfacing the CurrentCost meter to your PC

Note: since this article was written, CurrentCost have started selling data cables via their eBay store.
The current craze at IBM Hursley involves the CurrentCost meter, a simple little gadget that measures power usage in your house. These are being discussed on IBM blogs everywhere, because while the device itself is very neat, it also has the ability to output the data to a PC, allowing all sorts of neat graphing and other statistical analysis to be performed.
Unfortunately, while the device is available in the UK for a very reasonable price, the data cable is not widely available (I got mine from a guy at work who gets them directly from the manufacturer). Fortunately, the cable is actually quite simple to make yourself if you have some basic electronics knowledge!
The CurrentCost device has a RJ-45 connector on the base that is used to output the data stream - note that this is not an ethernet connection! It is in fact outputting a TTL-level serial data stream at 9600 bits per second (baud). This means that all we need to do to feed this into a standard PC serial port is convert the TTL signal levels into RS232 signal levels.
The majority of microprocessors use TTL signals to communicate, where 0V represents a binary ‘0′, and 5V represents a binary ‘1′. Annoyingly, the RS232 standard instead expects to see -5 to -15V to represent a binary ‘0′, and +5 to +15V to represent a binary ‘1′. Fortunately, this is such a common problem that a single-chip solution is available - the MAX232 series of chips.
For this project I’m using a MAX3232 chip, which accepts a wider range of voltages and is a nice handy thing to have around. You can pick one up from your local electronics supplier - I got mine from Maplin, but online suppliers will be even cheaper. We’re also going to need five 100nF capacitors, which you can pick up at the same time, as well as a 9-pin D-SUB socket. Finally, we’ll need to connect to the RJ45 connector on the bottom of the CurrentCost meter - I just used an old CAT5 cable I had lying around and cut the end off.
The circuit diagram is shown below - I use solderless breadboard to prototype mine, as it’s nice and easy to change around if you make a mistake. You will probably have to solder wires into the 9-pin D-SUB connector though.

Note that the CurrentCost device is transmit-only - it doesn’t respond to commands sent to it. As such, it is only necessary to wire up the TTL to RS232 direction, not the other direction. Also note that the MAX3232 has two duplex converters (O1/I1 and O2/I2) - we’re only using one of those at the moment, so we tie the other inputs to ground.
For details on RJ45 pin-outs, see here, and for 9-pin DSUB pinouts see here - although often D-SUB connectors have the pin numbers marked.
When you’re done you should have something that looks like this (or neater, probably!)

Now it’s simply a case of hooking it up and crossing your fingers! The easiest way to test it is to view the RS232 input - on Windows, you can use HyperTerminal or PuTTY, or on Linux you can try Minicom. Don’t forget to set the baud rate to 9600bps. If you’re not familiar with how to use your terminal program, I suggest you try it with a known good device first - there’s nothing more annoying than trying to figure out if you’re not seeing anything because your circuit is wrong, or because you’re not accessing the COM port correctly!
If it’s working, you should see a whole bunch of XML data appear every 6 seconds or so - Rich has kindly broken this down.
And that’s it - what you do with the data is now up to you! Personally I pipe it into a MySQL database, but I’m sure you can come up with many more ingenious things to do with it!
Filed under: Projects, IBM, Electronics on June 15th, 2008
I used a MAX233 (free from maxim’s samples page). Its a 20pin DIL, but doesn’t require any external components.
“the cable is actually quite simple to make yourself”
I was with you up until about this point…
(very cool, though!)
Hi Mat,
I agree, the MAX233 would be slightly easier (although I think you should still use a capacitor between 5V line and ground, ideally), but the MAX3232 is a little more common (and works with 3.3V and 5V voltages, which is useful if you tend to re-use stuff!)
I built a live, online national electricity meter for the Energy Saving Day (E-Day) website http://www.e-day.org.uk and am very impressed by the work you are doing and wonder if their might be any scope for a collaboration as part of next year’s E-Day?
I have been looking at alternatives to buying an OWL or CurrentCost device and/or their induction loops, and am intersted in keeping the cost of accessing domestic energy information as low as possible and in making the data presentation as engaging as possible.
Please get in touch if you think Energy Saving Day (E-Day) is something this group could help.
Warmest regards
Matt
I have tried to build it, but it doesn’t work.
I have a data cable orderd, and pin1, pin4, pin7, pin8 are connect in the UTP connector. Do you have some tips
I have found the problem.
Pin1 = +VE
pin4 = -Gnd
pin8 = TTL out
I have got my CC128, Is it possible to make your own cable but instead of Serial cable at the end, can I make it a usb, I know where to get the drivers from, if so how would I make it up, I have plenty of ethernet cables lying around and plenty of male usb cables lying around, would it be a case of just cutting the two and joing them ?
Frank - I’m not convinced I have a CC128 and there seems to be a datastream out of these pins (doesn’t look like XML). Does the data cable work some magic that isn’t obvious.
Hi,
I’ve knocked together your circuit on some prototyping board, many thanks as I spent ages wondering why a straight through cable didn’t work, you seemed to be the only person on the internet mentioning that it’s a TTL output… The output that I get in both hyperterminal and cutecom on linux/fedora11 has loads of odd random chars in it but it obviously nearly ok as you can see various parts of the XML. I was wondering if this may be noise but I can’t imagine that the circuit would be suceptable to noise- any suggestions? I can post some of the output if required.
Thanks.
The circuit should be very resilient to noise. It’s possible you have incorrect port settings, I believe the CurrentCost uses 8 data bits, no parity and 1 stop bit.
The other possibility is that if you are using a CC128 rather the older, white original CurrentCost pictured earlier in the blog post, the baud rate has been altered to 57,600. There are more details here:
http://www.currentcost.com/cc128/xml.htm
Thanks for the reply, I’ve also been on to the current cost support who have advised that the meter is damaged in some way (the memory is full of garbage, as well as the xml being full of random chars in amongst the proper outout.) The upshot is that Southern Electric are sending a replacement.
My new replacement CurrentCost arrived today and I still get the same problem, almost good, but slightly garbled output. If I was to guess I would say it looks like individual bits are being lost or there is some sort of timing problem.
I have noticed that my chip is a MAX3232CPE, rather than a MAX3232, would this make any difference? Could my slection of capacitor be at fault?
Here is a small snippit of the output:
þ þ þ095.9095.9255.9095.9255.
095.9255.95535 ÅÁùÑÁåÕñ½‘ÅÁù 5535409555
35409555354095553540955535409555354095553540955535409555354095553
540955535
Ah, it looks like your web site has chopped out all of the XML tags, oops, this means the snippit isn’t of much use.
has anyone a diagam to make this adaptor useing a max 233 please.
I had the same problem when used the RJ45 connections shown in the circuit diagram. Only got garbage. Got it working when I changed to using pins 4 and 8 (and power on 1) as shown by Frank on 29/1/2009. Lots of nice xml to play with now.
try one of these if you don’t’ like to solder much.
http://www.sparkfun.com/commerce/product_info.php?products_id=449