How to add a LiPo battery in our Arduino projects11/10/2019
In the next Bike Pixels version I want to integrate a rechargeable battery so you don’t have to rely on an external power source. In principle, this might seem trivial, but it’s not. Lithium-polymer batteries (or LiPo) are dangerous if they are incorrectly charged, overcharged, overheated or stored incorrectly they can explode. Luckily to make things easier for us and allow us to use a LiPo battery in our Arduino projects we have several modules that can do some of the work for us. One of these modules is the TP4056.
TP4056 module specs
The main element of the module is the TP4056 chip itself. This chip is a programmable linear current and constant voltage charger for single cell LiPo batteries. The module also integrates two LED indicators of the state of charge and two additional chips in charge of the protection of the battery. Although there are versions of the module that do not have these chips, in this case we will use a version that does have these elements like the one described in the image.
The module performs the charging process. First it ensures a constant current until the LiPo battery reaches 4.2V. Then, it gradually reduces the charging intensity until the battery is fully charged and ends the charging cycle when the charging current drops to one tenth of the programmed value. It supports input voltages up to 8V so it can be used directly connected to a USB port or a mobile charger up to 1.2A.
| Charging |
By default it is programmed to charge batteries with an intensity of up to 1Ah although it is possible to reduce this value by replacing resistance R3 with one of a higher value. If you use batteries with a capacity close to 2000 mAh or higher you can leave the resistance used by default, otherwise it is necessary to modify it.
Typically LiPo batteries have a maximum charge and discharge current value of 0.5C, i.e. we can apply a charge current less than half its capacity. Using higher currents can reduce battery life or even destroy it. Therefore, depending on the maximum intensity of intensity that we can use in our battery it will be necessary to modify the resistance R3 by one with the value that adjusts to the intensity given in the adjacent table.
In addition, the TP4056 also guarantees the safety of the battery. The DW01A chip is designed to protect from damage and degradation of LiPo batteries due to overcharges, over-discharges or current peaks. On the other hand the FS8205A is a chip with a double MOSFET. It is responsible for cutting the power supply to the battery when the charge is complete and prevent its discharge if its voltage drops below 2.7V. A lower value can shorten its life and even render it unusable.
Apart from the TP4056 module, we obviously need a LiPo battery and an Arduino board or a clone. In addition, as Arduino boards normally work with a voltage of 5V, it is necessary to add a voltage regulating module to increase the voltage of the LiPo battery. For the example I have used a Pololu U3V12F5 which is more expensive but very small and also very efficient offering up to 1A output. Anyway any step-up module that converts the LiPo battery voltage to 5V and provides a current around 500mA will do. Furthermore, unless we want our Arduino to be on until the battery is completely discharged we will have to add a switch to be able to turn it off and on when we need it. Next I leave you a list with different links to stores where you can buy all these elements:
|TP4056 module||(10pcs) $9.99||(10pcs) $2.00|
|Step-up 5V||(5pcs) $7.29||(5pcs) $1.80|
|LiPo battery ~2000 mAh||$9.89||$3.69|
|Arduino Nano||(original) $13.00||(clone) $2.45|
|On/Off button||(50pcs) $5.99||(20pcs) $0.64|
|Cable AWG 26 (0.13 mm)||(7×32.8ft (10m)) $16.99||(6×32.8ft (10m)) $13.38|
As you can see for just a few bucks, not including the price of the battery we can have Arduino running on a LiPo. But, I repeat, you have to be very careful with it when connecting all the elements.
Luckily the connection is quite simple. We just have to connect the battery and the step-up module together with the switch to the TP4056 module. Then you will only need to connect the output of the step-up module to the Arduino board. This requires the step-up module to be connected to the ground and 5V pins. Note that normally it is not recommended to use this port but as in this case as the voltage is regulated by the step-up module we can use this port without danger. All the connections look much clearer in the diagram below:
In addition, if we upload to the board the code that makes blink the integrated LED, after connecting all the elements we can test directly if everything is in order. In my case, after soldering all the elements I have something like this:
As you can see including a LiPo battery our Arduino projects is quite simple and cheap. The only limitation is in the maximum intensity supplied by the step-up module. In projects that require higher intensities this solution may not be adequate.
Other similar modules
On the market there is a lot of other modules that are similar to the presented. Usually all the cheapest solutions are based on some TP chip (TP4056, TP5000, TP5100) and include some less (eg. without battery protection) or extra features (eg. integrated pull up module). Among this I also have been working with this module based also on the TP4056 with an integrated pull-up circuit and it worked fine.
If you want to know more about each of the chips that make up the TP4056 module, below I leave a series of links with the cards of each of them:
Additionally if you want to continue with more advanced project, recently I’ve added a new post that adds a solar panel to this project in order to charge the battery using solar energy.
Of course if you have any doubt, found any fault or want to purpose a possible improvement do not hesitate to leave your comment at the bottom of this post. Also, if you want to stay in touch or receive any news from us don’t forget to signup to the newsletter.