I have designed a system that spends most of it's time in sleep and then wakes up to accomplish a very short task so it can return to sleep. Using a CurrentRanger, I have logged the current consumption over a period of time with current value and a timestamp and saved it in a csv document.

I would like to get an estimate of the mAh my system is using so I can estimate the battery life depending on the battery I choose. I can do a trapezoidal integration of my current consumption, but I am not sure where to go from here. How can I extract my mAh from my data?

enter image description here

(Column C is the timestamp converted to total milliseconds)

  • \$\begingroup\$ approximately 1.04E-06 Ah ... assuming that column B is in amps and assuming that current draw remains constant for the hour \$\endgroup\$
    – jsotola
    Commented Jul 12, 2021 at 18:49
  • \$\begingroup\$ There are short burst where the system wakes up and draw around 100mA every x minutes. Thats why I want to average this \$\endgroup\$
    – ESD
    Commented Jul 12, 2021 at 19:18
  • \$\begingroup\$ "...wakes up to accomplish a very short task so it can return to sleep." - how long does it wake up for? \$\endgroup\$ Commented Jul 12, 2021 at 20:41

1 Answer 1


Assuming HH MM SS.sss and A.

In cell C2 add in formula

= (B2-B1)*(A2-A1)

This will give a result in "Ad", ampere-days so multiply by 24 to get Ah.

= (B2-B1)*(A2-A1) * 24

To convert to mAh multiply by 1000.

= (B2-B1)*(A2-A1) * 24 * 1000

Copy C2 down the rest of the column.

Excel (and others) store dates as numbers. The integer value is the number of days since 1900-01-01 (check this!) and the decimal part is the fraction of a day.

  • \$\begingroup\$ my system wakes up every x minutes to do a task during which it will consume around 100mA and then go back to sleep. That Is why I would like an average current consumption for an hour. This only compares the to last samples \$\endgroup\$
    – ESD
    Commented Jul 12, 2021 at 19:26
  • 1
    \$\begingroup\$ Well why not sum the mAh column and divide by the total number of hours? \$\endgroup\$
    – Transistor
    Commented Jul 12, 2021 at 19:33
  • \$\begingroup\$ I don't know the sampling rate of my measuring device or if it's stable. I also have multiple samples that have the same timestamp because of the high sampling rate so I don't think it would be a valid way of calculating it (correct me if i'm wrong). I was thinking of doing an integral of my samples which would probably give me a value of power and then convert it to maH, but i'm not sur how or if it's the right way to do it \$\endgroup\$
    – ESD
    Commented Jul 12, 2021 at 19:41
  • \$\begingroup\$ Decrease the sampling rate or ignore duplicate timestamps. The integral is just the sum of each reading by \$\Delta\$t which is what my formula is doing. \$\endgroup\$
    – Transistor
    Commented Jul 12, 2021 at 19:46
  • \$\begingroup\$ Would it be better to use an oscilloscope and shunt resistor to see the duration of the 100mA phase. If this is reasonably repeatable then you can divide it out over the sleep period, if that’s repeatable. For example 1s at 100mA equates in charge to 167uA over 10min. Failing that, use your existing measurements and sum (instantaneous current * time since last sample). This gives you the total charge over the sample set, so divide by the duration of the sample set to give average current. \$\endgroup\$
    – Frog
    Commented Jul 12, 2021 at 19:53

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.