Is it possible to power a Pi using battery power alone, such that you have two battery packs; one primary and one secondary? To ensure non stop running the Pi should run from the primary until the primary is disconnected at which point the secondary replaces it, becoming the primary, with the the primary becoming the new secondary when replaced. At no time can the Pi be shutdown, either because of power loss or voltage disruption. Also only one pack should be depleted at anyone time.
Yes, it is possible to power the Pi with 2 battery packs, keeping the Pi alive at all times. I do this in my travel trailer and Pi-powered alarm clock. I can't afford to miss a fishing date so I have a two battery system.
The Pi. Mine, with touch screen display, needs approximately 2 amps at 5 volts. This is 10 watts, a moderate amount of power in this day and age.
The primary battery. My RV has a hefty 12V battery rated at 220 Amp-Hours, good to power the Pi alone for 10 days +. It is recharged by solar, or battery charger when at a powered campground, at which times the voltage in the trailer circuits is around 13.8V.
The secondary battery. Internal to the clock is a pack of 8 AA size NiMh cells rated at 2 Amp Hours at 10 volts, good to power the Pi for an estimated 2+ hours.
A "buck" voltage regulator. This cheap (Chinese) device converts the battery voltage(s) of 10 to 13.8 down to Pi 5 volts. It does so very efficiently - 90% - while able to provide 2 or more amps. Exactly what the Pi needs.
A couple of Schottky diodes to connect the two batteries together but at the same time keep one from charging the other. This is important since one battery is 10 and the other is 12. Think of the diodes as one-way devices for the current.
Battery charging. The RV battery is charged by its own systems so this is of no interest. The internal 10v NiMh battery pack is trickle charged by a resistor and diode (the diode to keep the 10v pack from trying to run the rest of the trailer in the unlikely event that the main battery is disconnected.
Use your imagination a bit since I can't draw a diagram. Inside my clock the main 12v battery positive and the secondary 10v positive each go through a diode and then connect to the buck regulator positive. All the negatives are tied together at a convenient location. The buck regulator is set (by the user) to 5 volts and output power goes to the correct terminal on the Pi. Also, from the main 12v power connection, run a resistor (have to experiment with the value to get about 20 milli-amps. Over 20 ma and you risk long term damage to the little NiMh AA batteries.) and a diode to the positive of the AA battery pack.
Concepts: The primary battery runs the system 90% of the time. When I unplug the clock - mainly to show off my programming skills to someone - the internal AA batteries take over with no user intervention. This is because the diodes act like an "OR" circuit with the higher voltage always getting through with no delays. The buck regulator nicely converts the voltages down to Pi 5v. Bonus, since a buck regulator (switching regulator) is a DC-DC converter, it can take 10V at 1 Amp and convert it to 5V at 2 Amps, with very little loss. 10 watts in, 10 watts out.
Note, it is possible to use 4 AA NiMh batteries to get a 5V battery pack but this is inefficient and can't make good use of a voltage regulator. 4 AAs will last less than half the time of 8 AAs. I would dismiss this possibility in the interest of "doing it right".
It really does work and I have never slept through a fishing date.
A simple and cheap solution can be had with a car battery, a cheapish Black&Decker battery charger with maintenance- and float-charge modes, and 50-100W step-down converter (eBay) set to output 5.25V. They’re pessimistically about 80% efficient, giving you a little loss. Pull your 5V from there to a male microUSB jack. If the charger loses power, its float charge will no longer feed the converter, nor does it matter. The battery will amply provide.
- A deep-cycle lead-acid battery will serve you better and longer. Costs a bit more.
To calculate how long you can power your Pi, you should have some idea of how many watts it uses. Let’s say sourcing 12W (5V*2.4A) with peripherals, running from an ~800Wh battery - through a 80% efficient step-down converter, ~640Wh. 640/12 = 53 hours, ~20 minutes.
You should observe a low voltage cut-off (for 12V S/LA) of 11.5-11.6V for battery longevity, but you don’t need anything fancy for overdischarge protection; you can just use a timer app on your phone.
A 50$ S/LA battery, a 25$ charger and a 10$ step-down converter = 85$.