CC128 + RPi3

Energy monitoring with a Current Cost 128 is a bit boring, plus their software/web based thing is pants.

Danny Tsang wrote the energy@home solution a while ago – python script to parse the XML from the CC128 via serial console and feed MySQL, then PHP + flot on apache2 to make the pretty.

That all worked well in the past, but unfortunately, it broke with MySQL 5.7 (and yes, I did try changing every instance of  ‘mysql_xxx’ to ‘mysqli_xxx’, but nothing’s ever that simple).

The python/datalogger side still worked fine for dealing with the XML and stuffing the database, so I boshed some crude php together (and learned a lot about MySQL5/flot/js in the process), threw in a date/timepicker and here we go:


I use a separate php page for each channel and session variables to send the date/time info back for each query.  It needs some tidying up (thinning out the data, for a start), but has proved pretty stable so far.

I ditched the CC USB (PL3032?) serial adapter and went straight from the RJ45 on the display unit to the serial GPIO pins on the Raspberry Pi 3 (well, I needed the USB adapter for torturing BT Home Hub 5As, but that’s another story).

Here’s the php: (you’ll need to change themysqli_connect’ password “x” to your own). The rest (python datalogger) can be found on Danny’s Github link above.

The third dataset (channel) is not used as I have only two sensors feeding it for now, but the empty channel is used (always ‘displayed’) so as to give the second x-axis (time) something to go on – I couldn’t figure out how to give a dataset more than one x-axis scale (i.e. day/date on top and time of day on bottom), so I just use the time stamps (from dataset3) with zero data.

This is because (like most things) I’m just too damn lazy to do it properly. 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *