I’ll throw this out real quick as I’m sure others are trying to do the same thing.
Been working on a RPI project that is ‘mission critical’. It cannot fail because it looses power and the file system corrupts. So I put together a battery backup that will provide 5V which can work for either RPI or Arduino.
The theory behind my circuit is very simple. I have a 9V battery and a 12V transformer providing current, both behind diodes. As long as the 12V power is on, the 9V battery is inactive. As soon as the 12V power is removed, the 9V battery provides power.
I use a DC to DC converter to convert 12V or 9V to 5V. My first experiment was with a normal 7805 voltage regulator. First, it got quite hot, even with a heat sink. The RPI draws a good chunk of current. Second, because so much power is wasted, the battery lasts just a few minutes.
I then tried the OKI-78SR-5/1.5-W36-C DC to DC converter, available here for about $4. (Same size as 7805 though the pinout is different). This works great – not only did I get rid of the heat problem, but the 9V battery was able to power my RPI for about 45 minutes.
Here is the schematic:
D3 exists to protect the circuit if I put the battery in backwards. I find this easy to do with a 9V. D4 is a 1A schottky diode which has a low voltage drop. You are starting with 5V, so you don’t want to loose much.
D4 prevents power coming from the RPI back into the circuit. Probably not important if nothing else is connected to the external power supply, but you may not want the RPI powering external circuitry.
A fuse is also highly recommended. I have a resettable fuse here, but it still isn’t quite the one being used by the RPI’s internal power supply. If I can find the same one (through hole), I’ll put it’s part number on as well.
I have the beginnings of a power fail detector circuit that can notify the RPI that it is in a power fail state. It’s just a transistor monitoring the 12V supply (essentially a NOT gate that outputs 3.3V). Once I have it fully functional I’ll add that.
I’m also working on circuitry allow the RPI to turn the battery OFF when it has shutdown so the battery doesn’t fully discharge. That is being implemented with an ATTiny85 and I’ll try to get that documented after it is fully functional as well.
Feb 2016 update:
Stumbled across this site: Safe Power for Raspberry Pi. At the moment I don’t need this, but it looks like a very good solution for providing RPIs with battery backup. So I’ll put a note here of the site.
Here’s another article worth looking at
Aug 2016 Update:
Filing this post away for possible future use. The (my) reason for wanting battery backup is to protect the O/S from corruption. The other possibility, covered in this post, is to make the O/S Read-only: