Serial port for Kill A Watt - Tweet A Watt compatible

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

Serial port for Kill A Watt - Tweet A Watt compatible

Post by opossum »

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.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

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

Post by adafruit »

oh hey that is super awesome! :)

User avatar
richms
 
Posts: 558
Joined: Tue Jan 20, 2009 3:05 am

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

Post by richms »

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?

karishmasinghal
 
Posts: 1
Joined: Thu Jun 17, 2010 3:54 am

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

Post by karishmasinghal »

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?

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

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

Post by opossum »

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.

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

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

Post by opossum »

karishmasinghal wrote:Would you be posting the code running on the PIC somewhere?
Source code and more is here.

minerva
 
Posts: 58
Joined: Sun Dec 06, 2009 11:12 pm

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

Post by minerva »

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.

Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm

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

Post by Volkemon »

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.

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

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

Post by opossum »

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.

Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm

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

Post by Volkemon »

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

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

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

Post by opossum »

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.

Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm

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

Post by Volkemon »

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 appliances, 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:

User avatar
richms
 
Posts: 558
Joined: Tue Jan 20, 2009 3:05 am

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

Post by richms »

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?

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

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

Post by opossum »

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.

Volkemon
 
Posts: 127
Joined: Mon May 10, 2010 8:24 pm

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

Post by Volkemon »

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!

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”