As promised, here’s a circuit which can be used to measure a voltage higher than VCC without drawing any current while not measuring:
Besides the fact that this needs an N-FET + I/O pin, there are several finicky details.
First of all, note that the following circuit will not drop the power consumption to zero:
The idea in itself is great: set DIO to logic “0” before performing a measurement, acting as GND level for the resistor divider (10 + 10 kΩ would be fine here). Then, to switch it off, set DIO to an input, so that the pin becomes high-impedance.
The problem is that the pin divider is still connected and that the AIO pin cannot float any higher than VCC + 0.6 (the drop over the internal ESD protection diode). The top resistor remains connected between PWR and VCC + 0.6, therefore it’s still leaking some current.
That also explains why the first circuit does better: the MOSFET disconnects all I/O pins from that PWR line, so that there is just a resistor from AIO to ground (which is harmless).
But there’s a catch: we need to be able to turn the N-channel MOSFET on and off, which means we need to be able to apply a voltage to its gate which is a few volts above the drain pin (the bottom one, attached to AIO). With a resistive divider of 10 + 10 kΩ on a 6V PWR line, that voltage will immediately rise to 3V, and there’s no way the DIO pin can keep the MOSFET on (it can only go up to logic “1”, i.e. 3.3V).
The solution is to use a different divider ratio: say 50 + 10 kΩ. Then, a 6V PWR level leads to a 1V level on the AIO pin, i.e. on the drain of the MOSFET. With DIO set to “1”, that means the MOSFETs gate will be 2.3V above the drain – enough to keep it turned on.
BTW, all this tinkering over the past few days has left me with a bunch a funky headers :)
Anyway, to summarise the zero-power battery monitor:
- to work with 6V PWR, use a 50 (or 47) kΩ top resistor and 10 kΩ for the bottom one
- use an N-channel MOSFET with low turn-on voltage (called a “logic level MOSFET”)
- to measure the voltage, set DIO to “1”
- measure the voltage on the AIO pin, where 0..1V will correspond to 0..6V on PWR
- to turn off the divider, set DIO to “0”
As you can see, this approach requires an active component to switch things and an extra I/O pin, but then you do end up with a circuit which can completely switch off.
For simple uses, I’d just use yesterday’s setup – sub-microamp is usually good enough!