# Using battery and USB power at the same time

I'm trying to make a Li-ion battery control circuit. I would like to be able to charge the battery via USB and power the load (at 5V) at the same time.

I know how to make a circuit that disconnects the battery from the load using a MOSFET and powers it only from USB (something like http://ww1.microchip.com/downloads/en/AppNotes/01149c.pdf).

However, with this approach (if I understand correctly), plugging a USB cable connected to something that can't supply enough current (eg. 500 mA when 1 A is needed) would still switch off battery power completely.

How can this be avoided? The ideal scenario for me is that in this situation the load is powered from both USB and the battery. If such a circuit is very complicated, simply ignoring the USB power and supplying the requiered current solely from the battery would still be OK. I will be powering a Raspberry Pi, so I would like to avoid a sudden current (or voltage) drop.

I found some load sharing ICs on the Internet, but they are designed to drain equal current from two loads, which might not be the case here.

I hope my question isn't stupid, I'm an electronics newbie :)

Linear LTC4067 is your solution. It will "add" both the battery load and the power supply together. the example below is taken from the LTC4067 datasheet. If you install the "optional" mosfet, you will get on OUT both the battery load and the USB load.

• You need to add more to this to make it a useful answer. Add a schematic to explain what you mean and discuss how this solution would work. Till then, this isn't a very useful answer unfortunately
– MCG
Nov 27, 2018 at 8:50

In the case of the application note, you could replace Q1 with another diode, then the load would draw power from which ever source has the higher voltage, or from both if they are at approximately the same voltage. But note that this circuit doesn't provide 5V output or any voltage regulation for that matter. If nothing is plugged in you would get the battery voltage (~4V), if USB is plugged in you would get about 5V, and if the AC adapter is plugged in you would get whatever voltage that provides (minus the diode voltage drops).

You mentioned charging, and 5V output, so you might need a separate charger IC, as well as a boost regulator (assuming you use one LiPo cell) to get the 5V output. There are some devices that have such capabilities combined, such as the LTC4090 device. It will take a battery, USB input, and even another high voltage input, charge the battery, and give a 5V output (in the case of the LTC4090-5 device).

Doing this is very hard and probably not worth the effort.

First up, it is very difficult to measure the amount of supply current.

What you can do is measure the voltage level of the supply rail, this voltage will dip when the supply current is exceeded. However calibrating this will be difficult, some supplies will just provide low or noisy voltage levels.

When you do find a weak supply you will need to switch to being purely battery sourced, otherwise you will be back feeding the battery and explosively bad things will happen. You will also need to clearly communicate this state to the user somehow, being battery powered while plugged in is a non-intuitive state.

Most devices solve this problem by just not working when underpowered, a common Raspberry Pi issue. Users fairly quickly learn that the weak power supply and device won't work together.