I'm wanting to use a 12V SLA battery and off the shelf mains charger as an uninterruptible power supply for an Arduino or similar device (via an appropriate 12->5V regulator) as also described here and here.

The battery voltage can be monitored using a voltage divider and one of the analogue i/o ports, but I also want to be able to detect from the Arduino software when the mains is off. I think what I'm after is an electronic version of something similar to this (to use for sensing rather than switchover). What is a way to do this with minimal additional components?

  • \$\begingroup\$ Hmmm... very small step down xfrmr and a rectifier and capacitor would do it. I won't give this as an answer because I suspect someone else will know of a better or simpler option, but if nothing else comes up this can certainly be detailed. Because of the low power level, you could easily wind such a transformer yourself at a very small size. If you end up with too high a voltage, just rewind the transformer or use a voltage divider. It probably wouldn't be a terrible idea to throw an optoisolator and/or crowbar circuit in the mix. \$\endgroup\$
    – K H
    Commented Aug 13, 2018 at 0:00
  • \$\begingroup\$ You can use a relay connected to mains. Or you can watch for a drop in the 12V output. It will probably drop precipitously when mains goes out. \$\endgroup\$
    – user57037
    Commented Aug 13, 2018 at 6:05
  • \$\begingroup\$ @mkeith thanks, that is pretty simple - no extra components - I'll do some tests to see how that will work. \$\endgroup\$
    – glennr
    Commented Aug 13, 2018 at 19:18

1 Answer 1


If you are continuously charging an SLA battery at the right voltage, then you do not need any form of switchover, just run the 12v->5v from the battery, and everything will happen automatically when mains power fails.

The safest place to detect mains failure is on the DC side of the charging power supply. Like this


simulate this circuit – Schematic created using CircuitLab

I'm not suggesting you hack into the charger to identify the pre-regulator voltage. I am suggesting that you use a 20v (ish) DC output wall wart, and build the regulator from an LM317. If the 317 doesn't sound attractive, you can buy cheap DC input 13.8v charger modules designed for float charging SLAs.

  • \$\begingroup\$ Thanks, I'm not concerned about the switchover, what I'd like to do is have the device report that it is running on battery so it can shut down if the mains doesn't come back on, just like a regular UPS. \$\endgroup\$
    – glennr
    Commented Aug 13, 2018 at 8:51
  • 1
    \$\begingroup\$ @glennr The link you provided for "what I'm after" is a switchover circuit. Your comment to this answer suggests that you are not satisfied with the answer but it seems to be exactly what you asked for. \$\endgroup\$ Commented Aug 13, 2018 at 11:38
  • \$\begingroup\$ I intended the first 2 links I provided to describe what I wanted, have edited the question to avoid this misunderstanding. \$\endgroup\$
    – glennr
    Commented Aug 13, 2018 at 19:12

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.