I would like to have a backup battery connected to a device that requires an uninterrupted power supply, like an Arduino or Raspberry Pi, so that if my primary power source (USB plug) gets pulled, the device will switch to being powered by the battery.

I need a solution that I can either build on a breadboard or buy for only a couple dollars. Does anyone know a solution? I'm assuming this is a common need and think I perhaps am not searching with the correct key words.


I would like to add that I may also use 4AA batteries and a DC-DC step down module to produce 5V exactly to power a 5V device, so I'm looking for a solution that accepts 5V. Assume the device, let's say Raspberry Pi, takes 5V, the power supply is 5V, and the battery backup is 5V.

  • The edit says “the power supply is 5V” ... does that refer to the 4 AA's with step-down to 5 V? Or to a mains-connected power supply? – James Waldby - jwpat7 Jan 1 '16 at 17:35
  • @jwpat7 5V is the rating of both the mains power (USB cable) as well as the DC-DC step down from the batteries – jake9115 Jan 1 '16 at 23:14

Your $2 budget rules out some of the more-effective possible solutions, such as using an actual UPS (uninterruptible power supply) system.

One affordable approach is to connect the plus side of a 3.7 V lithium-polymer battery through a Schottky diode [such as MBR0520, SS14, 1N5819] to the +5 V line of an Arduino board. (I haven't looked at Raspberry Pi schematics and don't know if this will apply there.) Hook the minus side of the battery to Arduino ground.

Ideally, the battery voltage less the voltage drop through the diode (say .4–.5 V) should be just less than the voltage that USB supplies. Ie, just under 5 V if you have a 5 V board, or just under 3.3 V for a 3.3 V board. Note, most 3.3 V Arduino systems are specified to run at 8 MHz rather than 16. There's a good chance a 5 V Arduino running at 16 MHz would continue to run ok when powered by about 3.3 V, but it's out of spec.

If your battery voltage exceeds 5 V you won't be able to make the connection quite so directly. Besides certain risks of damage (see eg Method #5 and Method #8 of 10 Ways to Destroy An Arduino) there will be the practical matter that the higher battery voltage will cause its power to be used preferentially to the USB power, thus discharging the battery so that it won't act as a backup.

Edit: The question-edit says the system uses 5 V, and seems to suggest the primary 5V power supply uses 4 AA batteries and a DCDC converter.

If the DCDC converter is a step-down buck converter it will go out of regulation when the input voltage from the four AA's goes below 5 V, which is 1.25 V per cell.

As you can see from the following graph, if the discharge rate of a typical alkaline cell is 100 mA, it still has about half its power left when its voltage goes below 1.25 V. To fully use up the alkaline batteries, you could use a buck-boost converter or could test if your buck converter just passes the voltage on through, as opposed to shutting down when the input voltage is low.

alkaline AA-battery discharge curve

(Note, the AA-battery discharge curves shown above and below are from the powerstream.com's “AA tests” web page.)

For the backup battery, where you also want 5 V output, an economical possibility is use of four AA NiMH cells, with nominal voltage 1.2 V per cell. However, initial voltage officially can exceed 1.4 V per cell, giving 5.6 V total:

NiMH AA-battery discharge curve

A Schottky diode in series will bring that down to say 5.2 V, an acceptable level for powering a 5 V system. But if the primary supplies 5.0 V, the backup will end up discharging slightly until its output voltage goes below that of the primary. If that's acceptable, fine. Otherwise, you could use a diode like 1N4001, with 0.7 to 0.8 volts of drop at 0 to 150 mA output. Instead of losing some backup power at first (due to higher backup than primary voltage) you will lose some at the end, due to backup voltage going too low slightly sooner. That won't be a problem, however, if you restore the primary supply and recharge the backups in time to prevent over-discharge damage to the backup batteries.

  • Thank you for the info. Please see my edit above. Does your suggestion still hold true? – jake9115 Jan 1 '16 at 5:17
  • @jake9115, see edit – James Waldby - jwpat7 Jan 1 '16 at 18:39
  • Thanks for this thorough answer, it is truly helpful. May I ask a bit more of you, and request a circuit diagram or links for parts needed? Your solution sounds elegant and simple. However, other sources, such as here: raspberrypi.stackexchange.com/questions/1360/…, suggest much more difficult and complex designs. Are there any obvious deficits with the simpler design you offer here? – jake9115 Jan 1 '16 at 23:20
  • Those designs are more complex because they include charging circuits for the backup batteries, and most of them use bigger-than-AA batteries, eg sealed AGM lead/acid batteries as are used in ordinary UPSs. Because the R.Pi's typical current draw is on the order of 300 mA, vs say 30 mA for an Arduino, the circuit I suggested is only suitable for supporting an R.Pi through brief outages of its main supply (eg five to ten minutes). – James Waldby - jwpat7 Jan 2 '16 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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