Since many people might be using with lithium batteries for the first time, I thought I would mention a few guidelines for those unfamiliar with this most excellent of energy storage media. Lithium cells are not difficult to charge correctly, but they are very particular. To paraphrase a well-known american street sign, "Differ and it will hurt". The hurting could potentially involve fire and lithium-flavoured brimstone.
Charging consists of a constant-current phase, during which the voltage rises, followed by a constant voltage phase where the voltage is not allowed to exceed a certain value, while the charging current steadily declines. Commercial chargers typically set Vmax at 4.2V. By setting the voltage limit a bit lower (4.1V, say), you can be kinder to the cell and get more useful charge cycles out of it by preserving its capacity for longer. That is one advantage of setting up your own charge control circuit. The constant charging current, in milliamps, should not exceed the cell's capacity, expressed in milliamphours. Charging current (in mA) is most often in the range from 0.5C to 08.C, where C is the capacity in mAh. You will find lots of ideas for chargers online, so make sure that they conform to this pattern. One of the simplest to build consists of an LM317 configured for current limiting feeding into another LM317 configured for voltage regulation.
You can even charge a Li-ion cell from a current-limited bench power supply. Set the voltage to 4.1V and the current limit to 500mA (which is a safe value for a 1200mAh cell). You will see the transition from the first to the second phase of charging as described above. The charging that occurs after the voltage limit is hit is known as the saturation charge. It accounts for the last 20% or so of the energy stored in the cell. Reducing the length of time spent in this second phase reduces the energy stored, though not by much, and is less stressful to the cell. Typically charging is terminated when the charge current has dropped to a certain percentage of its initial, current-limited value. Try 50% as a starting value.
If you don't want to build your own charger, you can get ICs to do the work for you. The MAX1555 (free samples available from Maxim) and the cheaper MCP73831 from Microchip are two examples. The only trouble with them is the tiny surface-mount SOT-23 package, so you really need to make up PCBs if you go that route Alternatively, for a bit more $$$, Sparkfun has various breakout boards based on these chips. Just put "LiPo charger" in their search box. If you want to get fancy, you can integrate the charge control with your main MCU. That introduces a lot more complexity and work but obviously has the potential to shrink your BoM. * Whatever you do, don't just leave a lithium cell hooked up to 5V through a resistor. That can sometimes be OK with NiMHs but never with lithium, as the voltage will continue rising past the safe maximum of 4.2V *
If you want to ensure that your application receives a constant voltage regardless of whether or not external power is connected, consider using a low-dropout regulator like the MCP1700. That way, your application sees a constant 3.3V - enough for most MC's and LED's.
Equally important as overcharge protection is overdischarge protection. * Don't allow a lithium cell to discharge below 3.0V *. If you go much below that, the battery can suffer internal damage which can reduce its capacity and potentially render it unsafe (i.e. a future fire risk). In practice I would recommend switching the device off either manually (in response to a low-battery warning light, for example) or, better, automatically, at 3.5V. The automatic option requires a bit more thought but can be implemented using an analog input and a digital output on a microcontroller, so it's a good option if you are already using an MC. In one scheme, the pushbutton momentarily applies power to the MC, which immediately secures its own power supply through a transistor in parallel with the switch, so when the button is released, power continues to flow. Using a momentary-ON pushbutton for power ON/OFF rather than a traditional toggle switch is a nice 'professional grade' touch for any project.
What if your project needs more than 3.7V, or demands high current capacity? Certainly, multiple cells can be wired in series for increased voltage or in parallel for increased current and or run time, or a combination of the two. HOWEVER, charging multiple cells in series or parallel is best considered a field for advanced Ninjas. Unless (and, possibly, even if) the cells are identical and are wired into series/parallel configuration when brand new, there is scope for the charging voltage to be unevenly divided between cells wired in series, and for the charging current to be unevenly divided between cells (or strings of cells) in parallel. There are no safe & simple shortcuts that I know of to deal with these scenarios. Therefore, if you want to use lithium cells in series and/or parallel, you should disconnect them and charge them INDIVIDUALLY.
Why are there three terminals? Two are obvious (hopefully!) The third is a temperature sensor which can be monitored to identify fault conditions. It is not necessary to connect anything to this terminal when charging or using the cell.
You can find much more detailed information, values, charging profiles, graphs etc at www.batteryuniversity.com.
Be careful and be safe when charging lithium batteries. The information in this email is correct to the best of my knowledge but is not meant to be exhaustive or to cover every possible scenario. If in doubt ask for help or use a commercial lithium battery charger. Note: Most phone 'chargers' do not in fact contain any charge control electronics, because this function is integrated into the phone. So hacking an old phone charger to connect it directly to a phone battery is NOT a safe charging option.
As Super-Awesome Sylvia would say, "Remember to experiment, stay safe, and get out there and make something!"