Saturday, March 16, 2013

JeeNode Kill-A-Watt - Part 1

I'll bet your thinking: great, just what the world needs, another Kill-A-Watt hack!?  Well, I've spent more hours than I'd care to admit working on this, and I've come up with a number of hardware and software improvements that I think will make this worth your while:
  • Uses a JeeNode with RFM12B radio for low cost
  • Uses both Kill-A-Watt current ranges for best accuracy
  • Improved power supply and reset circuit for reliable operation
  • Measures and transmits true AC RMS Voltage and Current 

JeeNode Kill-A-Watt being programmed

I'd like to acknowledge the work of others before me, because they helped me, and so I can refer you to them and keep my posts shorter.  By all accounts, Ladyada had the first published Kill-A-Watt hack, aptly named the Tweet-A-Watt My only issue with her design is that I'm cheap, so Xbee modules aren't for me. 

I plan to deploy lots of different kinds of data collecting nodes, and a Raspberry Pi central receiver and web server.  And so for me, the RFM12B modules are ideal, either as an add on to Arduino (or Pi), or as part of the excellent JeeNodes.  I use the 433 MHz version here in the US, and they have excellent range, easily covering all rooms on both floors and attic in my house.  I may even deploy some outside.

The Tweet-A-Watt created quite a buzz, and there are lots of forum posts about it, and alternative approaches.  Some are very dangerous, bringing electrical signals out of the Kill-A-Watt to be connected to an Arduino, or a computer or whatever.  I need to be very clear about this: DON'T DO IT!  The Kill-A-Watt has about 340 Volts peak to peak inside.  The plastic case is there to save your life. 

The only safe way to hack a Kill-A-Watt is to have a completely self-contained radio transmitter.  Note, I've seen designs (that I won't link to) that use an opto-isolator to provide a serial link, but I wouldn't even trust that, it's still wires that connect the inside of the Kill-A-Watt to the outside.  And besides, that design leaves all the math to be done by the receiver.

And bear with me please just a moment longer, lest you be fooled into thinking it's safe if you know what you're doing.  Just because the circuit board "ground" inside the Kill-A-Watt is connected to AC Neutral, does NOT make it safe.  For one thing, the Kill-A-Watt can be plugged into an extension cord or miswired outlet, such that Neutral and Hot are swapped.  And even if Hot and Neutral aren't swapped, Neutral itself can easily, and typically, be a few volts away from earth ground, with plenty of Amps to back it up.  So as soon as you plug in your Arduino to a dangerously hacked Kill-A-Watt and to the USB on your computer, there's an excellent chance you'll see smoke and fire.  Don't do it.

Beyond Ladyada's inspiration, the most helpful info I found was an excellent Kill-A-Watt schematic.  By studying this schematic and carefully experimenting with the Kill-A-Watt, I figured out that the Kill-A-Watt has two current ranges.  Ladyada's design, and all others I've seen, only use the coarse current range, on pin 1 of the quad op-amp.  But when the load current is less than about 1 Amp RMS, that output has more noise than signal.  That's why there's a another (filtered) amplifier stage.  Pin 8 provides good clean current readings, from milliamps to about 2A, where it saturates.  So my design, like the Kill-A-Watt itself, chooses the appropriate current range depending on the load.

(Note, by "carefully experimented," I mean that I used an isolation transformer between the Kill-A-Watt and the AC mains.  And I used a high voltage differential scope probe to connect to the Kill-A-Watt.  I always powered down before connecting or moving probes or loads.  And I applied power from a safe distance using a switched power strip, just in case there was an accidental short.)

Well, that's it for the overview and safety warnings.

Part 2 will be a lot more interesting, I promise.  I'll present my hardware design, with pictures and schematics.

In part 3, I'll bring it all together by covering the software, low power mode, measurement math, calibration, transmission, receiver.  Actually that might be more like parts 3 and 4.  We'll see.

Oh yeah, just about the time I was finishing up this project, I came across a very interesting site, LowPowerLab and this fellow has a very nice "Moteino," rather like a shrunken JeeNode.  In fact, if I'd found his site a month ago, I've have used the Moteino instead, because it's smaller and easier to fit inside.  And sure enough, he's got his own Kill-A-Watt hack called the WattMote.  I do plan to get some Moteinos and review them...

And I'm beginning to think the main market for the Kill-A-Watt is the maker-hacker community!