Skip to content
Oct 1 12

Home Power Monitor

by Riscy

I’ve wanted to do a home power monitoring project for some time. I was using a Clipsal Cent-a-meter a while ago to track power usage when I lived in Victoria but I didn’t have much luck with the newer model. It didn’t have a good range and seemed to lose connection between the base and sending unit. So I thought I would go DIY.

I looked at lots of different systems including PIC microcontrollers but I decided to give the JeeNode and JeeLink combination a try. It seemed like a good choice for the following reasons:

  • Arduino compatible
  • Low power (3.3V)
  • Integrated wireless
  • Easy interfacing with a PC (JeeLink)
  • Expandable

In our house we have a smart meter which has a blinking red light for every Watt Hour of power used. So by measuring the length of the pulse you can have an indication of instantaneous power usage. This saves using clip on CTs which need to be installed by an electrician. The other advantage of using the smart meter is that this is the actual power usage I am being charged for. The only problem with this is that in Tasmania we have two different tariffs, one for normal usage and one for heating (cheaper). My system doesn’t take into account the tariffs and can only measure total usage. It also could not be used with electricity generation because the smart meter only blinks for imported power, if you are generating then the actual power usage will be higher than the imported.

So I went to Modern Device and ordered the following:

The JeeNode will be used to monitor the blinking light, which will send data to the JeeLink (plugged into my HTPC running Ubuntu) and the USB BUB II is required for programming the JeeNode.

I soldered the JeeNode and JeeLink up when they arrived on the coffee table while watching something mindless on TV. It had been a while since I had done proper soldering and with a good temperature controlled iron it was pretty easy. I should get some good quality solder though!

I tested the JeeNode and JeeLink and they worked first time. Now to look for some code.

I ended up using this code I modified it to suit the 1Wh blinks and using a LDR.

Here is my version of the transmitter code:

// Reading Comparator input

#include "kWh.h"

class Port;
Port inputPort(1);
static unsigned long last;

void setup() {
    inputPort.mode2(INPUT); // Set AIO mode as input
    inputPort.digiWrite2(1); // Activate pull-up resistor for AIO
    rf12_config(); // Apparently this is necessary
    rf12_easyInit(3); // Send value at most every 3 seconds
    last = millis();

void loop () {
    static boolean ledOn = false; // Variable to indicate LED status
    int data = inputPort.anaRead();
    if (!ledOn && data > 750) {        // After testing I found the switching point was 750
        ledOn = true;
    } else if (ledOn && data < 750) {
        ledOn = false;

void ledBlink() {
    static int nBlinks = 0;
    unsigned long time = millis();
    unsigned long interval = time - last;

    if (interval < 0) { // millis() overflow
        last = time;
        nBlinks = 0;
    } else if (interval > 1000) { // 1+ sec passed
        // Blinks are 1000 per kWh, or 1 Wh each
        // One hour has 3.6M milliseconds
        long watts = nBlinks * 1 * 3.6E6 / interval;

        last = time;
        nBlinks = 0;

static void wattSend(long watts) {
    Packet_t packet;
    packet.lang = LANG_ELECTRICITY;
    packet.mesg = MESG_ELEC_CURRENT; = watts;
    rf12_easySend(&packet, sizeof packet);

And here is my version of the JeeLink receiver code

#include "kWh.h"

void setup() {

void loop() {
    if (rf12_recvDone() && rf12_crc == 0 && rf12_len == sizeof (Packet_t)) {
        Packet_t packet = *(Packet_t *) rf12_data;

        if (packet.lang == LANG_ELECTRICITY) {
            if (packet.mesg == MESG_ELEC_CURRENT) {
    else {

static void wattShow(long watts) {
    Serial.print("Usage: ");
    Serial.println(" W");

I connected 4 AA NiMh batteries as the power supply to the JeeNode and sat it on top of the smart meter. The LDR is connected between the AI pin and ground of one of the ports.

Pretty isn’t it?

The LDR is right next to the LED

The JeeLink is connected to my PC running Mythbuntu, which is my HTPC.

Ubuntu is running Perl code to read the serial port and dump it to a file which timestamps the incoming data.

use strict;
use warnings;
use Device::SerialPort;
use POSIX qw/strftime/;

my $port = Device::SerialPort->new('/dev/ttyUSB0');
my $time = time;

if( ! defined($port) ) {
        die("Can't open /dev/ttyUSB0 $^E\n");

my $outfd;
open ($outfd, ">>", "log.txt") or die "Failed to open output file - $!n";

my $output = select(STDOUT);
select $output;


while(1) {
    my $char = $port->lookfor();
    if ($char) {
        $char =~ s/\xd//g;
        my ($watts)= $char =~ /(\d+) W/;
        print strftime('%d-%m-%Y %H:%M:%S',localtime);
        print ",$watts\n";
        print $outfd strftime('%d-%b-%Y %H:%M:%S',localtime);
        print $outfd ",$watts\n";

It works and the next step is to make a nice graphing utility. I’ll post again when I have some pretty graphs. At the moment I’m just dumping all the data into Excel.

Jul 2 12

The problem with Telstra

by Riscy

I’ve decided to start using my blog more and impart some of my common and uncommon wisdom to the rest of the internet.

I’ve had what Australians call “broadband” since 2002 initially with Telstra, then Swiftel (which became Peoples Telecom) and then Internode. I was an early adopter and got the self installation kit from Telstra which included the Alcatel Speed Touch Pro.

Image from

Telstra provided a good quality of service, technically they have very knowledgeable people working there. Getting access to those people is difficult. I stuck with Telstra until my contract was up and then switched. Churning was easy and didn’t cause many headaches. At that stage I was the only one in the house who really used the internet on a regular basis. I was a regular player of online games (DoD, CS, Battlefield) and Gamearena was a great place to play games and compete in a professionally run ladder. People complained about refs and admins but they all did a great job and looking back, I think I took it for granted. I loved playing in ladder matches, playing on pub servers and generally mucking around online.

The problems with Telstra were entirely value for money related. The reasons I switched were:

  • Upload data usage was counted
  • Poor data usage tools
  • High excess data usage costs
  • Minimal extras provided

I knew I would miss the quota free downloads from Gamearena but Swiftel looked like they were catering for the enthusiast crowd. They allowed quota free downloads and uploads between peers and a reasonable amount of content hosted on their servers.

I was still involved with Telstra, but indirectly. The DSLAM in Traralgon was a Telstra DSLAM and any ISP I went with was still paying Telstra for access to my phone cables. I still had a Telstra home phone and if there were problems with the phone line it was Telstra’s problem. I don’t recall having many issues but sometimes I would need to disconnect the modem for 30 minutes to reset the line and then reconnect. Calling the helpdesk of ISPs usually required me to do this first so I got quite good at pretending I was doing it over the phone while they waited. I always tried fixing the problem myself first before calling.

The other interesting thing Swiftel offered was a VoIP trial. I got a free VoIP phone and some calling credit to try out the system. It worked but I didn’t use it much, in fact I don’t really using it at all. I kept the phone for years and ended up using it with Internode’s NodePhone but then ditched it when I got a new modem with integrated VoIP.

Image from

The next time had to deal with Telstra was when I moved to Nhulunbuy in the Northern Territory. Before I moved I checked that Telstra had sufficient DSLAM ports available at their exchange. I can’t remember the exact number but I think it was over 50, so I thought I was safe. I had been told by residents that there were problems getting ADSL connected but after checking I thought I was OK. I was wrong……

I tried to connect by transferring my Internode account from Traralgon to Nhulunbuy. I got the phone on and got the details to Internode. The request was rejected saying that there were no ports available. I said to Internode that this wasn’t true and directed them to the Telstra Wholesale site which indicated there were ports available. So it tried again, I was rejected again saying no ports were available. So I decided to try and connect using Telstra, their Liberty 25GB plan on 1500/256 sounded like a good option. No ports. I rang and e-mailed Telstra repeatedly but I was unable to get connected via ADSL. Instead they kept offering 3G connections, which were more expensive with potentially lower speeds and less download/upload allowances.

Finally I had managed to find out what was going on. I have no concrete evidence of this but I have seen the pattern elsewhere and believe this is what is happening. Telstra was using a microwave link to the rest of Australia to Gove (Nhulunbuy), this link has limited bandwidth and previously had been sized to support normal phones, and data used by Alcan (the alumina refinery I was working at). Then ADSL came along, they had to upgrade the system a bit and sized the exchange for a reasonable population. Then mobile phones became popular and started needing more bandwidth (including data) the backhaul bandwidth is limited so it needed to be reallocated. This is understandable but Telstra also has another motive.

ADSL pricing is regulared by the ACCC and Telstra needs to provide access to DSLAM ports and backhaul for other ISPs. 3G bandwidth is not regulated this way because there is more competition in the mobile phone market. However the issue is backhaul capability and Telstra controls this in rural areas. 3G data bandwidth is worth more $ than ADSL $ because there is less competition. So Telstra are encouraged to maximise 3G bandwidth and minimise ADSL bandwidth so they are exposed to less competition.

Telstra were initially very keen to sign up people to their own ADSL plans but rejecting 3rd party ISP requests. Once the word was out that people could do this Telstra tightened up. Instead their best option was to push people into 3G broadband which isn’t open to competition and was more lucrative anyway. I already had a Telstra mobile phone which I bought datapacks for which ended up being a similar price to a 3G broadband solution. Eventually I caved in and went with their 3G broadband plan. I wrote letters to Sol Trujillo, Steven Conroy, the ACCC and the local member of parliment. I did get call backs which basically confirmed that Telstra manipulated the market to maximise their profit. When the ACCC called they basically expected me to have access to this information as fact before I could act. How was I able to obtain that information? Impossible, unless I was a Telstra employee.

I know this same situation is happening in other rural towns around Australia. If the backhaul is close to limits, Telstra artificially manipulates the bandwidth allocation to prefer their 3G network to ensure they have an increased ability to maximise profit. For example Bridport in Tasmania has a backhaul limitation and people are encouraged to move over to 3G because their ADSL connection is slow. Clever.

I moved back to Tasmania and I was extremely happy to move to an Agile DSLAM in New Town. ADSL2+ with Internode was a dream, I had high speeds, reliable connection times and I bought an upgraded ADSL modem/router with built in VoIP (more on that latter). This was a rental property, and we stayed there for about 2 years then bought a house. I was still on the New Town exchange but for some reason I couldn’t transfer my existing service over to the new house.

Apparently local loop unbundling rules mean that ports don’t transfer, they go back into the pool. Unfortunately there were no unbundled pairs left for Internode so I had to go on a waiting list. So I could have the phone on at the new house from day 1 I had to get connected to a Telstra DSLAM port and pay Internode the higher price because of that. Then wait about 4 weeks for a port to be made available (probably the one I just disconnected from) and then connect via the Agile DSLAM. Ridiculous.

The disaster of privatising Telstra is huge. They are only interested in profit so long term infrastructure decisions are not made and instead equipment is just “patched up” to make it work. The ACCC needs to force them to open up access to the infrastructure they inherited, Telstra didn’t put much in place the copper has been an existing asset pre-privatisation. The sooner the NBN gets here the better, a monopoly is best managed by an entity that doesn’t have profit as the major motivation.

With any luck I should be on the NBN within 12 months, I don’t even thing the Liberals will be able to stop that. Once I do have the NBN I might actually be able to get real broadband which in Europe is defined by >30Mbps