If I know how many millamps I'm drawing, and also for how many milliseconds, how do I calculate this to mAh consumed?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
There are 1000 milliseconds in 1 second. There are 3600 seconds in 1 hour. That gives us 3600000 milliseconds in hour.
Consumed charge will be:
C = I * t / 3600000
where [C] is charge in [mAh] and [I] is current in [mA], and [t] is time in [ms]
If you want to calculate/estimate battery life - keep in mind, that nominal battery capacity applies to some nominal current / load. If your device draws small current - you will have more available capacity, and if current is large - you may get less mAh than nominal capacity.
Battery discharging with pulses may also affect "available" energy.
See battery documentation for more information.
That should be easy - each hour lasts 3.6 million milliseconds so each milliampere-hour contains 3.6 million milliampere-milliseconds. You have to multiply the current by the number of milliseconds which will give you milliampere-milliseconds and then divide that by 3.6 million to get milliampere-hours.
Integrate the current over time and you have your charge. If you want that in mAh, divide by \$ 3.6 \cdot 10^6 \$