I want to detect low battery in typical DS1307 circuit with microcontroller.

My first idea is to connect one of low cost comparator inputs to Vbat, another input to 2.0V from some voltage divider powered from 5V and (comparator) output directly to GPIO.

My second idea is to connect microcontroller ADC, maybe thru some voltage follower made with low cost op-amp.

  1. If these ideas are good: should I pick comparator or operational amplifier with low input bias current instead of regular comparator / op amp?

  2. How this is made in computer motherboards where BIOS can detect low battery and batteries last for few years?

  • \$\begingroup\$ You could disconnect the comparator or ADC inputs with a transistor rather than leaving it connected all the time. Won't really matter than how much the bias currents are if you only connect it up once a day/week to check. \$\endgroup\$
    – DKNguyen
    Apr 10, 2019 at 22:18
  • \$\begingroup\$ I was thinking about it, but does it really matter when MCP6541 comparator (<$0.50) has 10^13Ohm input impedance and typical bias current 25pA? Should I worry about something else, like quiescent current? \$\endgroup\$
    – Kamil
    Apr 10, 2019 at 22:26
  • 1
    \$\begingroup\$ Quiescent current doesn't matter because you're not powering the comparator (or the MCU) from the back up battery. \$\endgroup\$
    – DKNguyen
    Apr 10, 2019 at 22:32
  • \$\begingroup\$ you are powering it form the battery if you connect it directly to a MCU input pin. \$\endgroup\$ Apr 10, 2019 at 23:12
  • \$\begingroup\$ @Jasen I don't want to connect it directly to MCU pin (I want to use voltage follower or comparator). \$\endgroup\$
    – Kamil
    Apr 11, 2019 at 7:40

1 Answer 1


You can't connect the battery directly to the microcontroller, beacuse when the microcontroller power is off. battery current will flow through the microcontroller's ESD protection diodes, so some sort ot switch is needed to block that current when the microcontroller is powered off..


simulate this circuit – Schematic created using CircuitLab

In the top diagram A MOSFET is used to switch the battery current off when there is no power. to read the battery coltage output low on 'sense' abs high on 'control' to charge the capacitor. then set sense to inout and set control to low to turn the mosfet on, you have about 10 milliseconds to read the voltage before the MOSFET will turn off..

In the bottom diagram a diode is used instead, to read the battery voltage set control to high, the voltage on sense will be about 500 mV higher than vbat, while the diode is conductiong a small current will flow into the battery, so use it sparingly. you could possibly us an internal pull-up on the sense pin instead of R2.

In motherboards the clock itself has an indication that the the battery is low. check your RTC's datasheet. it may also have that feature.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.