I have a circuit/device that using ESP32 as microcontroller. I want to calculate how much total current and power that my device drawn.

So, the current draw will be like this:

my current data

My question is:

  1. The total current drawn in 1 minute by my device is 1.62 A (i just summing all of current draw * time), is it correct?

  2. How long my device last if i powered it with battery 4000 mAh, device is using 5 V, and ON/active time is 12 hours a day?


OK, now I have measured the current drawn using 1 ohm resistor series with load/device. Then connected my digital oscilloscope. Now what i got is like this:

enter image description here

So, to calculate total current drawn i just have to multiple current draw with period, is it correct?


Okay, now i got the average current consumption. But i got another question, i need to calculate the power consumption and energy that consumed by 1 hour. To get the power consumption i need to multiple current with voltage, like this:

P = V * I = 5V * 12.25mA = 61,25 mWatt.

  1. Is it correct?
  2. Is this average power drawn each day?
  3. Then to calculate energy each hour, i just multiply it by 3600. E = 0.06125 * 3600 = 220.5 Wh. Is it correct?

Thank You

  • \$\begingroup\$ Think about what happens if you multiply one unit with another. A * s = A according to your logic. \$\endgroup\$
    – winny
    Commented Apr 15, 2019 at 13:59
  • 1
    \$\begingroup\$ A good first step would be to monitor the current using a series resistor and an oscilloscope, just to get an idea of how the current varies with time. Have you done that? I think that taking a reading every 1s is going to be far too slow. \$\endgroup\$ Commented Apr 15, 2019 at 14:05
  • \$\begingroup\$ @ElliotAlderson Okay, now i edited my question \$\endgroup\$
    – Rizal Lana
    Commented Apr 16, 2019 at 6:57

2 Answers 2


No, your method is incorrect.

What you need to do is figure out the average current that is being drawn. By that I mean log the current that is being drawn over a certain period of time and find the average.

You can then calculate roughly how long your battery is going to last by taking your mAh and dividing it by the average mA drawn.

I think OP is slightly confused over current consumption. Let us use an example:

A 9V battery, with a capacity of 600mAh is powering an LED with a series resistor. The total current in the circuit is 10mA. The average current is taken every 1 minute for 10 minutes. Each time it is 10mA. This means the total current is still 10mA. It does not add up. Do calculate how long the LED will be illuminated for, you simply take the 600mAh, and divide it by your average current drawn (in mA). Thus, 600/10 = 60 hours.

Of course, this will only give you a rough figure. There are losses throughout that time, so some places, such as HERE will have an extra *0.7 at the end of the equation, thus making your battery life (600/10)*0.7 = 42 hours. This is to account for losses that will inevitably happen during the lifetime of a circuit.

  • \$\begingroup\$ i have measured the average current. It is 107 mA during active time (5 s), and then 17 mA during sleep time (55 s). So how do i calculate total current in 1 minute or 1 hour? \$\endgroup\$
    – Rizal Lana
    Commented Apr 16, 2019 at 6:56
  • \$\begingroup\$ You need to log that measurement. The easiest way, as Elliot Alderson said, is to use an oscilloscope. Measure over a series resistor for a duration of 1 minute, work out the average drop over the course of a minute and use Ohm's Law to give you the current. Then that gives you the total current for a cycle. As long as it does the same thing each cycle, it will be the same current after a minute, an hour or a day. You then use the method I described to calculate the battery life. \$\endgroup\$
    – MCG
    Commented Apr 16, 2019 at 7:45
  • \$\begingroup\$ okay, thanks for the information. \$\endgroup\$
    – Rizal Lana
    Commented Apr 17, 2019 at 0:54
  • \$\begingroup\$ @RizalLana please see the extra info I have added to the answer, including the example. That should help you \$\endgroup\$
    – MCG
    Commented Apr 17, 2019 at 7:33
  • \$\begingroup\$ Okay, Thanks for the information. Now i edited my question again \$\endgroup\$
    – Rizal Lana
    Commented May 28, 2019 at 1:33

From your new data (5 secs/107mA, 55 secs/17mA), your period is 60 secs. Now, your average consumption in a minute is:

(1/12)*107mA + (11/12)*17mA = 24.5mA

As you said before, the device is only ON 12 hours a day, that's 50%, so your final average consumption is 12.25mA.

With 4000mAh battery, its life will be:

Estimated life = (K) * Battery Capacity/Device consumption

K*(4000 mAh / 12.25 mA)
~ K*325 hours

with K = 0.7 battery life is around 228 hours or less than 10 days.

There are 3 things you should have in mind for measuring power consumption and estimate the battery life:

  • Measurement period:

As @elliot-alderson states, if you measure every second you could be losing peaks of current in your device/micro, for example, if there is a certain activity with a milliseconds period (ADC sampling, comms, etc.).

  • Measurement length:

As @mcg mentioned, for calculating an estimated life, you need to figure out an average consumption, this is the average consumption on a period of time equal to a repeatable cycle in your application. This is, if you read your ADC each second, transmit via UART each 200ms and blink a led every 2 seconds, you should average your consumption within a 2-second period.

Sometimes, if your device is most of the time in sleep mode, an event every 15 seconds or minute, you can use the consumption on sleep mode.

in your case, your active ratio is 50% (12 hours a day) so that should be also taken into account.

  • Measurement place

Where are you measuring the current at the battery, after a regulator, on a 3.3V plane. Remember that you need both voltage and current to measure power. So 300mA@5V is the same power than 500mA@3V. Check also the efficiency of power converters (DC-DC, Buck, boost) to get a reliable estimation.

Having all these clear you can use this tool to calculate the battery life, which is (K is a safety factor because you might not use the full capacity of the battery, I use 0.7 for my designs)

Estimated life = (K) * Battery Capacity/Device consumption


  • \$\begingroup\$ Hi, Edited my question again. Could you please help me? \$\endgroup\$
    – Rizal Lana
    Commented May 27, 2019 at 14:28

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.