Small UPS with fix 3V3/1A output and adjustable 1.3 to 12V output, Li-Ion charger and protection

Similar projects worth following
The charger has been designed for IoT projects. The device uses very little current in "sleep" mode. During active mode 1A can be delivered.


  1. Compact
  2. Powered by ubiquitous 18650 cells
  3. Option to connect Li-Po instead of 18650
  4. Including Li-Ion charger
  5. Charging while load is connected
  6. Charging options:
    1. USB
    2. 5V solar panel: up to 8V input should be accepted.
  7. Route VIN through : 5V output when powered by 5V
  8. Power input connector:
    1. USB micro
    2. JST-PH
  9. Outputs
    1. Primary output : 3V3/1A output
    2. Secondary output : 1.2V to 12V output, controlled by trimpot
  10. Efficient power conversion
  11. Low standby current
  12. Option to turn off outputs remotely to save power


Why make it when you can buy it?

  • TP4056, can be directly connected to solar charger
  • 3V3/1A created by 3 parallel LDO (77µA total quiescent current)
  • 5V/1.7A boost converter (260µA quiescent current).  There's no way to turn the boost converter off.
  • Not suitable to charge and discharge simultaneously.
  • Quite big

This one from AliExpress has only a 5V booster.

How much current is needed?

The original idea was to build a 3V3/2A supply.  But is that a good idea?  How many battery powered applications need a regulated 3V3 at 2A?  Sure we can build it, but it will be running at much lower currents for most of the times.  The efficiency at lower currents will be much lower.  The cost will be higher because of the bigger inductor and more expensive switcher.

1A will be enough for most applications, including the #easy-alarm-clock for which it has originally been designed.


Schematic, PCB assembly drawing + BoM for version R2

Adobe Portable Document Format - 163.00 kB - 08/20/2020 at 09:30


Portable Network Graphics (PNG) - 38.92 kB - 02/03/2020 at 19:53


  • Battery holder & PCB mounting

    Christoph Tack07/27/2020 at 19:53 0 comments

    It should be possible to mount the device easily.  There must be an option to connect two 18650 cells.

    MPD BH-18650-PC

    The battery holders below are through hole types.  The advantage is that it's easy to mount the PCB to a single or a dual battery holder.  These seem to be Chinese copies from the MPD BH-18650-PC battery holder.

    I think the battery holders below are designed for chargers, so that the battery can easily be removed.  There's no plastic on the side to keep the batteries in place.  The battery holders below might need a tie wrap to keep the batteries in place.  The MPD BK-18650-PC2 battery clip has been tested for shock and vibrations and is footprint compatible.

    Another disadvantage is that the through hole pins doesn't allow for the TP4056 module to be mounted on the edge of the PCB.

    Another disadvantage is that all components on the PCB need to be SMD types.

    12V UPS module from Banggood
    Simple way to connect a second 18650 cell

    Keystone 54

    Another option is to use the Keystone 54. It's an SMD type clip. Two are required per battery. They hold the battery firmly, but there's no plastic protecting the contact from accidental short circuits.

    Although the component is SMD, three through hole connections are required.  These make it impossible to mount the TP4056 module.

    Connecting a second 18650 battery can be done with a JST PH-header connected to the battery input of the TP4056.  The second PCB only needs the battery clips and the JST PH.  With a JST-PH to JST-PH cable, the batteries can then be connected in parallel.  There's more mechanical freedom to mount the batteries.

    Another advantage is that through hole connections can be made alongside the long edge of the PCB.  That might have been harder or even impossible with the through hole package.

  • DC-DC Conversion

    Christoph Tack07/27/2020 at 19:34 0 comments

    Buck, buck-boost / SEPIC or LDO?

    Buck-boost / SEPIC

    When looking at discharge curves from a Li Ion battery, it can be seen that at a battery voltage of 3V3, the battery holds only 15% of its original capacity.  There's little use in draining it further.


    An LDO that can deliver 1A at 3V3 will be bigger, more expensive and will have a higher quiescent current than buck converter.

    I plan to use it when the 5V is connected for a longer period of time.  The Li Ion would only be a backup power supply.  In that case, an LDO is really a no-go because of its low efficiency at 5V input.

    Buck converter

    If currents >1A are desired,  this will be a more efficient solution.  Both energy and cost-wise.

    • AP3429A

    Input surge/reverse voltage protection

    This will consist of a fuse and a TVS-diode.

    An SMD-fuse holder, holding a standard 2410-size fuse will be used.  Littelfuse sells these as there OMNI-BLOK 154 series.  Chinese knock-offs can be found on AliExpress.

    The TVS-diode should be able to dissipate reverse current or over voltage until the fuse opens.  An SMC (DO214AB) package can hold 1500W or 3000W types.  So there's room for experiment.  The TVS-diode will keep the input voltage below 9.2V, so we must be sure that the battery charger and the buck converter can also handle this.  The AP3429 only accepts max. 6V, so we'll have to add extra safety measures.

  • Component choice

    Christoph Tack05/18/2020 at 18:57 0 comments

    Battery protection



    Battery protection IC

    • AP9101CAK6-BVTRG1
      • UVLO = 2.8V (for uses where discharge currents > 3A)
      • over current detection : 100mV +/- 20mV
    • AP9101CAK6-ANTRG1
      • UVLO = 3.2V (for low power usage,)
      • Over current detection : 60mV (+21mV, -24mV from -40°C to +85°C)
    • FS312F-G : UVLO = 2.9V

  • Battery management

    Christoph Tack05/18/2020 at 18:42 0 comments

    Charger & protector selection

    A TP4056 charger & battery monitor module exists, but it takes up too much space.  So we'll implement it ourselves.  Some similar projects have been done:


    The TP4056 has a big package.  Other charger IC's are available on digikey (MCP73831, bq21040, STC4054). 

    • The STC4054 has the highest leakage current when no power supply attached. 
    • The MCP73831 only accepts maximum 6V, while the TP4056 breaks at 8V input. 
    • The bq21040 seems the best deal.  It provides max. 800mA instead of the 1A on the TP4056.  It's 20 times more expensive than the TP4056, but it won't be killed by an input voltage up to 30V.

    TP4056 module

    • TP4056 module GREAT WALL Electronics Co., Ltd., €0.28
    • TP4056 datasheet
    • TP4056 Micro-USB Battery Charger Circuit Diagram
    • 1A charge current, set by R3
    • Implements charge termination, as continuously trickle charging a Li-Ion-cell should be avoided.
    • When VIN < Vbat, the module will only discharge the battery with a 3.7µA current.  3µA of it is due to the battery protection IC.
    • Battery protection IC.  The undervoltage lockout (UVLO) is an important parameter.  When discharging a Li Ion with a 1A or smaller current, the battery has already lost 90% of its energy when the battery voltage drops below 3.3V.
      • Fortune DW01A battery protection IC.  Alternative battery protection ICs such as the AP9101C also require about 3µA.
        • UVLO = 2.4V (Do not use this chip!), It's not recommended to discharge a  Li-Ion-cell so deep.
        • AP9101CAK6-family is pin compatible.
    • Contains dual NMOS
    • Automatic charge termination
    • Can be directly connected to a solar cell (#155 The 5 Best Solar ChargerBoards for Arduino and ESP8266)
    • pin 7: ON = charging (LED closest to USB connector)
    • pin 6: ON = charging finished
    Proposed setup in a device
    Proposed setup in a device

    A power switch (such as this PMOS) is needed because the LiPo can't be charged while being connected to the load.  The explanation lies in the charging algorithm.  Suppose the voltage of the LiPo has dropped below 3V3, then the TP4056 will only allow 60mA on its output.  If a load is connected that draws more than 60mA  there will be no current left to charge the LiPo.  The LiPo will remain discharged forever (or until the load is disconnected).  More info can be found here.

    The efficiency can be improved by replacing the schottky diode by an NMOS, switched by an NPN-transistor.  The base of the NPN-transistor is connected to 5V through a voltage divider.

    Battery protector

    Charging a battery is one thing, protecting it from over-, under voltage, over current is another thing.  The TP4056 module includes a DW01A protection IC and a double N-MOSFET: FS8205A.

    TP4056 module including battery protection

    More info about this module can be found here.

    The DW01A has a too low UVLO limit, so we'll replace it by the AP9101CAK6-ANTRG1.  The MOSFET's TSSOP8 package might not be so easy to solder.  The DMG9926UDM will be used instead.  You could also use the FS8205, which is actually the same as the FS8205A except for the package.

    The over-current protection can be set by using the AP9101Cxxx-ANTRG1 or the BV-variant.  A factor two in current increase can be gained by putting several MOSFETs in parallel as done here.

  • Design R2 : improvements over R1

    Christoph Tack05/10/2020 at 18:14 0 comments

    Power input connector

    The only allowed input voltage is 5VDC.  R1 had a JST-XH connector, which left a lot of room for erroneous connections: higher voltages than 5V and reverse power connection.  If we replace it with a micro-usb connector instead (Amphenol 10118192-0002LF), then it's clear for anyone how to connect it, where to connect it to and what supply voltage it's using.

    I don't like to see a micro-usb connector as a user interface connector because it's quite brittle.  Luckily Sparkfun has us covered here.  There's a Panel Mount USB-B to Micro-B Cable for $2.50.

    By using the micro-USB connector, we could leave out the reverse polarity, over voltage protection and over current protection.  The USB 5V power source will have these protections built in.

    Extra buck-boost converter

    This allows an extra output voltage, up to around 12V.

    Power output connectors

    The JST-XH connectors are too big for this small board.  They have been replaced by JST-PH.

  • Testing revision R1

    Christoph Tack05/01/2020 at 15:47 0 comments

    Over voltage protection section

    The peak voltage over D1 is 9.2V, this would destroy U2.  To prevent this, an extra over voltage protection using U5 as voltage detection element and Q2 and Q5 as switching elements.

    Q2 and Q5 switch off when the input voltage rises higher than 5.28V.

    Applying 24VDC causes D1 to conduct, which trips the fuse FU1.  This is ok.

    To check if the circuit around Q2, Q5 works well, a voltage of 6.5V has been applied.  This is low enough to prevent D1 from conducting, but high enough to turn of Q5.

    Blue = voltage on C5. Red = voltage on gates of Q2 and Q5.  Notice that the red signal has a -100mV offset (I forgot to restore scope settings to default).

    There's clearly something wrong with this design.  Low voltage turn-on is quick due to U5 that starts conducting, but turn off of Q2 and Q5 is too slow.  This results in the voltage on C5 rising above the designated 5.28V.

    Decreasing R3 will speed up the discharge, but this design is inherently flawed.  Turning of Q2 and Q5 should be lightning fast to prevent damage to U6.

    Solving the problem

    Small rearrangement solves the problem
    The input voltage is 6V.  As the threshold of 5.3V is reached, the gate voltage of Q2 and Q5 rises fast, which turns them off quickly.  As a result the voltage on C5 doesn't rise above the 5.3V.
    Blue = voltage on gates of Q2 and Q5, Red = voltage on C5

    Charging section

    Charge current is set to KISET / RISET = 540 / 1K = 540mA.

    The Li-Ion cells I used were at the end of their lifespan, but they Initial constant current charging happens at 430mA.

    The red LED is on during charging.  After the charging process is completed, the LED turns off;

    Lithium Ion protection section

    After insertion of a Lithium Ion battery, briefly connect it to the charger.  This is needed to take the protection-IC out of Power-Down mode.

    Although I ordered the AP9101CAK6-ANTRG1 from Digikey, the auto-wake-up functionality, designated by the A, doesn't work.  After battery insertion, charger connection is needed.

    Over voltage

    • Measured : 4.25V
    • Datasheet AP9101Cxxx-ANTRG1 : 4.225V

    In case of over voltages, the CO-pin will go low.  Remark that this doesn't fully disconnect the battery from the load.  Discharging the battery is still possible.  A load connected to the battery will still be able to draw current from the battery.  The current will flow through the channel of the FET controlled by the DO-pin.  This FET is still conducting.  The current then follows its path through the body diode of the other FET, which is off.

    This is a useful feature, as it allows the battery to return to a safer state.

    In case of over voltage (most likely to be caused by over charging), when CO-pin is low, charging is no longer possible.

    Under voltage

    • Measured : 3.22V
    • Datasheet AP9101Cxxx-ANTRG1 : 3.20V

    In case of an under-voltage-event, the DO-pin will go low.

    Over charge current


    Over discharge current

    The circuitry has been connected to an electronic load.  Using the DMG9926UDM-7, the maximum current was 1.35A.  This is mainly because the AP9101Cxxx-ANTRG1 has a VDOC of only 60mV.  Replacing the battery protection IC by the BV-variant, would increase the maximum discharge current to 2.25A.

    3V3 buck regulator

    Efficiency measurement

    An electronic load has been used as load on the 3V3.  The board was powered using the thin wires from the JST-XH leads.

    Efficiency for powering the buck with 3.7V (Li-Ion) or 5V (USB) and two parallel inductors in the SMPS.

    Efficiency for powering the buck with 3.7V (Li-Ion) or 5V (USB) and three parallel inductors in the SMPS.

    Remark that if we had used an LDO instead of this buck regulator, we would have had 90% efficiency (theoretical maximum) for 3.7V input and only 66% efficiency (theoretical maximum) for 5.0V input.

    Ripple measurement

    For that we apply a...

    Read more »

View all 6 project logs

Enjoy this project?



Does this project spark your interest?

Become a member to follow this project and never miss any updates