Serial port for Kill A Watt - Tweet A Watt compatible
Moderators: adafruit_support_bill, adafruit

Serial port for Kill A Watt - Tweet A Watt compatible

by oPossum on Thu Jun 10, 2010 6:23 am

There have been some questions about how to directly connect a Kill A Watt to an Arduino or computer. It is unsafe to make a direct connection due to the ungrounded power supply used by the KAW. One solution is to use an optoisolator to provide a safe serial interface. The circuit is very simple...

Image

Built by soldering components to an 18 pin DIP socket...

Image

There is no need to modify the power supply of the KAW because average current draw is less than 1 milliamp. It sends one char per AC cycle to minimize drain on the power supply.

The protocol is the same as the Tweet A Watt so existing TAW software can be used.

I'll post more details this weekend when I have more time.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 635
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by adafruit on Thu Jun 10, 2010 9:52 am

oh hey that is super awesome! :)
User avatar
adafruit
 
Posts: 11711
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by richms on Sat Jun 12, 2010 1:41 pm

Awesome.

I love the socket as a circuitboard idea.

Have you considered having the calcs done in the pic and it just sending raw watts/amps/volts data out to the PC instead?
richms
 
Posts: 558
Joined: Tue Jan 20, 2009 3:05 am
Location: New Zealand

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by karishmasinghal on Thu Jun 17, 2010 3:57 am

This is a simple yet amazing idea! Great work! Simple option for those who do not need wireless option

would you be posting the code running on the PIC somewhere?
karishmasinghal
 
Posts: 1
Joined: Thu Jun 17, 2010 3:54 am

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by oPossum on Thu Jun 17, 2010 12:17 pm

richms wrote:Have you considered having the calcs done in the pic and it just sending raw watts/amps/volts data out to the PC instead?


Yes. The PIC will do sum of squares and sum of VA using integer math. The PC will do mean and square root with floating point math to get the RMS.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 635
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by oPossum on Thu Jun 17, 2010 12:19 pm

karishmasinghal wrote:Would you be posting the code running on the PIC somewhere?


Source code and more is here.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 635
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by minerva on Wed Jul 14, 2010 7:57 am

This is a really great idea - but I would suggest you carefully insulate the electronics, especially on the optically-isolated output side.
Otherwise, if you have the components just sitting there it might still be possible for something to short out (which is a Bad Thing), which would defeat all the effort you have gone to building the galvanically isolated interface.
minerva
 
Posts: 56
Joined: Sun Dec 06, 2009 11:12 pm

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by Volkemon on Sat Jul 31, 2010 12:19 pm

SWEEEEEEEEEEEEEEEET!!! Thanks oPossum!
Image

This is exactly what I have been looking for. I ruined my first KAW trying to solder directly to the chip, and I have been researching ever since before tearing open the next one. Lucky for me I have the same version you used.


I am wanting to interface this to an Arduino-based Datalogger, and wanted the wired link so I can run power with it also. I am going to use a smaller wallwart and cannibalize as necessary to have it piggyback on the unmetered side of the 110V AC.

The PC will do mean and square root with floating point math to get the RMS.


Is this referring to TrueRMS calculation? I am hoping to do that onboard the arduino and datalog the result. I am going to explore your information a little more and see what I can learn.
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by oPossum on Sat Jul 31, 2010 1:20 pm

Yes, true RMS.

RMS = square ROOT of the MEAN of the SQUAREs.

The current firmware for the PIC just sends voltage and current samples like the TAW. I haven't written firmware to do sum of squares yet.

The idea is to have the PIC rapidly sample the ADC and do sum of squares as each sample is taken. This can be done quickly with integer math. The resulting data will be small for any sampling duration, and can be quickly sent over the serial port. Whatever device receives the info can calculate the mean (divide sum [of squares] by sample count) and square root while the PIC is busy doing sum of squares on a bunch more samples.
Last edited by oPossum on Sat Jul 31, 2010 3:32 pm, edited 2 times in total.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 635
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by Volkemon on Sat Jul 31, 2010 1:40 pm

Alright! Thanks for the detailed info.

The idea is to have the PIC rapidly sample the ADC and do sum of squares as each sample is taken.


The sample referred to here is the voltage sample from the KAW, correct? Or does the current reading require manipulation also?

Sorry if these are NOOB questions, :oops: but I see I am missing some basic understanding. Thanks to all the help here, it is getting much clearer.

I see learning more about PIC controllers in my future :D
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by oPossum on Sat Jul 31, 2010 1:52 pm

Both, and more...

Sum of squares of voltage samples for RMS voltage.
Sum of squares of current samples for RMS current.
Sum of voltage sample * current sample for watts.

Once the mean and square of these values are calculated, then...

VA = RMS voltage * RMS current
Power Factor = watts / VA

So after all the math you get...

RMS Voltage
RMS Amperage
Watts
VA
Power Factor

Frequency could be measured, but that seems rather pointless.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 635
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by Volkemon on Sat Jul 31, 2010 10:18 pm

Image


I think I may finally understand. Thank you so much. So many things much clearer.

Squaring the reading 'eliminates' the negative readings that result during AC readings in both voltage and current.

Average out all the readings, take the square root of that and you have the RMS voltage/amperage.

RMS Voltage * RMS Current = Watts ( * {time} / 1000 to get kWH.. :!: )

Sample frequently to accurately trace irregular waveforms.



I have another KAW already open on the workbench, and it is the same model. I may go get a couple more from HD just to make sure I have the same style.

Already had the split core transformers for the 220V lines, and now maybe the knowledge to use them. The KAW is great for testing 110V banned, but I have 220V plans.



THANK YOU oPossum for taking the time to explain. ( And if I am miguided in any of my conclusions above, correction is accepted happily :D ) :mrgreen:
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by richms on Sun Aug 01, 2010 3:47 am

I was under the imporession that you only needed to RMS the voltage since that was the only one that had a square when calculating the wattage?
richms
 
Posts: 558
Joined: Tue Jan 20, 2009 3:05 am
Location: New Zealand

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by oPossum on Sun Aug 01, 2010 8:20 am

Volkemon wrote:RMS Voltage * RMS Current = Watts ( * {time} / 1000 to get kWH.. :!: )


No, that is VA.

Watts requires each sample of current and voltage to be multiplied.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
User avatar
oPossum
 
Posts: 635
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: Serial port for Kill A Watt - Tweet A Watt compatible

by Volkemon on Sun Aug 01, 2010 10:21 am

Yup. My error. You did state that pretty clearly before. I was just running, dizzy with the new knowledge.

I was up until 4am playing. Thanks Agian!
Livin' , learnin' , lovin' and laffin'. Thanks for the help!
Image
User avatar
Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm
Location: Melbourne FL USA