6

I have an energy monitor which collects the power usage (W) of a device, every 3.11 seconds. If I want find the total energy consumption (kWh) of the device over a set time period, how would I do it?

Transistor
  • 175,532
  • 13
  • 190
  • 404
bananamana
  • 165
  • 3

1 Answers1

9

You multiply each power measurement by its time to get the energy for that period. If you want your result in kWh, you have to scale from watt-seconds (which have their own name, the joule). We divide by 1000 to covert from W to kW, and divide by 3600 to convert from seconds to hours.

For example, if you use 9 W for 3.11 seconds:

E = 9 watt * 3.11 seconds
  = (9 / 1000) kilowatt * (3.11 / 3600) hours
  = 0.007775 kWh

Then you add up all the energy values for the duration you're interested in, perhaps the 27,781 values for all the 3.11-second periods in 24 hours.

As noted in comments, if all the time periods are the same, you can add up the power first and then multiply by the time, if that's more convenient. For example, for two samples 9 and 10: (9 * 3.11) + (10 * 3.11) = (9 + 10) * 3.11 = 59.09 Ws = 0.16 Wh.

jonathanjo
  • 14,034
  • 3
  • 34
  • 66
  • 1
    In case some readers did not notice: there are 3600 seconds in an hour – user253751 Nov 09 '22 at 18:44
  • Just to be fully explicit to the OP question, add up the W samples first, then multiply by the time covered by the first to the last sample. – Aaron Nov 09 '22 at 19:12
  • @Aaron, Just to be clear, add up the samples, multiply by the time covered, and then also multiply by the sampling period (e.g., in this case by 3.11/3600.) Amirite? If you don't multiply by the sampling period, then if you changed the algorithm to sample ten times as often, you'd be adding up ten times as many samples, and the final result would be ten times as great. – Solomon Slow Nov 09 '22 at 19:38
  • @SolomonSlow The sampling period is the actual time period when the samples were taken, 3.11s in this case. What you are talking about is the conversion from Ws to Wh, which is independent of sample rate. If they started sampling 10x faster, then the sample period would be 10x smaller. So it works out to be the same. – Aaron Nov 09 '22 at 19:46
  • @Aaron, you said, "add up the samples first, then multiply by the time covered..." If I collect ten times as many samples in the same time covered, how am I not going to get a result that's ten times as high? – Solomon Slow Nov 09 '22 at 19:50
  • @SolomonSlow (9W+9W)6.22s = 111.96Ws correct? (0.9W+0.9W...x20) 6.22s = 111.96Ws. It is the same. – Aaron Nov 09 '22 at 20:22
  • @Aaron, yes, but you scaled the samples. 9W does not equal 0.9W. And that's just what I've been saying all along. You have to scale the samples by the sampling period. (Or, add up the raw samples, and scale the end result. Same answer either way.) You didn't make that requirement explicit in your first comment. I thought it should be explicitly stated for the benefit of anybody who comes here, reads this stuff, and tries to implement it. – Solomon Slow Nov 09 '22 at 20:28
  • @SolomonSlow No, you mentioned sampling 10x as often. And if you do that, then your samples will be 10x as small. Not sure of the confusion. – Aaron Nov 09 '22 at 20:44
  • @aaron ... It's incorrect when you say "sampling 10x as often. And if you do that, then your samples will be 10x as small" ... if you sample the 9W load more often, the samples will be the same because they are power, not energy. – jonathanjo Nov 09 '22 at 20:46
  • Adding up all the raw samples first is only valid if all the sample periods are equal in length. In some cases, especially when timing variation exists in software, the sample period time can change and so you would need to do the multiplies of sample X time on a sample by sample basis. – Michael Karas Nov 09 '22 at 20:53
  • @MichaelKaras thanks for comment, I made an addition making that explicit in the answer ("if the time periods are the same ...") – jonathanjo Nov 09 '22 at 20:55