Let's assume I have a microcontroller with some amount of peripherals attached and would like to be able to make a reasonable estimate of battery life. Because I might have it sleep at times, and various peripherals would be in differing states, my current consumption might vary between uA (in sleep mode) and some 10s of mA (when awake).
Now, I could attach a battery and let it run down and measure the time, but this makes it both time consuming and hard (and possibly expensive) to compare different approaches, both in the firmware and hardware.
I could place a multimeter in series, but even if it has data logging, that is at some interval and I'd have to interpolate, and could entirely miss variations smaller than the interval. (Plus burden voltage and all that.)
If my device sleeps enough, the awake current becomes somewhat negligible, but that might require a 1000:1 ratio of sleep time to awake time, so that's not likely on all designs.
Is there some device that integrates current over time at very small amounts (e.g., not the Kill-a-watt outlet meter)? Basically I'm interested to know that "over the last hour, 20mAh were consumed". Bonus points if I can get precision current measurements at any given time, to compare awake and asleep current consumption.
Best Answer
Well, there's certainly specific current-sensing ICs. In your case, I'd "simply" go with something like:
Problems:
But as a principle, that works, and is certainly viable (although designing a stable, low-noise, high-amplification instrumentation amplifier might be nontrivial; but: there's existing instr.amp ICs that make that a lot easier).
Luckily, your problem is rather common. So: Many, including Texas Instruments, have a portfolio of current sensing amplifiers, some of which integrate both aforementioned shunt resistor AND a digital interface. See TI's product listing.
In fact, these ICs are capable of measuring current and supply voltage at the same time – and that's great to actually measure drawn power, a measure far more relevant to battery life than raw drawn current, if there's nonlinear elements (that is, for example, MCUs).
The INA233, for example, can be connected to an external shunt (let's say, 0.3 Ω) and has a resolution of 2.5 µV per ADC step. That means, a single ADC step is I = U/R = 2.5 µV / 0.3 Ω = 8.333 µA in current.
I think that device also has an automatic sampling & averaging mode, so that you can easily get good approximations even under rapidly changing load.
Also, as I just found out: the thing has an "alert" level, so that you can wake up your measurement system whenever the current rises above a configurable threshold. Nice! That way, you only need to sample occasionally.