Author Topic: Wattage monitoring - I've no flipping idea what I'm doing, help!  (Read 515 times)

0 Members and 1 Guest are viewing this topic.

Offline rthorntnTopic starter

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: au
Wattage monitoring - I've no flipping idea what I'm doing, help!
« on: February 29, 2024, 01:17:59 am »
Hi,

I have power data (Shelly 3EM with CT clamps), it gives me a power "value" (watts) from the sensor at least once every 15 seconds, it basically sends updates faster if it decides the "value" has changed enough.

I can see the same power data from other sensors (power company and inverter) and I can see that my my influxdb derived values are 10-30% off over 24 hours, I think the culprit is adding an hours worth of values together and then dividing it by the number of values  ("mean" aggregate data in 1 hour chunks)  is the right way for power data?

The results are pretty close if I "mean" aggregate data in 15 second chunks.

This is what I'm looking for, a time series with data points like this:

14:00-15:00 - 6524w
15:00-16:00 - 5987w
16:00-17:00 - 4876w

With this data set, what is the math to get me to the actual power used in an hour?

Thanks.

Richard
« Last Edit: February 29, 2024, 01:19:30 am by rthorntn »
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2086
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #1 on: February 29, 2024, 01:55:34 am »
You only mention watts. Is this the only measurement or are some of your instruments also sensitive to, or  registering reactive power ?
 
The following users thanked this post: rthorntn

Offline rthorntnTopic starter

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: au
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #2 on: February 29, 2024, 02:14:26 am »
Thanks, apologies, I don't know much about power, especially AC, do you mean the power factor?

The Shelly web UI gives me:

Voltage - 226.9 V
Current - 13.678 A
Active power - 3.09 kW
Apparent power - 3102 VA
Power factor - 1
Frequency - 50 Hz

Energy last minute

Active - 51.764 Wh
Active returned - 0 mW

MQTT gives me most of that but not the last minute, it gives me total instead:

total_act_energy - 134882.85
total_act_ret_ energy - 283273.12

I'm storing Active Power in a database and querying it to try to make hourly usage totals.

Cheers
Richard
« Last Edit: February 29, 2024, 02:36:25 am by rthorntn »
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 11900
  • Country: us
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #3 on: February 29, 2024, 02:45:31 am »
I can see the same power data from other sensors (power company and inverter) and I can see that my my influxdb derived values are 10-30% off over 24 hours, I think the culprit is adding an hours worth of values together and then dividing it by the number of values  ("mean" aggregate data in 1 hour chunks)  is the right way for power data?
Not only power, but for any consumption data, really.

Quote
With this data set, what is the math to get me to the actual power used in an hour?

Let's suppose you have a data set as a list of pairs: Time stamp, Power recorded at this instant

Let the list be like this:

T1, P1
T2, P2
T3, P3
T4, P4
etc.

T is time in hours and fractional hours, P is power in kW at time T.

Then what you do is take successive pairs, and accumulate a total pair by pair. For example:

Total = 0
Total = Total + 0.5 * (P2 + P1) * (T2 - T1)
Total = Total + 0.5 * (P3 + P2) * (T3 - T2)
Total = Total + 0.5 * (P4 + P3) * (T4 - T3)
etc.

You can probably set this up in a spreadsheet.

What this is doing is taking the average power over each interval and multiplying it by the length of the interval, to give the power consumption in kWh for that interval.

If you accumulate this total over the span of an hour, you will have the total consumption over that hour in kWh, which coincidentally will be the average power consumption for that one hour period.

Do this computation hour by hour, and you will have the summary you are looking for.
 
The following users thanked this post: rthorntn

Offline rthorntnTopic starter

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: au
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #4 on: February 29, 2024, 02:56:01 am »
Thanks, would it be smarter to store:

total_act_energy - 134882.85

Every minute and then subtract the new value from the previous value?

14:00 total_act_energy - 134882
14:01 total_act_energy - 134889 (7w)
14:02 total_act_energy - 134898 (9w)
14:03 total_act_energy - 134905 (7w)
14:04 total_act_energy - 134915 (10w)
14:05 total_act_energy - 134965 (50w)

So the power used in 5 minutes was 83w?
« Last Edit: February 29, 2024, 03:12:44 am by rthorntn »
 

Offline donlisms

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: us
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #5 on: February 29, 2024, 03:35:20 am »
I think it depends on how you're managing the data and how you're producing the results.  You talk a little about hourly usage, as well as per-minute usage; I'm guessing you really want minutes. Sometimes.  Maybe.

From a software perspective, I think I'd just capture the raw data in one form or another, which may very well be just the total, at the chosen resolution (every minute or every hour).  Time/total pairs, using IanB's averaging technique. My preference would be to do the average or difference as part of the reporting; let's say I ask for the power overnight 12 hours, pick two data points, subtract the totals, and there you go. Or ask for hour summaries, but then split out an interesting hour into minutes. 

On the other hand, if there's no chance to do any computing "later", then something similar to what you described could be done "up front" at the chosen interval.  You might see how that kinda locks you in to the interval, because you get one chance to do the subtraction, but maybe that's okay, I don't know!
 
The following users thanked this post: rthorntn

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3442
  • Country: us
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #6 on: February 29, 2024, 03:38:44 am »
After scanning the "User and Safety guide" for the Shelly 3EM[1], what you may be seeing is (in their words), momentary.  Per the user guide, the display of Watt Usage is the Watt being used at that moment.  In the app shown in the user guide, they did not sum or average it for you.  From what you wrote, I think you already got that.  They didn't sum or aggregate data form you.  You have to get the data frequently and sum it yourself.

If my interpretation of the user guide is right that the data reported is "momentary" data, this is the scenario:

Think of it this way, if you have a 100 watt light bulb and that is the only thing being monitored.  At the start of 1am, it was off, it turned on at 1:30am.  At 2:00 am, the data is read.

So at 2:00am it shows 100W, you don't know that it was not ON between 1:00am to 1:30amSince it read 100 Watts and if you assumed 100Watt-Hour used, you would be exactly 100% off.  You used only 50 Watt-Hour.

If my interpretation is indeed correct, you should probably read the data more frequent and sum it yourself.  Say if you read it 1 second interval:
1:00:00am = 0
1:00:01am = 0
1:00:02am = 0
...
1:29:59am = 0
1:30:00am = 100W (this second) = 100/3600 watt hour (3600 seconds/hour)
1:30:01am = 100W (this second) = 100/3600 watt hour (3600 seconds/hour)
...
So at the end, you have 1800 seconds (readings) of 100W/3600 Watt-Hour. Which would give you 50WattHour.

You should test my interpretation that the number transmitted is "momentary".  User Guides are often difficult to decode.  Hook that darn thing up with something that use a constant amount (like a light bulb), keep it on for the whole hour and see what it reads.  Then, do 1/2 hour on and 1/2 hour off and see what it reads.

Personally, I would prefer to go to 1 second instead of 15 seconds interval -- unless the data collection time is sluggish and need more that 1 second to do.  Going 15 seconds would expose you to 15 seconds worth of wattage error if something just turned on immediately after a reading is done.  With a longer duration, you may have to worry above averaging last and current reading.  A 1 second (or even 0.1 second), that reduces the need to worry about that.  Your max error would be "max watt thing you can turn on or off" divide by 3600 for the 1 second read.  Your program needs to do more summing, but your program likely wont complain about have to do so much more arithmetic.  So, sum it as quickly as the data collection / transmission time permits.

If you do want to stick to 15 seconds, each hour has 240 chunks of 15 second (3600/15=240), so read the watt and you have watt/240 WattHour.


Reference:
[1] The User Guide I found on line:
https://kb.shelly.cloud/__attachments/63832224/User%20and%20Safety%20Guide?inst-v=1ab960e4-071b-4043-9129-82bd66a757fc
« Last Edit: February 29, 2024, 03:41:33 am by Rick Law »
 
The following users thanked this post: rthorntn

Offline rthorntnTopic starter

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: au
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #7 on: February 29, 2024, 04:31:12 am »
Thanks, I'm now capturing:

Active Power
Total Active Energy
Total Active Return Energy

Total Active Energy and Total Active Return Energy update every minute and (calculating the difference between the latest reading and the previous one) they seem to give me the intended result.

No point reinventing the wheel I guess
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 11900
  • Country: us
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #8 on: February 29, 2024, 04:32:31 am »
Time/total pairs, using IanB's averaging technique.

To be clear, my post was assuming time/instantaneous value pairs reported by the measuring device, like this:

After scanning the "User and Safety guide" for the Shelly 3EM[1], what you may be seeing is (in their words), momentary.  Per the user guide, the display of Watt Usage is the Watt being used at that moment.  In the app shown in the user guide, they did not sum or average it for you. 

That's why I described how to do the totalizing afterwards.

Considering this point:

Personally, I would prefer to go to 1 second instead of 15 seconds interval -- unless the data collection time is sluggish and need more that 1 second to do.  Going 15 seconds would expose you to 15 seconds worth of wattage error if something just turned on immediately after a reading is done.

We also have this:

I have power data (Shelly 3EM with CT clamps), it gives me a power "value" (watts) from the sensor at least once every 15 seconds, it basically sends updates faster if it decides the "value" has changed enough.

This means you should not be exposed to a 15 second error, if the device samples more frequently when the power is changing rapidly.

The algorithm I posted does not rely on fixed reporting intervals, so it will remain accurate with uneven spacing.

 
The following users thanked this post: rthorntn

Online IanB

  • Super Contributor
  • ***
  • Posts: 11900
  • Country: us
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #9 on: February 29, 2024, 04:33:11 am »
Thanks, I'm now capturing:

Active Power
Total Active Energy
Total Active Return Energy

Total Active Energy and Total Active Return Energy update every minute and (calculating the difference between the latest reading and the previous one) they seem to give me the intended result.

No point reinventing the wheel I guess

Perfect.
 
The following users thanked this post: rthorntn

Offline jonpaul

  • Super Contributor
  • ***
  • Posts: 3366
  • Country: fr
Re: Wattage monitoring - I've no flipping idea what I'm doing, help!
« Reply #10 on: February 29, 2024, 01:57:34 pm »
integrate for KWH.

We Use professional instruments and CT like Yokogawa and Hoili, not consumer

j
Jean-Paul  the Internet Dinosaur
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf