Current Cost Classic vs CC128

Back in November I bought (well, actually I signed up to a new deal with E.ON which included one) a Current Cost electricity monitor, and hooked it up to my server so I could gather the stats for Cacti. I do this by running a small perl script which looks as follows:

#!/usr/bin/perl
# /usr/local/bin/cc-classic.pl
 
use Device::SerialPort qw( :PARAM :STAT 0.07 );
 
$port = "/dev/currentcost";
 
$ob = Device::SerialPort->new($port)
      or die "Can not open port $port\n";
$ob->baudrate(9600);
$ob->write_settings;
$ob->close;
 
open(SERIAL, "+>$port");
while ($line = <SERIAL>)
{
  if ($line =~ m!<ch1><watts>0*(\d+)</watts></ch1>.*<tmpr>\s*(-*[\d.]+)</tmpr>!)
  {
     $watts = $1;
     $temperature = $2;
     print "watts:$watts temp:$temperature";
     last;
  }
}
close(SERIAL);

This would give me the two values I am interested in; watts and temperature (since it sits in the garage node 0 ;)) in Cacti’s format:

$ /usr/local/bin/cc-classic.pl
watts:761 temp:11.3

But today, I received my new unit, a Current Cost CC128. It’s main benefit is that it supports individual appliance monitors, which makes the output even more useful. So, armed with a draft copy of the CC128 XML output document, I prepared my script to read as follows:

#!/usr/bin/perl
# /usr/local/bin/cc-cc128.pl
 
use Device::SerialPort qw( :PARAM :STAT 0.07 );
 
$port = "/dev/currentcost";
 
$ob = Device::SerialPort->new($port)
      or die "Can not open port $port\n";
$ob->baudrate(57600);
$ob->write_settings;
$ob->close;
 
open(SERIAL, "+>$port");
while ($line = <SERIAL>)
{
  if ($line =~ m!<tmpr>\s*(-*[\d.]+)</tmpr>.*<ch1><watts>0*(\d+)</watts></ch1>!)
  {
     $watts = $2;
     $temperature = $1;
     print "watts:$watts temp:$temperature";
     last;
  }
}
close(SERIAL);

And guess what… that works just fine ;)

For those who read diff:

$ diff /usr/local/bin/cc-classic.pl /usr/local/bin/cc-cc128.pl 
2c2
< # /usr/local/bin/cc-classic.pl
---
> # /usr/local/bin/cc-cc128.pl
10c10
< $ob->baudrate(9600);
---
> $ob->baudrate(57600);
17c17
<   if ($line =~ m!<ch1><watts>0*(\d+)</watts></ch1>.*<tmpr>\s*(-*[\d.]+)</tmpr>!)
---
>   if ($line =~ m!<tmpr>\s*(-*[\d.]+)</tmpr>.*<ch1><watts>0*(\d+)</watts></ch1>!)
19,20c19,20
<      $watts = $1;
<      $temperature = $2;
---
>      $watts = $2;
>      $temperature = $1;

Please note, the above only works with 1 sensor (the main transmitter), so it is likely to change in the future. For now it suits my need.

Modding the Dell Mini 9 – Part 2

I wasn’t planning on revisiting my Mini mods yet, but when someone offered (and I happened to be looking) an upgrade to a 32GB RunCore SSD, I could not pass on the occasion. The only problem was that it rendered my SSD activity light useless as the RunCore does not carry the same signal on the pin that the STEC drive uses.

Thankfully all the hard work figuring out where the negative side of the SSD light had to connect to was done once more by UnaClocker on the MyDellMini forums, so all I had to do was find a quiet Saturday and warm up the soldering iron.

We begin by undoing the work we did on the STEC. Heat up the pin on the SSD and remove the black wire. We will need to connect that to the RunCore drive.

As said, UnaClocker found out that the signal we need is present on a small resistor, which although tiny, isn’t the worst place in the world to solder on. Just fold back the sticker to reveal it. If you enlarge the 2nd picture, you will see which one it is. Use the tiniest amount of solder and attach the black wire to the resistor.

Fold back the sticker, put the SSD back into it’s slot and boot it up. Blue LED goodness once again!