Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rgardner
 
Posts: 3
Joined: Sat Sep 27, 2014 4:23 pm

Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by rgardner »

Hi all!

I'm trying to calibrate my kill-a-watt like LadyAda did in her wattchery.py script. https://github.com/adafruit/Tweet-a-Wat ... attcher.py

The twist is that I'm using an XBee series 2 that is collecting one sample a second. I'm trying to normalize the current and watts using her techniques, but without the averaging ability. Here is my progress (in Python):

Code: Select all

CURRENT_NORM = 15.5
MAINS_VPP = 340
VREF_CALIBRATION = [492, 498, 489, 492, 501, 493]

self._voltage = self._raw_voltage - 512  # remove DC bias.
self._voltage = (self._raw_voltage * self._MAINS_VPP) / 512
self.current = (self._raw_current - self._VREF_CALIBRATION[3])
self.current /= self._CURRENT_NORM
self.current = abs(self.current)
self.watt = abs(self._voltage * self.current)
Any thoughts?
I'm getting the following data:

Code: Select all

sensor data: {'current': 22.70967741935484, 'watt': 4610.064516129032, 'sensor_id': 0}
sensor data: {'current': 31.741935483870968, 'watt': 5364.387096774193, 'sensor_id': 0}
sensor data: {'current': 21.483870967741936, 'watt': 1031.225806451613, 'sensor_id': 0}
sensor data: {'current': 6.129032258064516, 'watt': 98.06451612903226, 'sensor_id': 0}
sensor data: {'current': 1.7419354838709677, 'watt': 0.0, 'sensor_id': 0}
sensor data: {'current': 0.7741935483870968, 'watt': 50.32258064516129, 'sensor_id': 0}
sensor data: {'current': 2.129032258064516, 'watt': 557.8064516129032, 'sensor_id': 0}
sensor data: {'current': 8.64516129032258, 'watt': 3458.064516129032, 'sensor_id': 0}
sensor data: {'current': 16.967741935483872, 'watt': 7635.483870967742, 'sensor_id': 0}
sensor data: {'current': 16.129032258064516, 'watt': 7129.032258064516, 'sensor_id': 0}
sensor data: {'current': 10.580645161290322, 'watt': 3872.516129032258, 'sensor_id': 0}
Do I need to analyze more samples at a time? Any thoughts on improving this?

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by adafruit_support_bill »

The twist is that I'm using an XBee series 2 that is collecting one sample a second.
If you are sampling a 60Hz signal only once per second, you are not going to get meaningful data.

User avatar
rgardner
 
Posts: 3
Joined: Sat Sep 27, 2014 4:23 pm

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by rgardner »

Hello, I've changed the IR setting to 0x32 * 1ms (=50ms) on the XBee Series 2. I couldn't find TX IT setting in the xctung XBee configuration application, so I don't know how to increase the samples per packet. Instead, I've implemented logic so that 20 packets are collected, mimicking the ~20 samples per packet Lady Ada was collecting. Her logic is here: https://github.com/adafruit/Tweet-a-Wat ... er.py#L114

My logic is here: https://github.com/project-nikola/autom ... ing.py#L58

Here is some of the sample data I'm getting:

Code: Select all

sensor_reading: {'analog_samples': [[1023, 1023], [462, 1023], [1023, 890], [634, 1023], [1023, 902], [1023, 1023], [852, 1023], [1023, 1023], [466, 1023], [1023, 851], [831, 1023], [1023, 955], [1023, 1023], [722, 1023], [1023, 1016], [658, 1023], [1023, 872], [1021, 1023], [1023, 1020], [1023, 1023]], 'avgwatt': 19090.239089184062, 'avgamp': 35.80265654648957}

sensor_reading: {'analog_samples': [[579, 1023], [1023, 1023], [615, 1023], [1023, 877], [1023, 1023], [603, 1023], [1023, 1023], [471, 1023], [1023, 858], [1022, 1023], [1023, 1013], [1023, 1023], [633, 1023], [1023, 1023], [547, 1023], [1023, 864], [1023, 1023], [770, 1023], [1023, 1023], [467, 1023]], 'avgwatt': 19027.388994307403, 'avgamp': 36.46679316888045}

sensor_reading: {'analog_samples': [[1023, 881], [743, 1023], [1023, 908], [1023, 1023], [1023, 1023], [1023, 1023], [696, 1023], [1023, 1023], [467, 1023], [1023, 917], [608, 1023], [1023, 947], [1023, 1023], [930, 1023], [1023, 1023], [466, 1023], [1023, 856], [1023, 1023], [899, 1023], [1023, 1023]], 'avgwatt': 19899.370018975336, 'avgamp': 36.52751423149905}

sensor_reading: {'analog_samples': [[488, 1023], [1023, 858], [1023, 1023], [785, 1023], [1023, 1023], [626, 1023], [1023, 873], [998, 1023], [1023, 1013], [1023, 1023], [597, 1023], [1023, 952], [780, 1023], [1023, 936], [1023, 1023], [630, 1023], [1023, 1023], [544, 1023], [1023, 847], [1023, 1023]], 'avgwatt': 22829.965844402283, 'avgamp': 35.78747628083491}

sensor_reading: {'analog_samples': [[999, 1023], [1023, 1023], [526, 1023], [1023, 970], [692, 1023], [1023, 896], [1023, 1023], [903, 1023], [1023, 1023], [508, 1023], [1023, 865], [861, 1023], [1023, 943], [1023, 1023], [550, 1023], [1023, 1023], [500, 1023], [1023, 844], [1023, 1023], [910, 1023]], 'avgwatt': 20366.106261859582, 'avgamp': 36.022770398481974}

sensor_reading: {'analog_samples': [[1023, 1023], [469, 1023], [1023, 956], [594, 1023], [1023, 871], [1023, 1023], [952, 1023], [1023, 1023], [592, 1023], [1023, 967], [568, 1023], [1023, 929], [1023, 1023], [631, 1023], [1023, 963], [745, 1023], [1023, 1019], [1023, 1023], [614, 1023], [1023, 1023]], 'avgwatt': 19248.43263757116, 'avgamp': 36.64516129032258}

sensor_reading: {'analog_samples': [[468, 1023], [1023, 859], [960, 1023], [1023, 1005], [1023, 1023], [667, 1023], [1023, 1023], [467, 1023], [1023, 893], [651, 1023], [1023, 885], [1023, 1023], [707, 1023], [1023, 1023], [454, 1023], [1023, 910], [590, 1023], [1023, 862], [1023, 1023], [900, 1017]], 'avgwatt': 18341.878557874763, 'avgamp': 35.51802656546489}

sensor_reading: {'analog_samples': [[1023, 1023], [482, 1023], [1023, 943], [796, 1023], [1023, 1009], [1023, 1023], [775, 1023], [1023, 1023], [457, 1023], [1023, 864], [943, 1023], [1023, 979], [1023, 1023], [832, 1023], [1023, 1023], [464, 1023], [1023, 877], [1023, 1023], [831, 1023], [1023, 1023]], 'avgwatt': 19325.085388994303, 'avgamp': 36.60721062618595}

sensor_reading: {'analog_samples': [[456, 1023], [1023, 865], [865, 1023], [995, 1023], [1023, 1023], [685, 1023], [1023, 970], [574, 1023], [1023, 986], [1023, 1023], [715, 1023], [1023, 1023], [460, 1023], [1023, 916], [816, 1023], [1023, 965], [1023, 1023], [785, 1023], [1023, 1023], [607, 1023]], 'avgwatt': 19368.12144212524, 'avgamp': 36.72106261859582}

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by adafruit_support_bill »

I've changed the IR setting to 0x32 * 1ms (=50ms)
The period of a 60Hz sine wave is 16.67ms. The original code is designed to take 17 samples at 1ms intervals to capture a full cycle. http://www.ladyada.net/make/tweetawatt/software.html

At 50 Hz, you will be sampling some part of every third cycle.

User avatar
rgardner
 
Posts: 3
Joined: Sat Sep 27, 2014 4:23 pm

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by rgardner »

Thank you for all your help. The XBee Series 2 does not sample fast enough to obtain meaningful data. Collecting a single sample from every third curve doesn't seem very helpful.

Because we still want to use an XBee Series 2 mesh network, my tentative plan is to use an Arduino to collect the samples at that 1KHz sampling rate. I can then do the normalization on the Arduino, and send the calibrated data through the XBee Series 2 to the coordinator.

On this page, http://www.ladyada.net/make/tweetawatt/receiver.html, Lady Ada states that "This project most likely won't work with any other version of the XBee, and certainly not any of the 'high power' Pro types!" Maybe put a note like: "other XBee models, like the XBee Series 2, do not sample fast enough for this application. If you want to use other XBee models, check that the sampling rate >= 1KHz"

Thanks again for all of your help.

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by adafruit_support_bill »

Thanks for the feedback. You might look at something like the Trinket for doing the raw data collection. One problem you may have is scavenging enough power from the Kill-A-Watt for the additional circuitry. Recent models have downsized the power supplies to just barely enough to power the Kill-A-Watt itself.

https://www.adafruit.com/search?q=trinket&b=1

User avatar
Deadboy
 
Posts: 29
Joined: Tue Sep 30, 2014 5:57 pm

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by Deadboy »

That is a really interesting idea. Is it really that straightforward to connect a micro-controller to the Kill-A-Watt?

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by adafruit_support_bill »

It does require some reverse engineering - as well as care since you are working with mains voltage. And, as noted in my previous post, there is not a lot of power to spare for additional circuitry. A small processor such as the Trinket would be the best bet.

User avatar
Deadboy
 
Posts: 29
Joined: Tue Sep 30, 2014 5:57 pm

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by Deadboy »

I've been researching this some more and came upon a sparse writeup on how to hookup a serial cable to the KAW. It looks fairly straightforward. But, I noticed they use different solder points on the circuit board. Is it just because the KAW they were working with was from an earlier revision?

http://www.compendiumarcana.com/kaw/index.html

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Tweet-A-Watt + XBee Series 2: Kill-A-Watt Calibration

Post by adafruit_support_bill »

I noticed they use different solder points on the circuit board. Is it just because the KAW they were working with was from an earlier revision?
That is entirely possible. If you search these forums, there was a similar opto-isolated serial hack documented. But Kill-A-Watt circuitry is subject to change beyond our control.

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

Return to “XBee products (discontinued)”