This post explains the basics of using a lithium battery on a Raspberry Pi project.
Most lithium batteries have a 3.7 volt rating, and operate safely from about 3.0v to 4.2v. Discharging a battery lower than 3.0v will shorten the battery’s lifespan, and charging it above 4.2v will do the same. The Raspberry Pi and most of the add-ons are made to operate at a constant 5v, meaning the two are not compatible without something in between. This is where a charge controller and a voltage booster come into play. This can be done with two separate components, but an all-in-one device can save on space and simplify wiring. Many options are available, and I’m going to show my favorite (meaning least expensive) board. All other boards (such as Adafruit’s Powerboost) function in the same way as this one, so the basics explained here apply to all of them.
This module has a 5v power input, which can come from USB or from a 5v power supply. It uses the 5v to charge the lithium battery. It is able to properly charge the battery to 4.2v and then hold it at that voltage.
It also has a 5v power output, which boosts the battery voltage to a stable one that can be used on the Pi. When the battery voltage drops below 3.0v, it kills power to the output entirely.
The battery wires are soldered to the B+ (positive shown in red) and B- (negative/GND shown in black). The microUSB/miniUSB connector on the left is used for power input, and the standard USB on the right is for power output to the Pi. The connectors can be removed for projects that need the extra space, and power wires can be soldered directly to the pads on the board.
This device is one option of many available. It is used in my projects such as the PSPi because it can sustain over 1A of current continuously without problems. Many other devices are just as capable, but the price of this makes it appealing.