CurrentCost hacking – starting to identify appliance power usage

I needed a break from work tonight, so went back to playing with the CurrentCost meter – a chance to try a few new things.

The objective
I want to make a start on identifying how much electricity different things in my house use. To begin, I’m going to start with a very manual user-driven approach:

Subscribe to updates from the CurrentCost meter, and when a significant change in usage occurs, ask me what I’ve just switched on or off, and collect that information to build up a record of how much electricity different devices use.

It’s already quite late, so I just wanted to hack a quick first version together. I decided to write it as a small Java app.

As I’ve mentioned before, I’m publishing the CurrentCost readings to a small broker running on my home server. The plan was to write a Java application that uses MQTT to subscribe to updates from the broker.

Why? Because I’ve not used Java on the Slug before, or with MQTT. (Is that not a good enough reason? 🙂 )

I’ve written it as a command-line app, because it’s a quick way to run it from different devices around the house. (That is, by cheating 🙂 I’m actually running the app on the home server, using PuTTY / PocketPuTTY / SSH etc. to run it from my ThinkPad, PDAs, mobile, EEE PC, etc.).

Step 1 – Get Java on to the Slug
I’m using Jikes for SlugOS/LE. I found instructions to set it up on, and found the packages via ipkgfind:


ipkg install classpath_0.97.1-1_arm.ipk jamvm_1.5.1-1_arm.ipk zlib_1.2.3-2_arm.ipk 
ipkg install jikes_1.22-1_arm.ipk -force-depends

Step 2 – Get the Java MQTT client library
I found a link to a Java client library on

The zip file there contains a J2SE/wmqtt.jar which I copied to the server.

Step 3 – Find some existing Java MQTT client sample code
There is a good developerWorks article with source code for writing MQTT subscribers in Java. I started with the Callbacks example which gives you enough code to subscribe to the broker, and get the data out of messages received as a byte array.

Step 4 – Compiling and running
To compile:

/opt/bin/jikes -classpath /opt/share/jamvm/

To run:

/opt/bin/jamvm -classpath /opt/share/jamvm/ CurrentCostTrainer

I did run into a small problem running this, which required me to install the file package.

ipkg install file

The reason for this is documented here.

Step 5 – The app
That was pretty much it – the bits of the app that I wrote are fairly trivial. The app runs at the command line, stores the last known reading from the CurrentCost meter, and if a new reading is significantly different from it, it prompts for a description of what changed.

00:55:46 : I noticed a change of 20W. What did you just switch off? [unknown] : BT Vision
00:56:01 : I noticed a change of 82W. What did you just switch off? [unknown] : TV

To save me having to watch the prompt the whole time, I added a line to make it beep to get my attention when it prints a prompt for the user.

The descriptions entered by the user are being written to a text file.

dalelane@minipooter:~$ more CurrentCostTraining.xml
  <descr>XBox 360 - standby</descr>
  <descr>BT Vision</descr>

The source, if it is helpful for anyone, can be found here.

What next?
Some ideas…

Instead of cheating and running the client on the server itself, the query prompts could be properly sent to a mobile.

Previous results could be examined before generating the query, which would let the query prompt include allowing some possible suggestions. E.g. “I think you’ve just switched on the television. Is this correct?”

Comparisons need to be made smarter than just between consecutive CurrentCost measurements – it needs to look beyond that to try and identify changes.

It’s currently based on the simplistic assumption that appliances have a roughly consistent power usage. The next step would be to try and identify curves in power usage graphs, rather than just measure initial power surges when you first start a device.

All in all, it’s a very simple first step… but it’s a start. There is a certain geeky fun in switching something on or off anywhere in your house, and having your phone beep and say “I noticed you switched something on” 🙂

Tags: , , , , ,

2 Responses to “CurrentCost hacking – starting to identify appliance power usage”

  1. Gareth Jones says:

    Nice work Dale, that sounds really interesting. Determining what devices are using power will be really useful when we crack it – this kind of user-interaction approach will probably be key! Definitely need some kind of time/habits approach too I reckon.

    For sending stuff to mobile, the Universal Inbox might be a good option as it has the MQTT layer built in with the ability to respond to messages.

  2. Matt Daniels says:

    This is interesting. It’s probably only a short step to look at some of the bigger power hoggers (leccy shower, kettle, oven etc.) and put a hint or suggestion in your command line (“Your power went up 2000W, what was it? (Kettle?)” even before you have some data to base the hint on. Also need to look out for combos like oven and kettle going on at the same time.

    Another idea – hook the bigger power hoggers into X10 controllers (where feasible) and be prompted to turn them off (“I noticed the tv has been on for 5 hours would you like me to turn it off Y/N”).

    What sort of tolerances have you built in, to signify a significant jump? My usage tends to hunt +/-30 Watts during “quiet” periods. Not sure if this is usual or not.

    Also as an aside, have you noticed a difference in the temperature readings from the Classic and the Envi? Side by side in the same room I’m seeing +4 degrees difference on the Classic.