# microcontroller low battery indicator

I am powering a board and circuit with a 9V battery (those alkaline ones). And I would like to read the 9V battery to keep track of how much power it has left. I have read that I can do this with a voltage divider since most ADC input on uCs take 5V max. That's good but wouldn't the voltage divider itself draw power and make the battery drain faster? I am not going to constantly measure battery level.

If you use a voltage divider with fairly high value resistors, e.g. two 499K in series and tap off the middle, your maximum voltage will be 4.5v and it will draw only 9 µA.

If even that much current were a concern, you could tie the bottom of the resistor divider into a open-drain output pin on the microcontroller and set it to ground only when you need to take a measurement. In that case, you could get by with lower value resistors.

EDIT:

As Russel McMahon mentions, many micros won't allow the input of the ADC rise much above their supply voltage (VDD), which would happen when the ground was removed on the resistor divider. So you would then need a high-side switch instead.

• OK but note: An ADC will usually need an input impedance of a few 10's of k at most for full accuracy. // Open drain output pin may not tolerate applied voltage when controller off - or may - depending n design so make sure. // Two transistors allow you to switch high side of a resistive divider so it draws no power when off. Commented Aug 19, 2011 at 2:27
• @Russell, re the maximum input impedance, I believe this mostly affects the acquisition time for a rapidly changing signal. In the case of the 1M resistor divider, the input will essentially be constant (unless the device draws so much current that the supply voltage droops), so it should be possible to get a valid reading over several milliseconds. Commented Aug 19, 2011 at 17:49
• @Russel - You can reduce the input impedance of a primarily DC signal like this to insignificant levels by adding a capacitor on the ADC input. Commented Aug 19, 2011 at 18:22

A high value resistor divider, as tcrosley suggests, is a good idea as a start, though there are a few "but"s.
The ADC's input impedance is usually quite low, so will have a big influence on a 1M$\Omega$ resistance. Also switching the I/Os to input will stop the current, but consequently the 9V will be on the inputs and you don't want that.

A solution could be to use a P-MOSFET to switch the resistor divider on and off. Choose a low-leakage FET like the FDG332PZ (just one of many type with a leakage current < 1$\mu$A). Remembering the low input impedance of the ADC we can then safely use a lower resistance divider. This will cause a larger current when switched on, but we only need it for a few $\mu$s every hour or day or so, so overall that's really negligible.

• PMOS FET will be on "high" side and needs a gate drive above Vcc rail. Use a second transistor to drive it. (This is the 2 transistor arrangement that I mentioned). Or use open collector procesor out[ut to drive it but note warning in my earlier comment. Commented Aug 19, 2011 at 8:19
• @Russell - Correct. Sorry, hadn't read your comment, and now it looks like I've stolen your answer (though that would have been much more comprehensive :-)). Again sorry/thanks. Commented Aug 19, 2011 at 8:28
• no problemo - was only a comment I made it in anyway - was just making sure the drive level issues noted. Commented Aug 19, 2011 at 10:35