I am attempting to make an alarm on AC main failure based on Arduino Mini Pro.

The idea is that when AC main failure happens the Arduino Mini Pro shall wake up and periodically "beep" between "sleeps."

I want to use 3.3V/8MHz version of Arduino primarily sourced by AC adapter and to use its hardware interrupt to detect the AC failure.

When AC fails it should be powered by coin cell battery until AC main returns. Primary goal here is to work on battery as long as possible.

While reading various posts, threads, articles, I understood that this should be done with op-amp and MOSFET but struggling to figure out how.

Because of coin cell battery's low voltage to power 3.3V Arduino, I understood that solution based on Schottky diodes are not the right option, especially due to reverse current it may blow up my battery over a time.

Appreciate experts' help!


2 Answers 2


According to the data sheet you Atmega328 can go down to 2V power supply at 1Mhz so you can use a coin cell and a Schottky diode as a backup source. All your timings will be eight times longer but I don't think this would be an issue. Just change the prescaller clock while Arduino is powered from the main source, here is a topic about this.

You can find plenty of low power techniques sources just googling , here is one.

I think that the answer is wrong, the oscillator itself is not working under 2.7V so this will not work.

Still, if the average power consumption is under 10mA (beep and rest) you still can use the Schottky diode and a larger capacitor on the 3.3V rail. The data sheet shows 0.3V voltage drop at 10mA which is still in the accepted range for 8Mhz.

  • \$\begingroup\$ Thank you very much, Dorian! I am worried about blowing up the battery by time because of reverse current of Schottky diode. 😥 \$\endgroup\$
    – Bakyt
    Dec 18, 2018 at 12:31
  • \$\begingroup\$ @Bakyt The Schottky reverse current is not an issue, just use a low current diode, at 2V the reverse current is under 0.1uA even in the worst condition, usually ten times lower. Like this one: ro.mouser.com/datasheet/2/389/bat54-y-954423.pdf \$\endgroup\$
    – Dorian
    Dec 18, 2018 at 12:34
  • \$\begingroup\$ thank you for your clarification! I will look at available diode options. \$\endgroup\$
    – Bakyt
    Dec 18, 2018 at 13:19

I would suggest an optoisolator such as HCPL3700. Avago has a great application note on using it https://docs.broadcom.com/docs/AV02-3699EN

I used it like so in a clock circuit to detect AC loss for resetting to a known time (master clock application).
AC Loss detector

The input resistors limit current flow thru the bridge rectifier.

  • \$\begingroup\$ thank you very much for the great solution option. I wasn't aware of such ready-to-use optocouplers. It looks I need to wake up the microcontroller on a regular interval, put high of one of its outputs to feed the "receiver" part of the coupler and measure the level at Vo. As I mentioned in the post, my another concern is to work on battery longer time as possible. I will look at this option too! Thank you very much again! \$\endgroup\$
    – Bakyt
    Dec 18, 2018 at 14:23
  • \$\begingroup\$ No no, that's not the intent. Vo connects to an input pin with it's internal pullup enabled. As long as the pin is Low, AC is present. Set up your interrupt to take action when the pin goes High. \$\endgroup\$
    – CrossRoads
    Dec 18, 2018 at 14:42
  • \$\begingroup\$ thanks @CrossRoads for clarification. We need to power somehow the receiver part of the coupler so it can react to the loss of AC, hence to interrupt the microcontroller (MC). When MC sleeps "forever" (till the interrupt), the only option to power it is the battery, which is constant current drawing. Appreciate if there are some parts that I did not get so far. \$\endgroup\$
    – Bakyt
    Dec 18, 2018 at 15:02
  • \$\begingroup\$ Given that this would force 100% battery operation it seems less suitable than the asker's original idea. Use a quality AC to DC power adapter as both the source of routine power and (likely after a capacitor delay of a few seconds) the way to detect power failure. \$\endgroup\$ Dec 18, 2018 at 15:47
  • \$\begingroup\$ Two schottky diodes for power source - battery, and AC. uC runs all the time - it won't know where power is coming from. Loss of AC detector lets it know it is now running on batteries. I suppose just a low on one input from the mains AC to 5V supply would do the same. Not as sexy tho. AC/5V supply could keep a rechargeable battery topped off too with an appropriate charge circuit (with a design that didn't overcharge the battery). \$\endgroup\$
    – CrossRoads
    Dec 18, 2018 at 15:58

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.