# Digital power/current consumption monitoring?

#### davidsalomon

Joined Aug 21, 2020
4
Hello,

I've been working on a simple project with Arduino. I integrated a current sensor and now I can know how much Amps any device is consuming. Also, I made a platform to graph the current consumption. Although, I am a bit confused on how can I measure the consumption over time and be trustworthy information so at the end it is the same information as the bill you get for your electrical usage, or at least very close.

Is it just by making a lot of samples per second and adding them up?
For example: getting 100 samples per second, add them, and graph the sum of the samples?
If so, how many samples per second is reliable?

Thank you in advance.

#### rsjsouza

Joined Apr 21, 2014
301
If I understood correctly your premise, you want to measure energy. If so then yes, it is basically what you are thinking - take each current sample and multiply by the voltage being supplied to the circuit at every sample. This will give you the power being consumed at every sample. In possession of this data, you can extrapolate add them and see how much energy was consumed through the total time span.

The rate to which you sample the current is highly dependent on the application. To measure the power of a house, for example, the sampling rate does not need to be very high, while in a Bluetooth or Wi-Fi processor you need to measure several thousand times per second to reliably capture the transitions of radio switch on/off.

#### davidsalomon

Joined Aug 21, 2020
4
Hello @rsjsouza , thank you very much for your response.

Yes, I want to measure energy/power in Watts. You gave me more clarity, but I still have some doubts. Can we look at a quick example?

If I do 400 samples in 1 second and 1,000 samples in 1 second, and if I just add all the samples then the total value is completely different. Let's say I got the same 0.03 A in every sample. For the 400 samples it would be 12A and for 1,000 it would be 30A. This doesn't make sense, and I'm stuck here. Please help.

#### Papabravo

Joined Feb 24, 2006
15,765
Hello @rsjsouza , thank you very much for your response.

Yes, I want to measure energy/power in Watts. You gave me more clarity, but I still have some doubts. Can we look at a quick example?

If I do 400 samples in 1 second and 1,000 samples in 1 second, and if I just add all the samples then the total value is completely different. Let's say I got the same 0.03 A in every sample. For the 400 samples it would be 12A and for 1,000 it would be 30A. This doesn't make sense, and I'm stuck here. Please help.
You are missing an important point. The sum of samples of current is a meaningless number. In the same manner the sum of voltage samples is also a meaningless number. What you want is the the product of instantaneous voltage and instantaneous current which is instantaneous power TIMES the sampling interval. The default assumption is that if the sampling rate is sufficiently fast each voltage and current sample is an accurate reflection of the AVERAGE current and voltage during the sample period. This may or may not be the case. You would have to do a comparison test to verify this assumption. Now if you add up an hours worth of samples of average power over small sample intervals you will have an approximation of power consumption with units of watt-hours. Will it match the calculations of the electric utility? Maybe. If not your first assumption should be that they use a more sophisticated method. BTW I would be very careful of jumping to conclusions based on the results of your initial experiments. I certainly would not be writing letters asking for a refund on my electric bill, without a great deal more evidence.

#### davidsalomon

Joined Aug 21, 2020
4
You are missing an important point. The sum of samples of current is a meaningless number. In the same manner the sum of voltage samples is also a meaningless number. What you want is the the product of instantaneous voltage and instantaneous current which is instantaneous power TIMES the sampling interval. The default assumption is that if the sampling rate is sufficiently fast each voltage and current sample is an accurate reflection of the AVERAGE current during the sample period. This may or may not be the case. You would have to do a comparison test to verify this assumption. Nor if you add up an hours worth of samples of average power over a small sample interval you will have an approximation of power consumption with units of watt-hours. Will it match the calculations of the electric utility? Maybe. If not your first assumption should be that they use a more sophisticated method. BTW I would be very careful of jumping to conclusions base on the results of your initial experiments. I certainly would not be writing letters asking for a refund on my electric bill, without a great deal more evidence.
Hello Papabravo, thank you for your response. Yes, the average is something I am missing, but I didn't know if it would be reliable. Let's say you get a peak in current in any millisecond, but after doing an average it goes unnoticed. These are experiments, not to go and do something regarding the electrical bill, just to monitor and have knowledge of my consumption and be more conscious on the usage.

#### Papabravo

Joined Feb 24, 2006
15,765
It is a feature of AC circuits that for a resistive load (an incandescent bulb) the voltage and the current will be in phase with each other. This means when there is a peak in the voltage waveform the same is true of the current waveform. Now the average value of any sinusoidal signal is zero. That is one reason why we use RMS (Root Mean Square) values of voltage and current to compute average power consumption in a resistive load. Multiplying voltage times current for in phase sinusoids is similar to computing a Root Mean Square value -- it is always a positive number.

Consider the relationship between the line frequency 50/60 Hz and 400 to 1000 samples per second. You are not going to miss anything significant that happens. 1 msec is also about 21° out of 360° for a sinewave.

#### rsjsouza

Joined Apr 21, 2014
301
I was in the middle of a response but @Papabravo already provided good information.

My initial response was:
If I do 400 samples in 1 second and 1,000 samples in 1 second, and if I just add all the samples then the total value is completely different. Let's say I got the same 0.03 A in every sample. For the 400 samples it would be 12A and for 1,000 it would be 30A. This doesn't make sense, and I'm stuck here. Please help.
Perhaps I should have been clearer on my initial response. Given that 1W is 1J/s, you need to collect all your samples and average them across the timespan of 1s.

So, assuming the voltage is constant across the measurement time (100V just for rounding), at every sample you would have 100V * 0.03A = 3W of instantaneous power at every sample. After one second, you would need to calculate the average power

$P_{avg} = \frac{P_0 + P_1 + ... + P_{999}}{1000} = 3W$

(similar thing for 400 samples)

The overall consumed energy, however, monotonically increases. So, if you monitor your system for 3 hours at the $$P_{avg}$$ above, you would have 3W * 3h = 9Wh. If monitoring for 4h, you would have 12Wh, and so on.

#### ronsimpson

Joined Oct 7, 2019
1,180
If you are building a piece of test equipment for (HP, Agilent, Keysight) then the sampling rate must be very high. If you are wanting to know how much power the house is using you can sample very slowly because a slight error is OK.

Let's say you get a peak in current in any millisecond,
If you sample 1,000,000 times a second you will see a 1mS peak.
Example: I have a furnace to heat the house. It uses 0 watts when off, 1000 watts when on, and 2000 watts for 1mS when starting up. The furnace cycles on/off all day long. If we sample 10,000 time a second we can measure the 1mS accurately, but 100,000 samples/second will give us only a slightly better picture. From a experiment I did we can get good results by sampling only once/second. We will miss 999 out of 1000 pulses but we will measure the one pulse as being 1 second long. (1000 pulses of 1mS * 2000 watts = 1 pulse of 1 second 2000 watts) The results over a long time will be very accurate.

You will want to measure much faster than 1 second. It is unlikely there is a 1mS pulse. It is more likely it takes 500mS for a fan motor to start up.

Example: We could not measure all three phases of the power line. But we could measure one phase very well. (the old meter is one phase and the new meter is 3 phase with the same parts) We measured phase 1 for one cycle then phase 2 for one cycle and then phase 3. The results was very good. (measured out over 1 second)