As a by-product of work around another project, a rather simple solution for an emergency power supply, or a simple UPS, emerged.
If you want to look at the development and the ups- and downs, go here: http://www.raspberrypi.org/phpBB3/viewt ... 37&t=50470
Below is a sub-set of the project that allows a Pi to work for more than 4 hours (at 500mA) just of two Ni-MH 2700 mAh cells.
The 400-500mA is worse-case for a Pi model B with memory stick and WIFI adapter running a program 24/7.
If you want the details look at the other post, but in simple terms, this circuit automatically switches to battery back-up as soon as the main voltage drops off. If that returns, the circuit will switch back again. The LT-1302 converts the voltage of the cells (between 1.8 and 3V) to 5V. The Ni-MH cells are automatically maintained and re-charged with a small charge (C = 1/64). If you want to use normal Alkaline 1.5V AA or AAA batteries, don't install R3 and D3 or use a jumper, and you need to work out how long the charge will last.
If you connect a GPIO line as input to the junction of R10/R11, you can use this in your program to find out that the Pi is running off the UPS. Look at the other post for a program that does that, and more.
The switching between the two supplies is done with two Schottky diodes, and the higher value wins the battle. You need to make sure that the main supply is about 100mV or so higher, so the battery supply is simply in waiting for a lower value.
If you cannot change the main 5V supply voltage, attach the sense input from the LT-1302-5 to the anode of D1. This creates a lower voltage equal to the drop over the diode of 0.3V for the Pi. In that case, you may want to select a larger value for C2, to make sure the Pi does not get disturbed by the 0.3V voltage drop when the supplies switch.
You can also use the variable version of the LT-1302, in which case you can set the output voltage with a divider and a 10-turn pot. In that case, adjust the output of the LT to be 100mV lower than the 5V supply, and leave the sense line where it is in the diagram so it corrects for the voltage drop over D1.
The LT-1302 will not get warm at all at 500mA. Make sure you get a good coil L1 and a low ESR capacitor for C2. More information can be found in the spec sheet. One last word of caution, don't use a breadboard to play with this circuit, build it on a (universal or prototype) PCB and follow the layout recommendations in the specification. If you do that, the circuit is simple, works flawlessly and is easy to use.