# Will this circuit suffice for low battery detection for any microcontroller?

I'm making a major digital circuit powered by two 3.6 volt cordless phone NiCD rechargeable batteries, and one thing I want to include is a low battery detector. To protect the rest of the circuit from overheating, I use a typical 7805 voltage regulator circuit to give all my circuit 5 volts.

What I want to do is detect if the source battery is too weak to power the rest of the circuit and allow a microcontroller to detect it via a GPIO pin's logic state.

Because digital circuits ideally run on 5VDC, I figured using a zener diode rated at 5.1V with a 10K resistor for R1 would be sufficient to detect the low voltage itself but I'm not sure if it would explode the GPIO pin even though its pulled up by 5V through R2 which I may also make as 10K.

Questions are:

Would this circuit have potential to work or would connecting fresh batteries equaling the same voltage explode a GPIO pin?

Also, is 10K an ok value for the resistors or should I choose something different?

The microcontroller in question is at89C2051.

• What's the purpose? Are you planning to shut down most of the circuit when the battery appears "low?" Or do you want to save some data and shut down? How will you use this? Also, what exactly do you want to be considered "good" and "bad" regarding the stacked NiCd batteries? Peter's point about the LM7805 is pretty important, too. Have you considered an LDO?
– jonk
Dec 1 '16 at 1:28
• When the battery is low, I want the microcontroller to detect it using a GPIO pin and then display a message on an LCD indicating the battery is low. And what I want considered Bad is when the total voltage from the batteries is too low to power anything in my circuit (under roughly 5 volts). I haven't heard of LDO but I might consider a heat sink even though the battery voltage is less than 9.
– user116345
Dec 1 '16 at 1:39
• An LDO is a "Low drop-out" voltage regulator. An LDO will regulate with the input voltage as little as 0.5 volt or so (they vary) above the output. The need for a heatsink depends on the power dissipated in the regulator with the maximum expected input voltage. Dec 1 '16 at 4:15

This circuit won't work - the transistor will be saturated, and the GPIO pin held low, until the battery voltage drops to ~ 0.7 volts.

Also, your thought of using an LM7805 to regulate your 7.2 volt battery down to 5 volts will only work with fully-charged batteries, as the 7805 need a minimum of 2 volts across it to maintain regulation.

• If I made slight modifications to my circuit such as maybe adding a pull-down component or swapping components, would I get it to work? and I did manage to make a 7805CT regulator output 5V from a 6VDC wall adapter. I have to admit such circuit is not easy to find on the internet because their voltage detectors use the same voltage for input and output.
– user116345
Dec 1 '16 at 1:16
• It might work with a 5 volt Zener in series, between R1 and the transistor base, and a pull-down resistor of 10K or so between base and ground - then the transistor would turn off when the battery voltage drops below ~ 5.7 volts. Dec 1 '16 at 4:19
• So I take it a zener still in reverse (cathode to R1 and anode to base)?
– user116345
Dec 1 '16 at 4:45
• So your series idea does work. I used 6VDC for main supply, and I put a voltmeter and resistor in series for output to test, and when I stuck a 9V battery between zener anode and ground, the voltmeter measured 5.90V. If I instead connected the zener anode to vcc then I get a reading of 5.96V. It makes me think that the transistor is sucking up power sometimes? I don't know.
– user116345
Dec 1 '16 at 5:14