Making a PCB that can use LiPo and LiFePo4 batteries

I have an ESP32 project in mind and I want to design the PCB in such a way, that depending on the parts soldered, it can bei either powered by a LiPo or a LiFePo4 battery and of course also over USB. Besides powering the MCU with 3.3V, a boost circuit supplys other sensors with 5V.

Case: LiPo, no USB
If using a LiPo, the voltage needs to regulated by an LDO to 3.3V and another connection goes to a boost converter to output 5V.
LiPo, USB Connected
If USB is connected, the LiPo should be taken off the supply for the load. The 5V USB should go to the 3.3V LDO and also to the boost circuit. In the boost circuit I hope it just passes the diode and inductor and the boost circuit doesnt do anything else since it already has 5V.

Case: LiFePo4, no usb
For this battery, the current should go straight to the MCU, not going through a regulator. This is recommended in many articles and should work fine, as long as it is not charged over 3.6V. It should also go to the boost circuit to 5V.
LiFePo4, USB connected
If the USB is connected, the battery should be taken off the circuit since no 5V should never enter the battery. The 5V USB should go to the 3.3V LDO and regulated down. Similar to the LiPo circuit, the USB should also go to the boost circuit hoping it wont do much with it but pass it through the diode.

Goal:
The goal is that I have as few components and traces as possible while the circuit works as described.

First Ideas
Load sharing systems have been used quite often lately, but I havent seen them working with two battery types.
The idea is that once USB is connected, the gate of a p channel mosfet turns off the connection between the battery and the load.
I opt for two load sharing circuits while soldering only the one for the specific battery, not knowing if that would really work. There are also some solder bridges in the circuit to take that part completly off everything depending of the battery chosen.

I would really appreciate if someone could look at my circuit and tell me if that makes any sense / could work, or if I should do something different.

It might work, but I'm not sure it's a good idea.

You may find (as I did when testing ESP8266 modules) that a significantly higher current is drawn at voltages higher than the intended 3.3V, which will reduce your battery life. Using a 3.3V LDO regulator, the circuit may draw less current overall, even taking into account the regulator's quiescent current.

Hopefully you are already aware that not all LDO regulators are the same and some have a much higher drop out than others, but they are still called "low drop out". Quiescent current can also be significantly higher in some than others, so check the regulator specs in the data sheet carefully. For example, AMS1115 and MCP1700 are both described as "low drop out" but if you check the actual drop out and quiescent current from the data sheets, you will see how much difference there is.

Myself, I would get the breadboard out and test both the options.

There are a few things that a straightfoward 'is my design OK' question might not pick up.

As well as the issues mentioned by @PaulRB, there is the problem with the high current pulses consumed by an ESP32 when WiFi or Bluetooth is used causing resets, some regulators cannot cope with them.

And then when presumably the PCB is completed you might find the sleep current is a lot higher than wanted.

You both have very valid points. I just want to notice that my problem currently mainly is, how I can design a PCB that can use either a LiFePo4 or a LiPo battery in a safe way, depending on the soldering I do on the PCB.
The disadvantages of the batteriess itsself, like battery lifetime or current draw, aswall as if it makes sense to do so instead of designing to different PCBs, is a different topic.

I will test the current draw between 3.0 and 3.5V with a bench power supply, thanks for noticing!
With a LiFePo4 battery it will be hard to use a 3.3V regulator on its own. Already at 80% state of charge, it will have a voltag of 3.3V and the regulator will not work anymore. So I would have to boost the LiFePo4 to 5V and then regulate it to 3.3 with the LDO or use a SEPIC circuit. Connecting it to the ESP32 directly seems like the better option for me

The one I used in the schematics has a dropout voltage of 238 mV max, typically around 150. That is as low as I could find and good for a LiPo, but not the LiFePo4. They always need to have a higher input (+ dropout voltage) than the output and that does not work very well with the LiFePo4 voltage range.

I would have to buy all the components in a trough hole design AND in the very small SMD footprint.
I planned on testing it on the PCB and wouldnt be too angry to fix it and order another one afterwards, but still want to ask before ordering to not waste too many ressources and also to discuss and learn about the whole electronics topic :slight_smile:

Is that specific to my circuit or a general point? The LDO would be only used with the LiPo. And the LDO I chose is commonly used with LiPos and should be fine.
The LiFePo4, will be directly connected to the 3.3V input pin, it should not have too many problems with the steady output at current spikes.

But how is that exactly?
I mean, in general, many people use the ESP32 with batteries. Some with LiPo, some with LiFePo4. While the LiPo has a high energy density but loses some through the regulation of the LDO, the LiFePo4 has a low energy density but can supply the board directly and loses less energy. I got the point of @PaulRB but have not seen that in any tests so far. Most people report a very low current draw. But actually, even if it draws more current, I still want my project in a LiFePo4 version because it feels safer to me.

What I am more concerned it the safety of the circuit. I have been working on the circuit for weeks now. Every time I thought I finished it, I found a path that energy could flow back to the battery that should not be. It is only a very small part of the whole project, which will drive sensors, small 5V motors (150mA) and so on, but it seems like the most important thing that I should be confident before ordering and soldering it

The regulator will not stop working. But it's output voltage will drop below 3.3V. I have noticed that my ESP8266 circuits continue to operate ok until the discharge protection circuit for the Li-po/li-ion batteries cuts off at around 2.8V. So the ESP is probably working down to maybe 2.6V output from the LDO.

That would be much less efficient. Boost converters have high quiescent current and maybe only 80%~90% efficient. After that, the LDO will waste much of the power reducing it back to 3.3V because it will be only be ~66% efficient.

Maybe look for a boost/buck module that will produce 3.3V output over an input range of around 2.5V to 5.5V. For example

The DC-DC power module is automatically raised or lower to support the shutdown function. The maximum input voltage is 15 VDC, the quiescent current is less than 200uA.
The fixed output is 3.3V / 5V /12V and the maximum output current is 0.17 A.
Work frequency is up to 1.2MHZ, high stability, cost-effective, all industrial-grade components, long working voltage drift-free, suitable for demanding applications, mass production.

On drop down menu can choose what output you need: (Please pay attention what is on packaging numbers show what is the output voltage)

  • 3.3V -X12909
  • 4.2V -X13011
  • 5V -X 12910
  • 9V -X13012
  • 12V -X13013

Did you say you had components that need 5V? Replace those with 3.3V equivalents if you can.

Which regulator are you using?
So far I have read that it is not recommended to use an LDO with lower input than output voltage, since the behaviour could be "unexpeceted"

But why? Why use a converter at all if you can just connect the LiFePo4 to the ESP directly?
And using an external module would not be very pleasing when designing a PCB.

So since the question is how it is possible to have solder places for the two battery types on the PCB but using only one: is your recommendation to not use the circuit shown in my schematic but instead of the 3.3V LDO use a buck/boost circuit that puts out 3.3V?
I would see the disadvantage here that the LDO is only really usefull if the PCB is using a LiPo, with the LiFePo4 the circuit needs (in my opinion) to connect the battery directly and not through a LDO or buck/boost circuit with energy loss

Yes, there are some that have to be 5V and cannot be replaced, unfortunately.

This would not work, the ESP alone needs 500mA

Mostly the regulator built in to Wemos D1 mini.

Also I have used MCP1700 and HT7333 with atmega328.

No, it won't need that much. Except in very short pulses. The average current consumption will be much lower I think. A large capacitor should help to deal with the short pulses of high current.

I have found that Wemos D1 mini consumes around 80mA average current when connected to WiFi, around 20mA when not connected to WiFi, and around 200uA in deep sleep. I would expect ESP32 to be similar.

Battery protection is maybe the biggest issue: they have a different minimum voltage, at which your circuit should cut out. If that cut-off is set to LiPo level, your LiFePO4 isn't of much use; and if set at LiFePO4 level you would destroy your LiPo battery. Unless you rely on battery protection circuits built in the cells itself.

You will find many parts are not available in THT. However you can get breakout boards for all standard SMD footprints, such as a board that effectively turns an SOT-23 into a TO-220 footprint.

If your regulator can do 500 mA peaks you'll be fine. The rest of the peak can be handled by the decoupling cap.

When running motors I'd get a lot less worried about shaving off a few µA of quiescent current...

Those do need a boost circuit; those are indeed notorious for high quiescent current. Look at a boost circuit with an enable input, or a way to switch them off (probably needs a high side switch on the power input of the booster).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.