I'm trying to calculate the energy consumption over a period of 1.3 seconds in joules (J).

I have a sample every 100 ms (0.1 second) with the current and voltage (in volts) (in practice, the samples have a much higher granularity, but for the sake of simplicity ;)).

Time (s) Current (mA) Voltage (V)
0.0 30200 3.55
0.1 30000 3.6
0.2 30200 3.65
0.3 30100 3.55
0.4 30000 3.6
0.5 30100 3.55
0.6 30200 3.6
0.7 30100 3.65
0.8 30000 3.55
0.9 30000 3.6
1.0 30200 3.6
1.2 30000 3.55
1.3 30100 3.6

How can I calculate the consumed energy consumption in joules over this period of 1.3 seconds?

My idea was to:

  1. Convert mA to ampere by diving each mA value by 1000: e.g., 30.2, 30, 30.2, 30.1, 30, etc.
  2. Taking the mean of the current and voltage, 30.09 A and 3.59 V respectively..
  3. Multiplying these to get the power: 30.09 A * 3.59 V = ~108 W
  4. Since watt is also joules per second we multiply it by 1.3 to get the total consumed energy of this period in joules: 1.3 s * 108 W = 140.4 J.

Is this correct? Does it make sense? Are there better, more accurate ways to measure the energy consumption in joules over a period?

  • 1
    \$\begingroup\$ #4 looked good to me. It's about 3.6 V @ about 30 A for about 1.3 s. Nicely calculated. You are done. Now, if things bounced around a lot more and you knew some a priori details about why, then more complicated ideas might pop. But not with the numbers you've got there. That said, it's possible that the current went to zero in between your measurements and you didn't see it happen. Nature can be like that, sometimes. A real ***. But I kind of doubt it, here. ;) \$\endgroup\$
    – jonk
    Jul 22, 2021 at 5:02
  • 1
    \$\begingroup\$ @jonk No - he's miscalculated. You can't take mean(current) * mean(voltage) to get an average value for power (even though in this case it's close because it's almost DC). The right way is to sum up each interval's energy as described in the answers. \$\endgroup\$
    – throx
    Jul 23, 2021 at 5:26
  • 1
    \$\begingroup\$ @throx All those thoughts crossed my mind when I first wrote the comment. But given the dataset itself, a quick glance told me the simplified approximation method was good enough. I'm old enough to be an expert slide rule user, and at that time we used all manner of such wrong-but-wrong-in-knowingly-useful-ways shorthand when opportunities presented themselves. This case could be treated as one of those. That said, I'm still very glad you wrote, too. I could have said more and probably should have, just in case. \$\endgroup\$
    – jonk
    Jul 23, 2021 at 13:33
  • 1
    \$\begingroup\$ @throx By the way, while more is crossing my mind, it's actually important to acquire these approximation skills. At times, they can lead quickly towards getting at the meat of matters without getting bogged down. There are times when that's more important than the neglected errors. Particularly when trying to cut through a complex situation. \$\endgroup\$
    – jonk
    Jul 23, 2021 at 13:55
  • 1
    \$\begingroup\$ @throx So where you saw an improper technique, I had actually been more impressed that the OP had seen a quick way to approximate a useful result. Different strokes for different folks. \$\endgroup\$
    – jonk
    Jul 23, 2021 at 14:04

5 Answers 5

  • Convert \$\text{m}A\$ to \$A\$.
  • Multiply \$A\$ and \$V\$ for each time period to get \$W\$.
  • Multiply \$ W\$ by the length of the time period (\$0.1\text{ s}\$) to get \$J\$.
  • Add up all the \$J\$. Simple numerical integration.
  • 1
    \$\begingroup\$ This is the best way to do it and the simplest non-math formula way to explain it. \$\endgroup\$
    – user57037
    Jul 22, 2021 at 4:41
  • 1
    \$\begingroup\$ And if you want to improve it use Simpson's Rule! \$\endgroup\$
    – Tesla23
    Jul 22, 2021 at 8:06

Expanding @Elliot's answer to a graphical illustration:

Since you know the values of voltage \$V\$ and current \$I\$ at different time instants, you can calculate instantaneous power \$P = V . I\$ for those time instants.

Then, if you plot the graph of \$P \$ (in watts) against Time \$t\$ (in seconds):

enter image description here

The different discrete samples are joined by lines with the assumption that \$P\$ varies linearly with Time \$t\$. Now, you can estimate the energy consumption \$E\$ in \$\text{joules}\$ as the numerical integration of \$P\$ over \$t\$; or the area of the power plot under the time interval: \$(0.0\text{s} \text{ to } 1.2\text{s})\$. This area is simply the sum of areas of trapezoids--formed by triangle and rectangle--within every time interval of \$0.1\text{s}\$.

This is one way of estimation and another way of estimation is by assuming that the measured \$P\$ remained constant between the time samples. Then, you can plot the graph like step changes: enter image description here

In this case the math for energy consumption \$E\$ becomes fairly easy, as \$E=\Sigma(P \times 0.1) \text{ joules}\$.

Again, this is same as the area of power plot under the time interval: \$(0.0\text{s} \text{ to } 1.2\text{s})\$; i.e., the sum of areas of rectangles within every time interval of \$0.1\text{s}\$.

  • 1
    \$\begingroup\$ Notice that, of you change the "Power" axis of your plots to run from 0.0 to 110.5 instead of from 106.5 to 110.5, then you will see that the power "curve" actually is a pretty good approximation of a straight, flat line. I.E., the power consumption is practically constant. \$\endgroup\$ Jul 23, 2021 at 2:46
  • 1
    \$\begingroup\$ Note that in the formula E = Σ(P × 0.1) you have to discard either the first or the last data point, depending on which side of the rectangle you want to anchor to the data. If you instead discard half of each the first and last points, you have the trapezoidal rule. \$\endgroup\$ Jul 23, 2021 at 8:02
  • \$\begingroup\$ @EdgarBonet That's right. Here, the first data point was discarded for the estimation. \$\endgroup\$
    – Mitu Raj
    Jul 23, 2021 at 8:05

What you propose is one way to estimate how much energy was consumed.

A better method is to calculate how many joules were consumed in the time between each pair of samples, assuming that both voltage and current remained constant during that time. Then, just add up the total energy use over time. This is called a rectangular integration.

You can do better still with a trapezoidal integration. Assume that the power consumed changes linearly between sample points. Calculate the energy consumed as the time between data points multiplied by the average power (the average of the power at the beginning of a sample time and the end of a sample time). Again, just add up the energy for each sample time.

These are all just estimates, of course.

  • 4
    \$\begingroup\$ All real measurements are "just estimates". \$\endgroup\$
    – J...
    Jul 22, 2021 at 12:16

How you do it should depend on why you think the readings are varying.

If you think they vary because of reading errors and noise while the device takes a constant current and is fed with a constant voltage, then the way you describe using means will be accurate.

If you think that the device is actually taking a varying current, then it would be better to estimate the energy consumption in each short period, and sum them.

With this data set, the difference is going to be very small. If the readings varied by a larger fraction of the mean, then the results would be more divergent.


You are describing integration, similar to the derivation of Newton and Gauss. For example, in the first 0.1 s, EMF rose from 3.55 to 3.60 V. One can assume that the change is linear over a small range, so the average EMF over the first second would be half-way between, or 3.575 V (well, I've gone beyond the two significant figure data, but I'll round later. My bad.).

In a similar manner, current fell from 30.20 A to 30.00 A over that time, averaging at 30.10 A.

The total energy usage, over the first 0.1 s would be approximately 3.575 V * 30.10 A, 107.61 V*A, or J.

Repeat 12 times and sum the answer. This is simply a sum.

A more accurate answer might be obtained from curve fitting, thereby obtaining a numerical function to describe the change in voltage and in current with time, and solving the definite integral for that function.

  • 3
    \$\begingroup\$ Curve fitting+definite integration is absolute overkill. It can give better accuracy if you know what kind of function (or process) the source can be modeled after. But if the source generates samples with no clean math regularity (e.g. it is a load that awakes responding to external events, so possibly totally random) square or trapezoidal integration give quite accurate results if the samples are taken with a high enough rate. With curve fitting you may also generate huge errors if you don't limit the bandwidth of the system to avoid aliasing (because of Nyquist's theorem). \$\endgroup\$ Jul 22, 2021 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.