5V to 5V DC UPS |
Backup time is approximately 1 hour using 3000mAh 18650 battery. Or, you can get a proper UPS Hat like this one:
UPS Hat with Raspberry Pi (bottom) |
It is very tempting to make a UPS from generic lithium battery chargers, especially if you just want to power devices like your internet modems and WiFi. And some power banks can be recharged as well as output power at the same time. A few can have their input power turned on and off without dropping their output, just like a UPS. But there are problems: often the power bank heats up.
It seems lithium batteries may not like to be float-charged. A common lithium charger IC like the TP4056 measures the current supplied to the battery and turns off charging when it thinks the battery is full. Diverting part of this current to supply the load at the same time interferes with this and may even cause the charger to fail to stop charging the battery. The latter may heat up. In particular lithium polymer batteries may swell up burst or pop its enclosure. Dr. Gough's has an excellent writeup on the subject.
Lithium Polymer Battery |
It is safer to use the bulkier lithium ion protected 18650 format, with safety vents, and extra overcurrent and overtemperature circuits. They are often slightly larger the the unprotected ones.
Typical Protected 18650 battery |
Another thing to look for is the metallic strip or tab running from one end to the other.
Note the conductive strip running vertically down the 18650 protected battery on the right |
18650 batteries are also easy to replace if mounted in holders. They are also surprisingly economical.
18650 are not AA size batteries |
CAUTION
It is generally NOT ADVISABLE to repurpose generic lithium chargers as UPS, Especially using no-name TP4056-based chargers like this one! Lithium battery-based UPS need to be designed for that purpose. When charging your batteries, you generally do not turn on the load. When the load is connected, the charger is not. Do not leave this setup unattended - there is risk of fire. I am also assuming you are familiar with electronics and its attendant hazards. The purpose of this project is to exercise your electronics chops i.e., to get some insight into lithium battery UPS design issues. This is NOT a viable design.
Having settled on the 18650, I happened to have this no name 'TP4056 Lithium Battery Charger with Protection' board in my parts bin. The PCB was marked '03962A' and there is even a schematic.
The deliciously cheap 'TP4056 Lithium Battery Charger with Protection' |
Schematic for 'TP4056 Lithium Battery Charger with Protection' |
A straightforward connection as a UPS might look something like this.
Wiring diagram from Electrothinks |
The UPS battery will switch over and back very quickly if the charger drops out or in. The problem is the red charging indicator will not go off as long as the load is also present. And this will result in the 18650 with a somewhat shorter service life.
Now if I add 2 schottky diodes thus, the TP4056 Charger will turn off charging with load connected:
MT3608 DC-DC Boost |
The resulting schematic is:
Battery output boosted to 5V using an MT3608 |
Note you have to adjust the the MT3608 output before you connect the load. While these generic boards generally work, the quality of the assembly can be a little variable, with dry joints or bent pins. A bent pin in the variable resistor can result in an output of over 20V!
There are quite a few inadequacies: the input 5V to the charger needs to be steady, between 7V-4.6V. Too high and the TP4056 will be damaged. Too low and it will fail to forward-bias the schottky diode and cause the load to be supplied from the battery which means the charger will not switch off and the battery may overheat with continous use.
This is a little problematic as a UPS is supposed to tolerate a wide variation in input voltages. In my case my 5V is supplied from a mains 5V 2A adapter which works for me. You need to re-test when you change to different input 5V sources or loads. In my case a Raspberry Pi Model B draws different loads depending on use of dongles; even plugging in the Ethernet connector will increase draw.
Happy Trails.