Battery backup

I’m planning on powering my Arduino primarily through an external power supply (24vDC from AC), regulated down to to 5v and supplied via the 5v pin. Since the project includes a scheduled timer (lighting control), I’d like to have a battery backup to keep the timer running during a power outage.

I was planning on simply hooking a 9v battery into the vIn when I realized I don’t really know which power source it was drawing from.

Basically, I’m wondering if the Arduino preferentially uses the 5v pin over the vIn pin, or what other way way would be the best method for achieving this.


I think you are not of safe ground having power going into both the Vin and +5vdc pins at the same time as this is not a application that the voltage regulator was designed to handle.

Your external +5vdc power should be applied via the USB connector (use a hacked USB cable) that way the automatic power switching designed in the Arduino will switch to USB power if the external power is lost.


The usb will not be connected…this will be completely standalone.

I’m open to alternative solutions though…

[Edit] nevermind, I think i see what you mean…nice idea…I’ll try it

I’m not sure what the drain is on usb power is when it’s being wall powered…

But, you might also like this: Minty Boost

I agree about the Minty Boost. That thing is SWEET!

  • Brian

That’s cute, but not quite what I’m looking for. :slight_smile:

Thank you retrolefty, it works great. I managed to find a DIY usb-b plug to make my own power cable , rather than have to sacrifice my lone arduino connector cable. :wink:

I then used the circuit described here:

to detect which source was active, and hooked up a red/green led so that it’s green on mains power (via hacked usb) and flashes red on battery.


I thought the maximum input voltage on the arduino was 12V? You said that you were powering it via 24V DC.

I plan to use 24v eventually (it will be powering a number Cree XRE LEDs too, which is why it’s so large), but I’ll be using a voltage regulator to get it down to 5v. I don’t actually have the final power supply yet, so I so I threw together a simple 7805 circuit (specifically : with a 9v battery for testing.

Ah gotcha, thanks for the clarification

keep in mind that using a 7805 with a 24V source will work… but the 7805 will have to deal with that extra voltage in the form of heat. Make sure you heatsink the 7805 since with 25V on the input side it will probably be generating some heat even without a load.