May 23 2013

A Lithium Battery Charger with Load Sharing

You may have found that charging your project’s lithium battery while at the same time trying to use your circuit didn’t quite workout, with problems like the circuit not turning on and the battery never finish charging. Even an LED can cause the battery to never finish charging.
This article goes through creating a battery charger with load sharing (also known as power-path) that can properly charge the battery and have the main circuit run normally. The charging IC we’ll be using is the popular MCP73831/2 from Microchip for single-cell Li-Po and Li-Ion batteries with a maximum charge current of 500mA. We’ll also be adopting the load sharing design from Microchip app note AN1149.


Issues when not using load sharing
During the preconditioning and constant-current charge phases the charger IC will limit current supplied to the battery and load. If this limit has been set to 40mA and the load wants 30mA, only 10mA will be left to charge the battery. If the load wants 50mA then 40mA will come from the charger and 10mA from the battery, which will discharge the battery rather than charge it. If the battery is already dead then the load will be starved of current, causing the voltage to drop, the load probably won’t operate correctly and the battery won’t charge.

During the constant-voltage charge phase the charger will normally wait until the current through the battery is below a particular percentage (usually 7.5% of the set charge current) and then finish charging. If a load is present the current will probably never go below this level and charging will never seem to finish.

Charger IC variations
There are a few variations of the charging IC, MCP73831/2 means MCP73831 and MCP73832. The only difference between these two is the charging state output (STAT pin).

Charge state MCP73831 MCP73832
Shutdown Hi-Z Hi-Z
No battery present Hi-Z Hi-Z
Preconditioning Low Low
Constant-current fast charge Low Low
Constant voltage Low Low
Charge complete – standby High Hi-Z

There are also variations which set how the battery is charged in relation to when and how long to precondition, fast charge and so on. AC, AD, AT and DC are the 4 types. The AC type seems to be the ‘normal’ type that is used in the IC datasheet. More information about each charging phase can be found in the app note above.

Basic charge circuit
This design is the minimum required for the MCP73831/2 to charge a lithium battery (well, R1 and LED1 could also be removed), but problems will arise when charging and connecting a load to the battery, as discussed above.

Charge circuit with load sharing
Adding load sharing only requires an additional 3 components. When USB power is applied this circuit will turn off Q1, and as long as (Vusb – D1 VF) is above (Vbat – Q1 VSD) then the load will instead use power from USB through D1. This allows the battery to charge normally without any outside disturbances.

Q1 is a P channel MOSFET. When USB power is applied Q1 will turn off and stop current flowing from the battery to the load, effectively disconnecting the battery. The load will then use power from USB through D1. The MOSFET you choose should have as low RDS(on) as possible to minimize power loss, should be able to handle the current your circuit is going to draw from the battery and has a VGS(th) between 0V and -2.4V.

D1 is to prevent current flowing from the battery into the charging power source. D1 should be a schottky diode that can handle the loads’ maximum current draw. The forward voltage drop doesn’t matter too much, but lower the better to reduce power loss when powered by USB. The absolute maximum drop is (VINmin – (VBATmax – VSD) = VFmax), the USB 2.0 standard specifies 5V±0.25V, most lithium batteries charge to 4.2V and internal MOSFET diodes have a drop of around 0.6V, so (4.75 – (4.2 – 0.6) = 1.15). This maximum forward voltage drop is so the source (load side) voltage of Q1 doesn’t go below the drain (battery side) voltage, otherwise the internal diode of Q1 will begin to conduct which will interfere with the battery charging. Reverse current leakage of schottky diodes might be a problem if ultra low power consumption is needed.

R2 is to make sure Q1 turns on and connects the battery to the load when the charging power source is removed.

C3 is an extra decoupling/bypass capacitor.

Another important point to think about is the reverse leakage current of D1, which could be up to a few hundred microamp (schottky diodes are very leaky).
This leakage current will create a small voltage at the MOSFET gate which, if high enough, could cause the MOSFET to not turn back on properly when the main Vin power is removed.

To see if Q1 is turning on properly place a voltmeter across Q1’s drain and source pins and it should read a few millivolt depending on load and the MOSFET’s on resistance, e.g. with a load of 100mA and RDS(on) of 50mΩ then the voltage drop should be 5mV.

To minimize the gate voltage you can either use a diode with lower leakage current (which will also improve battery life) or reduce the value of R2, or a bit of both.

To figure out what value R2 should be to keep the gate voltage to a sane level (lets go for a Vtarget of 1V) we first workout the effective resistance D1 has at the batteries’ max voltage:
Our example diode has a leakage (IR) of 200uA @ 4.2V (you can find leakage info in the datasheet for your diode, or you can measure it yourself by applying a voltage backwards across the diode and measuring the current).

RD = VBATmax / IR
RD = 4.2 / 0.0002
RD = 21KΩ

So now we can treat D1 and R2 as a voltage divider, we just need to workout what value R2 should be so that the voltage at the MOSFET’s gate meets our Vtarget.

R2 = Vtarget * RD / (VBATmax – Vtarget)
R2 = 1 * 21000 / (4.2 – 1)
R2 = 6.56KΩ

So when using a diode with a leakage current of 200uA @ 4.2V, R2 must be no more than 6.56K to keep the MOSFET’s gate at 1V. I’d recommend not going over 100K for R2.

This also means D1 and R2 will be leaking a total of 152uA from the battery (I = VBATmax / (RD + R2)).

It’s probably a good idea to do these calculations for VBATmin (around 2.4 – 3V) too.

Charge circuit with load sharing and additional microcontroller
Here’s an even further modified charge circuit. A microcontroller can be used to sense when USB power is applied, when the battery is charging, enable/disable charging, control charge rate and measure the battery voltage. This information could be displayed on something like an LCD.

Pin I/O Pull-up Info
PD3 (5) Input Enabled Charger STAT pin sense. LOW means the battery is charging.
PD6 (12) Input Disabled When USB power is applied this pin will go HIGH.
PD4 (6) Output Controls charging.
PD5 (11) Output Controls charging.
PD7 (13) Output Setting to HIGH will turn the level shifter and Q3 on which will allow current to flow through the divider. Once an ADC reading has been taken this should be put back to LOW.
ADC3 (26) ADC Measure voltage. Internal 1.1V should be used as the reference voltage.

Charge rates

Q2 Q5 Charge
Off Off Disabled
On Off 100mA (10K)
Off On 370mA (2.7K)
On On 470mA (2.7K || 10K = 2.126K)

R2 and R3 voltage divider also serves as R2 100K pull-down resistor for Q1 in the first load sharing schematic.

Only the MCP73832 should be used in this case, using MCP73831 will drive the STAT pin HIGH with 5V when the battery finishes charging which will exceed the microcontrollers’ max pin voltage of VCC + 0.5V (2.5 + 0.5 = 3V max).

loadShare_20140613.c (3.68 kB)
Load sharing code example
Downloaded 1331 times
MD5: C50476A4F66D332D6DBD29BEC05D13B4

loadShare.c (2.71 kB)
Load sharing code example
Downloaded 1185 times
MD5: 2D0DC4BCC9047756554131EBCE4773CF


  • You should make sure your circuit can run on the full voltage range of the battery (usually 3V-4.2V, but sometimes down to 2.4V) as well as 5V from USB.
  • You should make sure that your charging power source can supply enough current to charge the battery as well as power the circuit.
  • When charging at high currents be sure to have large enough PCB traces to dissipate the heat from the charging IC. Heat comes from the ground pin (VSS).

March 9th 2014 – Added info about D1 reverse leakage and working out required R2 resistance.
June 13th 2014 – Updated microcontroller schematic to use more suitable BJTs instead of MOSFETs (cheaper, easier to find). Also added adjustable charge rate.


3 pings

Skip to comment form

  1. Felipe

    my name is Felipe and I have a question.
    I need use the MCP, but I need put a resistor between VBAT pin and Bat pin. Because this resistor, I am having problems with charge. The current of charging is lower than the ideal.
    You ever had this problem?

    1. Zak Kemble

      Whats the reason for having a resistor between VBAT and the battery?

      1. Felipe

        I will use my electronics in an environment with flammable gases. Is a norm in Brazil use this resistor.

        Sooner, I saw problem with my current of charge, its lowering very fast, in 15 minutes go to 150 mA, when my prog resistor is configured to 300mA. I need solve it before. I no have capactors in my charge circuit, after add I return with notices.


        1. Zak Kemble

          Hmm, well, you won’t be able to get more current through the resistor unless you reduce the resistance or increase the voltage, but increasing the voltage would be a bad idea. The charging IC is not designed to have a resistor in series with the battery.

  2. Petr

    Hi Zak,

    I am trying to understand MOSFETs and I’ve got some issues understanding your load sharing schema: the Q1’s Vgs starts from -0.3 V (from its datasheet) and we use Schottky with say 0.4 V forward voltage drop (you compute that it can go as high as 1.15 V!). Now when the USB power of 5 V is attached then the gate has say 5.00 V and the source has 0.4 V less (because of the D1 voltage drop), i.e. 4.6 V. That means the Q1 switch is closed because Vgs is -0.4 V (thanks to the D1). When the switch is closed the current flows from USB directly to battery and destroys it. That’s first issue. Now say we disconnect the USB, the Q1’s gate voltage is zero then. The Q1’s source voltage is unknown, it’s probably flying somewhere because it’s connected to the load only. But the load can have low input resistance so we may suppose the voltage of Q1 source is zero as well. Now the Q1 is open (because Vgs = 0 V) thus the current from battery cannot flow to the load. That is the second issue.

    I probably missed something crucial but in my eyes this schema cannot work both with and without the USB power connected. Please enlighten me, thanks in advance!

    1. Zak Kemble


      2 problems: You’re doing an extra step when working out Vgs and forgetting about the internal MOSFET diode.

      When working out the Vgs, you only do Vgs = Vg – Vs (5V – 4.6V = 0.4V (not -0.4V)). That means the P-MOSFET is open/turned off when USB power is applied.

      When USB is disconnected, with a high or low load resistance, the MOSFETs internal diode will conduct and the source voltage becomes Vs = Vbat – Vf (4.2V – 0.6V = 3.5V). Then Vgs = Vg – Vs (0V – 3.5V = -3.5V) which will close/turn on the P-MOSFET and bypass the internal diode.

      1. Petr

        Oh, the Vgs error I made is obvious, thanks for correcting that. As for the MOSFETs internal diode – I indeed haven’t realized it can be used for passing the voltage from drain to source (all usual schematics connect voltage to source, not drain, you know 🙂
        Thanks a lot for the explanation!

        BTW, the Vgs can be as low as 2 V (for almost discharged battery) so we need a MOSFET with a rather low Vgs threshold, right? I suppose those with min 2 max 4 V Vgs(th) (like IRF9450) cannot be used for this. I’ll need to find a smaller one than I have here.

        Could this load sharing be done with a N-channel MOSFET by any chance? I have a bunch of those handy… 🙂


        1. Zak Kemble

          No problem 🙂

          A LiPo/LiIon battery should never go as low as 2V, that makes it a dangerous battery. Absolute minimum should be 2.4V, but no less than 3V is preferred.
          Vgs(th) of the IRF9450 is a little too high, it might work, but the Rds will be quite high. An N-MOSFET could probably be used, but not as a replacement, a complete circuit redesign would be needed.

          1. Petr

            FYI, the Vgs as low as 2 V is true for battery with about 2.6 V (I subtracted the Vf already) which is indeed slightly less than the preferred LiPo/LiIon voltage but still quite possible. The Vgs(th) of the Q1 should definitely be lower than 2 V.

            I am searching for a P-channel MOSFET with low Vgs(th) on Ebay now. Pity the AO3401 in SOT-23 are not easy to solder on universal PCB…

          2. Zak Kemble

            Ah I see. FDD6685 might be OK, it’s in a larger SMD package so it shouldn’t be too hard to solder some wires to it. All the good stuff are SMD these days.

  3. Tarun

    After building this circuit, I think the MOSFET in the schematic is backwards. Source should go to VBAT, Drain should go to output.

    1. Zak Kemble

      No, if it was wired like that then there would be a short from USB to the battery; current will pass through D1 and the internal diode of the MOSFET into the battery.

      1. Daniel

        It looks backwards to me too. The mosfet will conduct whenever the gate voltage is lower than the source voltage right? so when Vin is not connected, wont both the source and the gate voltage be 0 causing the fet to stay in the “off” position?

        1. Zak Kemble

          When the MOSFET is off and Vin is removed the MOSFETs internal diode will conduct, bringing the source voltage to the battery minus the internal diode drop. If the battery is at 4.2V the source will be around 3.6V, meaning Vgs will be -3.6V causing the MOSFET to turn on and bypass the internal diode.

          1. Daniel

            Ok so when Vin is plugged in and the mosfet is off, would current still flow from the battery through the internal diode?

          2. Zak Kemble

            No, because the voltage at the source will then be higher than the battery voltage, blocking any current through the internal diode.

          3. Daniel

            Ok that makes sense, Thanks!

  4. Lili

    I have built this circuit and tested on both veroboard and a PCB. I have a problem when the USB is unplugged that there is a small (~0.5V) voltage that appears on the USB pin. I was wondering what causes this? I am using the same components as shown in the charge circuit with load sharing image.

    1. Zak Kemble

      The small voltage is caused by the reverse leakage current of the schottky diode. It’s nothing to worry about since available current is so small (<1mA).

  5. Dustin

    Hello, Was curious if you could use this chip for say 2 cells in series? I’m wanting a 2 cell rechargeable battery pack that can be plugged into usb when needing to charge as well as turn on off when there is a load present.

    1. Zak Kemble

      No, the IC only supports single cells. If the cells are in series then you will need a voltage booster since USB is only 5V and 2 cells go up to 8.4V.

  6. vpapanik

    Zak, thanks a million for your excellent article on load sharing. This detailed info was surely missing from the AN1149 application note 🙂

    I am using the same concept for my designs too, you can also check the PMV32UP P-Channel MOSFET from NXP, almost same low Rds, cheaper price.

  7. vpapanik

    … and PMV16UN for the N-channel.

    I just saw your AVR setup too. That’s an excellent design, well done. I would really appreciate if you could answer some questions I have, that would help me a lot.

    a) for extra input protection, maybe a reverse-biased 2.5V zener diode should be connected to the output of the R2/R3 voltage divider. I know that USB power is already protected but who knows… however, in the case of an external (e.g. wall) 5V source I think it is essential.

    b) are R4 and R8 and R10 really essential ? I see them in some designs, not in others, and I cannot really understand their purpose on limiting current to a MOSFET gate.

    c) is it possible to use the same P-channel MOSFET for Q2 and Q4 by putting it above R1 and R9, respectively ?

    Thanks a lot again !

    1. Zak Kemble

      Though PMV32UP and PMV16UN don’t have any ESD protection (the 2 back-to-back zeners between gate and source). I like the extra protection 😛

      For anyone reading this, we’re referring to DIY Digital Wristwatch.

      a) If the USB voltage goes over 6V (max pin voltage is VCC + 0.5V so 3V) R2 will limit the current a fair bit. I don’t think it really needs the extra zener. You could instead change the ratio of the 2 resistors, 56K and 39K would work at 5V and be able to go up to a little over 7V before the output goes over 3V, but by then you’ve probably damaged the charger IC since its absolute max is 7V.

      b) Well, MOSFET gates are like little capacitors. When turning them on and off you need to charge and discharge them and with no resistance you’ll get large, but short, current surges which can damage stuff over time. Gate resistors can also be used to reduce ringing and EMI.

      c) (I guess you meant Q3 not Q2, since Q2 is already a P-MOSFET. LS1 instead of R1 and R8 instead of R9)
      No, Q3 and Q4 can’t be P-MOSFETs. The purpose of Q3 is to level convert the controllers’ 2.5V output up to the battery voltage level so Q2 can be turned off. You’d have to use the same level conversion technique with Q4 if you change it to a P-MOSFET.
      MOSFETs need to have their gate voltage at close to its source voltage to turn off, the source voltage for Q2 and Q4 (if it was a P-MOSFET) would be whatever the battery is at (3V – 4.2V) and 2.5V from the controller wouldn’t be enough to turn it off.

      1. vpapanik

        Thanks a very lot Zak, for your prompt answers, everything is perfectly clear. As far as the MOSFETs are concerned, the extra protection feature is really important so I am thinking of buying some strips of them too !

        In my last question I was referring to the microcontroller setup you are showing on this post (not in the wristwatch post), so we were talking the same thing 🙂 I have a few questions on the wristwatch schematic as well and I will post them there. Your help is mostly appreciated !

        1. Zak Kemble

          Lol oops, I had completely forgot about that part of the post >.< Though Q2 and Q4 still need to stay as N-MOSFETs because the 2.5V from the microcontroller won't be able to turn P-MOSFETs off.

          1. vpapanik

            Yes, absolutely true 🙂 You’ve been mostly helpful for me to understand those MOSFET secret details !

            I also looked at the similar DMP2035U part from Diodes, same price, better max VDS (-20V) and lower RDSon (23 mOhms).


          2. Zak Kemble

            They can only handle a few amps so a few mOhms isn’t really going to make much of a difference. I’ve been using DMG6968U and DMP1045U just because I’ve brought a load of them so at the moment they’re my small-general-whatever-use-them-for-anything MOSFETs 😀

  8. Marcello

    Hello there. I need to charge two Li-Ion batteries that are both powering a device; I was already planning and building a circuit with 73831 when i came upon your “addendum” and thought it’d be very useful. I only have to modify the circuit a little, and i was wondering if you could tell me if it is right or not. Since i have to charge two batteries i simply doubled the 73831 part including the MOSFET, so that every battery (slightly different in mAh and wear) would charge independently. The only thing i didn’t double is the final part with D1, R2 and C3 cause it would be redundant. Basically it’s a twin charger circuits, meeting at the MOSFET sources to power the device. Do you think it could work?

    1. Zak Kemble

      Your idea should work for charging, but I’m not sure about discharging. One battery might end up charging another at an uncontrolled rate (especially if you partially charge the batteries so they’re all at different voltages), adding a diode just after each MOSFET source should fix that. Actually, if you add the diodes then there’s no need for the MOSFETs since they’re only acting as super low voltage drop diodes.

  9. Marcello

    You’re right, but now I realized my problem is slightly different: since the device’s pcb is already being powered by Vcc when its jack is connected, what i’d need is only to disconnect the batteries while they’re being charged. I thought of simply removing D1, cutting off the direct power-to-load; there shouldn’t be problems about +5V going to the load since there’s no flow of current through the MOSFET, am i right? (but i’m keeping C3 and R2).

    1. Zak Kemble

      D1 is to stop the battery from keeping the MOSFET turned off when VCC is removed, if the MOSFET is always off then it will just act like a normal diode because of the body diode.

      1. Marcello

        I know, but i meant to remove D1 entirely along with its line, because I don’t need the load to be powered directly by Vin. I only need Q1 to stop the battery powering the load, my only doubt is: would there be some current going to the load when Q1 shuts the battery?

        1. Zak Kemble

          Ah right, yes, current will pass through the MOSFETs body diode to VCC because there is no higher voltage to block it (normally from D1). A second P-MOSFET after Q1 with source connected to Q1 source, drain to VCC and gate to Vin should fix that, though.

          1. Marcello

            Uhm, but in this case i’d have a double voltage drop from the battery.. alternatively i found a minirelay laying around, i’ll see if i can use it, wish me luck..
            Anyway, thanks for your time.

          2. Zak Kemble

            The MOSFETs will only have a few millivolt drop, they turn on when Vin is removed. Though a relay would work too 😛

  10. Jan Rychter

    Thanks for the great article. I wish I had this when I was starting my design — it would have saved me a lot of time.

    I’m curious — in the microcontroller circuit, why did you use Q2 and R4? Wouldn’t the microcontroller’s open-drain output serve effectively the same purpose? Were you worried about the current? From what I understand from the MCP73831/2 datasheet, we’re looking at around 500µA out of the PROG pin, so this should not be a problem I think?

    1. Zak Kemble

      R4 is because the gate of a MOSFET is like a small capacitor, there will be large current surges when turning the MOSFET on and off, the resistor limits the current to a safe level. Though really, since the MOSFET isn’t going to be switched often and the DMG6968U gate capacitance is only 151pF it’s probably OK to remove R4.
      Q2 is used because of the ESD diodes giving a max pin voltage of VCC (2.5V) + 0.5 = 3V, setting the pin to High-Z will connect the PROG resistor to 2.5V via the ESD diode and you’ll still get current passing through. If the controller is running without the regulator then it should be OK to remove Q2 and just use the controller output.

      1. Jan Rychter

        Right — the body diodes. I always forget about those. Ok, I understand now. Luckily for this transistor Rdson doesn’t really matter, so a really cheap one like a BSH111 (5Ω Rdson) should do fine.

        Thanks for explaining!

  11. Milan Adhikari

    Hello Zak,

    Thanks for the article its really good one to read when someone is starting with such design. I have a concern about powering the load. Now we are powering the load with 4.2V but what do I have to do in order to provide 5V to the load? Do I have to step up 4.2 V to 5V?

    1. Zak Kemble

      Yup, you will need a 5V boost converter like NCP1402.

  12. Hiren

    Thank you for the idea.

  13. Roy

    Hi Zak,

    Why not use a diode instead of Q1. No current will go into the battery, from the USB input, because this voltage level is higher than the charge voltage of the battery charger. What is the disadvantage in doing this using 2 diodes instead of a diode and a FET?

    Nice explanation of the circuit itself.


    1. Zak Kemble

      Diodes have a relatively large voltage drop. When the MOSFET turns on current will bypass the diode, so instead of the ~250mV drop of a Schottky diode you get ~3mV drop of the MOSFET (assuming 30mΩ Rds and 100mA).

  14. Bernhard

    Hello Zak,

    Thank your for your excellent article. I was searching for ages on the Microchip Website because it was missing some part like the MCP73831 only with an extra disable or shutdown input. I also came to the solution using a MOSFET on the PROG pin. Since I am no Expert on MOSFETS I startet searching and found your blog.

    My Question is: Why not skip R10 and Q4 and connect R8 directly to the gate of Q3. My guess is that this might cause a current to flow from Bat+->R9->PD7->body diode->VCC->R2->R3->GND?

    I am planning to use this for a LPC but I guess the principle with the body diode is the same.

    Best Regards,

    1. Zak Kemble

      Yup, the battery voltage will pass through the MCU internal diodes and kind of fight with the 2.5V regulator trying to bring it up to battery voltage, but not much bad stuff will happen because of the limited current through R9. Also because of the diode and everything the gate voltage will probably be clamped at 2.5V + diode drop, so you’ll end up with around 3.2V at the P-MOSFET gate which won’t be enough to turn it off (3.2 – 4.2V = -1Vgs). R2 and R3 aren’t touched.
      Q4 is to level shift the 2.5V up to battery voltage so the P-MOSFET can turn off. Removing the 2.5V regulator will mean you don’t need all the level shifting stuff since everything will be at the same level.

  15. Eric

    Great write up. Confirmed a plan I had in mind for using p channel MOSFET for source switching.

    Question: when the battery is charging, I just want the load circuit turned OFF, not powered by usb. To achieve this, I can simply omit the wire from usb to load (and the Schottky diode), right?

    1. Zak Kemble

      Yup, but you will also have the swap the drain and source of Q1 so current doesn’t go through the internal diode to the load.

    1. Zak Kemble

      That would be correct.

  16. vpapanik

    I would like to thank you once more, especially for the new diode leakage current section !

    I couldn’t explain the relatively large (1.1V) gate voltage I was getting, now it makes perfect sense 🙂 my load sharing circuit is now fine tuned thanks to this brilliant post.

    The only issue that I found is that the charging led remains on when the battery is not connected 🙁 however, I can live with it, since I have no idea how to turn it off in that case.

    check also my implementation of a magnetic switch (for the regulator that goes after the load sharing circuit), you may find it helpful for new projects : https://www.youtube.com/watch?v=zG1mUlXUgnc

    1. Zak Kemble

      Good to hear 😀
      That magnetic switch looks pretty interesting, could definitely be useful.

  17. vpapanik

    Nah, sorry, forget the last thing, I found it : it’s because of the voltage divider for sensing battery voltage which pulls VBAT to ground when the battery is disconnected…


    1. Zak Kemble

      That, and the capacitor is like a very small battery, you’ll probably find that the LED is actually turning on and off very fast as it charges the capacitor then it discharges through the divider.

      1. vpapanik

        Is it possible to go for larger resistor divider values (20K/68K) ?

        1. Zak Kemble

          Since it’s just the battery voltage being measured (not a fast changing signal) you could try 1M + 1M with a 100n capacitor in parallel with the bottom resistor, though high value resistors will pick up noise like from touching the middle of the divider with your finger.

          1. vpapanik

            I will !

            Now, when the magnetic switch is off, the battery consumes 100uA on the switch IC itself, another 50uA on the 20K/68K divider, and something more is unexpectedly leaking to the ADC input (MCU is turned off). Not bad, but it can be better.

  18. João Ferreira


    I would like to use this circuit to power a automatic watering system. But instead of being powered via USB or AC adapter, i would like to use a solar panel as voltage source.
    I was thinking in a 5v solar panel, but my concern is about current. If the battery is charged and the watering system is in off state, the solar panel would be constantly trying to send current to the system, right?

    1. Zak Kemble

      Current can’t be pushed into the system, the system decides how much it wants. It’s the voltage you need to check, but I haven’t used solar panels much so I’m not sure how they behave.

  19. Khue

    Hi Zak, thank you for this tutorial. I wasn’t sure before about the load sharing part of the circuit I needed to add. I’m trying to build a power supply for a 3.3V microcontroller. The power supply will be able to take an input of either 120VAC or 5V-18VDC. I have my schematic here: http://imgur.com/ACvB1Yk . In LTSpice, 3.3V out when there is a power input, but when I disconnect input power to the Battery Manager, my output is way lower than 3.3V. Do you know what’s wrong?

    1. Zak Kemble

      I don’t think LTSpice simulates the MOSFET body diode for Q1 unless you manually add it in. The body diode is needed to get the MOSFET to turn on, without it Vgs would be 0V and the MOSFET would stay off.

  20. Marc Singer

    Nice post. It has been very helpful.

    FYI, I implemented your design using an ON-Semi NTLJF3117P which is a small package containing both the p-fet and the schottky diode.

    One of my goals is to reduce the current of the system when it is idle. My hunch is that if I increase the pull-down on VBus that the leakage current won’t really change. The voltage on VBus when there is no USB power will, but not the current. Is this right?

    1. Zak Kemble

      Glad you found the post useful 🙂 The NTLJF3117P schottky already has very low leakage, about 600nA @ 4.2V (equivalent to a 7M resistor). A 50K pull-down results in 29.79mV @ 595.74nA, doubling it to 100K results in 59.15mV @ 591.55nA. So yeah, voltage pretty much doubled but current didn’t change much. Because of the already very low schottky leakage the pull-down resistance doesn’t really have much effect unless you start going into the megaohms range (but then the MOSFET could turn on from noise etc). You could use a less leaky normal diode instead of a schottky, the part about D1 mentions that you can have a drop of up to 1.15V across the diode if the supply voltage doesn’t go below 4.75V.

      1. Marc Singer

        I’ve been staring at the datasheet for the 3117 for some time and I don’t see the numbers you’re showing. Are you reading the graph? Is there another source for this information?

        1. Zak Kemble

          I’m looking at this graph http://www.onsemi.com/pub_link/Collateral/NTLJF3117P-D.PDF Page 7, Figure 15. Typical Reverse Current

          1. Marc Singer

            You threw me with ‘@4.2V’.

            I’m seeing 0.03v on Vbus with a 44K pull-down and a battery voltage of 4.175V. This makes the leakage 680nA and the equivalent resistance be 6.1MOhm.

            Your eyes are keener than mine.

  21. Marc Singer


    I’ve been trying to understand your comment about ‘sane gate voltage.’

    With Vbus, Vg is VBUS and Vs is VBUS – Vf of the diode. Vgs is going to be positive which will guarantee that the FET will be off.

    With no Vbus, Vg is going to be Vleak=Ir*R2 where Ir is the reverse leakage current through the diode and R2 is the Vbus pull-down. Vs is going to be close to Vbat depending on Rdson and the forward drop in the body diode, but the conductance of the fet is going to be much more efficient than the body diode drop once the fet is on. So, worst case Vgs is Vleak-(Vbat -Vf) which is going to be dominated by the battery voltage unless Vleak is really high.

    I think your comment is about making sure that Vleak isn’t so high that it competes with Vbat-Vf. So, when you say a target for Vg is 1V you are saying that you want it to be no more than 1V. Even at Vbat of 3V, Vgs will be at least -1.6V when Vg is 1V.

    IOW, the sane gate voltage is being evaluated when there is no Vbus. Yes?


    1. Zak Kemble

      Yup, everything you wrote there is correct, although the Vleak calculation is a little off – example 10uA leak and 1M pull-down ends up at 10V.
      The ‘sane gate voltage’ is for when Vbus is removed and ‘target voltage’ would indeed mean ‘no more than’.

      1. Marc Singer

        Sure. As the pulldown is weakened (value of R2 increased) then Vg approaches Vs and eventually the fet won’t turn on when Vbus is removed. I think that for the case where Vg < Vs, the calculation for for Vleak is a reasonable approximation.

  22. itanium

    Can I use AO3401 for Q1?

    1. Zak Kemble

      Yeah, an AO3401 should work fine.

  23. Andrew Hannay

    Hi Zak,
    I used lithium-ion charging for the first time on my last project (DIY Game and Watch -> http://www.instructables.com/id/DIY-Game-Watch/). I didn’t have problems with load sharing as I designed the software to have an auto shutdown so it drew very little current (5uA) and could charge without any problems.
    On my new project I want my circuit to stay active and it will draw somewhere in the range of 6mA which will be enough to stop the charger from shutting down hence why I found your excellent description explaining how you deal with it.
    Now, I had come up with a much simpler idea but I wanted to run it buy you to see what you think.
    The USB supply is 5v and I would take this to the charging IC and to my circuit via a diode like you have, which will give me a voltage of around 4.3v to 4.4v. I would connect the charger to the battery as normal, but then from the battery I was going to have another diode going to my circuit which would give a voltage of around 3.5v to 3.6v (4.2v – diode drop) while the battery is charging.
    I was thinking that this would mean that the battery would not supply any current to my circuit as it’s voltage would be lower than the voltage coming from the USB (less the diode drop). Would this work or would I end up sharing the current between the USB and the battery?

    1. Zak Kemble

      Nice looking project there 😀
      Yeah, your idea will work. The main purpose of the MOSFET in my design is to get rid of the diode voltage drop, there’s still a diode from battery to main circuit since it’s part of the MOSFET, but the diode is bypassed when the MOSFET turns on. You can also remove the pull-down resistor since that’s just to make sure the MOSFET turns on when USB power is removed.
      As long as the battery voltage minus diode drop is less than the USB voltage minus drop then no current will be drawn from the battery.

  24. Andrew Hannay

    Cheers. I simulated it online just to confirm it worked, which of course it did, it just seemed too simple 🙂

  25. Frank

    Hi Zak,

    Thanks for the awesome tutorial!
    I’d been playing with something similar but without succes and I now understand why it wasn’t working.

    I was wondering if you happen to know of any compatible through hole mosfets as an alternative to the DMP1045U-7?

    Any advice would be much appreciated!

    1. Zak Kemble

      Through-hole P-Channel MOSFETs with a low enough Vgs seem to be quite hard to find, though these should be good for up to about 1A – FQPF27P06, SPP15P10PL, NDP6020P

      1. Frank

        Thanks so much!
        Just ordered a FQPF27P06 for testing.

      2. nico

        In the datasheets


        I see that all mosfets you mentioned can handle > than 10A… Am I reading something incorrectly or why would you say “up to 1A”?

        1. Zak Kemble

          Hey Nico, up to 1A because the Vgs can be as low as 2.4V (Vgs will be at whatever voltage the battery currently is), which is not enough for much more current without a significant voltage drop across the MOSFET. See the On-Region Characteristics and Output Characteristics graphs in the datasheets.

          1. nico

            Oh of course, you’ re right. Thanks for clarifying.

            Well, it would be too good to be true but, maybe introducing a regulator between the battery and the drain?
            The would also allow for a MOSFET with higher VGS, right?
            But would it interfere with other aspects of the design leading to breaking?

          2. Zak Kemble

            Yeah you could add a boost regulator, but don’t boost the voltage too much (try to keep it at 4.2V) otherwise D1 won’t conduct when USB power is applied and you’ll end up drawing power from the battery while it’s trying to charge. See the first paragraph under the load sharing schematic and the paragraph about D1.

  26. JCB

    can i to flip the mosfet(source conected to battery and dreno conected to load), and replace D1 with a 3,8V LDO regulator with reverse current protection…
    because i need the voltage of charge from 3,3 to 4.2V


    1. Zak Kemble

      That won’t work. The orientation of the MOSFET is very important and shouldn’t change, you’ll end up damaging the battery if it’s wrong. Just stick the regulator on the output of the load sharing circuit.

      1. JCB

        But i have a problem.
        I need 3,8V on my load, and when battery is supplying the load the 3,8V LDO regulator don´t work.. The BUCK/BOOST regulator is very expensive to my project.
        Do You have a suggestion?

        thanks for your attention

        1. Zak Kemble

          If you must have 3.8V then you will need a boost of some sort since the battery voltage can go down to around 3V. A buck/boost is kinda expensive as you say, so you could use just a boost to up the voltage to 4V or so then use a 3.8V linear regulator after the boost.

          1. JCB

            Thanks so much ZAK

            I will search for a nice boost and LDO

  27. JCB

    Hi Zak

    Can i insert a diode between pin 4 of MCP and the mosfet gate?
    I want to reduce the voltage on load when the supply is conected.

    thanks for your attention

    1. Zak Kemble

      It would be best to swap out D1 with a diode with the voltage drop you want (or multiple diodes in series if 1 isn’t enough). Make sure the total voltage drop doesn’t go above 1.15V, see the section about D1 on working out the max drop.

  28. chris

    I’m a beginner, so my question might be a bit odd 😉
    Can I use an other DMP1045U instead of the D1 diode? Drain connected to VIN, Source to VCC and Gate as well to VIN.
    To avoid the voltage drop of the diode and at the same time, make sure no (only minimal) current flow to the USB input in case it is running on battery?

    1. Zak Kemble

      Nah, I see what you’re trying to do, but it won’t work in this case 😛
      Vgs needs to be less than about -1.2V to turn on, but with USB connected it will be 5V – 4.2V = 0.8V, meaning it will be off. And then when USB is removed it’ll turn on because 0V – 4.2V = -4.2V!

  29. Gokku

    Hey Zak,

    thanks a lot you tutorial and answers are awesome.
    I want to use the shematic for powering a Raspberry Pi. So I need 5.2 Volts at the output and I will need arround 2A because I have a touch panel. So my question is when I use a USB adapter everything is fine because Raspi gets the supply via the wall adapter. But whe I plug off the suplly Raspi gets suplly from Battery and only 4,2V right? So I need a booster no? is there any booster which can handle 2A (or little more) and still gives out 5.2V?

    1. Zak Kemble

      Yeah, you’ll need a boost regulator for the battery since it outputs 3V-4.2V. You could try this one – http://www.aliexpress.com/item/J35-Free-Shipping-DC-DC-Boost-Converter-3V-Up-5V-to-9V-2A-USB-Output-Voltage/32338265996.html It’s adjustable so be sure to measure the output voltage before connecting it to the Pi.

      1. Gokku

        ok thanks a lot. i have ordered one of these: adafruit powerboost 1000 basic
        which should also work.

        I ordered the same Mosfet which you use in your shematic and the MCP73831. Now I bulded up the shematic….but it doesnt work.

        How can I measure the Mosfet? without any supply it should be “open” between gate and source/drain and “closed” between drain and source no? or cant I measure without any supply?

        Can I add my EAGLE files somewhere?

        Thanks a lot again.

        1. Zak Kemble

          Put your multimeter into voltage mode. When the battery is attached and USB is disconnected the MOSFET should be closed/have low voltage drop (less than 0.1V) across the source and drain and open/larger voltage drop (more than 0.5V) when USB is connected.
          Google “file host” and upload the EAGLE files to one the websites.

  30. Diya Dinakaran

    Please clarify; whether the wiring of Q1 (as per the component symbol) is right or wrong ?

    1. Zak Kemble

      All diagrams and symbols in the post are correct.

  31. nico

    Hi zack,
    Thanks for your info about the “load sharing circuit”.
    I’m also going to build the circuit. I have just one question about the D1 diode.
    I have to set the voltage for the load to 4.2V max during the normal operation (when the main
    power supply at 5V is connected) since my load works from 3.4 to 4.2.
    I see you use the B130law and ,reading the datsheet , it gives me 0.38V of forwad voltage.
    This gives me 5v-0.38 =4.62V which would burn my load.
    I dont want to use any step down/up conversion since my load works perfectly between 3.4 to 4.2 V (lipo at 3.7V will power it when main DC power fails)
    Could you please suggest wich diode I can use or maybe add to the circuit ?
    The current of the load is 1A max.

    1. Zak Kemble

      You could put multiple diodes in series, but you also need to make sure there isn’t too much drop otherwise the internal MOSFET diode will begin to conduct preventing the battery from fully charging. You should also measure the voltage drop at the loads minimum current, as the drop goes down as the current goes down, at 10mA the drop will be about 0.17V.
      An easy, but not very efficient way that could work would be to use a zener regulator/clamp just before D1.

  32. nico

    Ok ZaK,
    Thanks for reply. I thing I should put a DC-DC boost converter and I found one from Linear Technology (LT3759).

    About the kind of battery to charge : I’m going to charge a Lipo 2200mAh since I want about 1A in both case (load under Main power or battery ). Do you think there’s a limitation with this circuit?
    thanks a lot again

    1. Zak Kemble

      This load sharing with the LT3759 should be fine with 1A, though maybe swap D1 for a diode with slightly higher current rating otherwise you’ll be pushing it to its max.

  33. Neo

    Hi Zak,

    Thanks for the nice blog. I have one question, is it safe to connect STAT directly to the MCU I/O pin? Should there be a resistor in between to prevent from possible over current? Especially the high state of MCP73831 is 5V.



    1. Zak Kemble

      Hey Neo, the MCP73832 (two) either pulls the STAT pin LOW or leaves it floating, it doesn’t get connected to the 5V supply rail. Connecting the MCP73832 STAT pin directly to an I/O pin is safe. MCP73831 (one) STAT will need some level conversion, a single current limiting resistor is not the best idea as it will still try to pull the MCU 3.3V rail up to 5V, a voltage divider or transistor would be better.

  34. Diogo

    I have one question, see if you can help me

    I would like to use this circuit in a Arduino Project that uses a 3.3V microcontroller that I will build standalone.

    It’s necessary in the end of the circuit to build a Voltage Regulator? Or I can connect directlly in my microcontroller.?

    Thanks Diogo

    1. Zak Kemble

      Hey Diogo, you will need a regulator as the charging circuit can output 5V when charging or up to 4.2V when running from the battery.

  35. Lucas

    What happens when you are out of USB power, and the battery voltage gets too low?
    This circuit has cut down voltage?

    1. Zak Kemble

      No, there is no undervoltage protection in this circuit, the battery should have that built-in to it.

  36. Boyd Roberts


    Can this c code be modified to upload to Arduino? If not, how do I get the c code onto the chip?

    The are many AC varieties on the microchip website. Which one is recommended? Thanks.

    Everything else should be a piece of cake!


    1. Zak Kemble

      Hey Boyd, yea the code be modified to run on Arduino, you will need to change the PORT write stuff to digitalWrite(), PIN read stuff to digitalRead(), printf to Serial.Print() etc…

      Which AC variant to use will depend on what IC package you want and the charge voltage of the battery (4.2V – 4.5V). You probably want the SOT-23 package and charge voltage of 4.2V, so that’s the MCP73832T-2ACI/OT.

  37. danny

    Hi Zak

    I have the mcp73831en a circuit for making environmental parameters, but a sound is perceived when charged using the solar cell.

    help me please

    1. Zak Kemble

      This Lithium charger is only designed for a steady 5V supply, which a solar cell won’t be able to provide. You’ll have to come up with some completely different circuit.

  1. DIY Digital Wristwatch | 物联信息

    […] battery charging circuit uses a Microchip MCP73832 along with some additional components for load sharing, where the battery can charge without the rest of the watch interfering with […]

  2. Digression #2: PiMony, a smart remote prototype | The Pithesiser

    […] Power supply: Adafruit PowerBoost 500C with 2500mAh LiPo battery and load sharing circuit. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Are you human? *