I am building a small project using an WEMOS ESP32 S2 mini and want to power it with an LiFePo4 for safety and efficiency reasons.
I want to keep using the built in USB port for charging and data communication.
But the problem is that the internal 3.3V regualtor, that steps down VBUS (5V USB) to 3.3V, will probably be overloaded if the battery is connected to it at a lower voltage and it tries to charge it.
With this circuit i want to make sure to disconnect the battery and charging board (TP5000) while USB power is present.
Does this usage of the two MOSFETS make sense? My thinking was, that if this configuration is used, no current can flow in either direction no matter what the charge level is.
Does this make sense? Or am I missing a way easier method to accomplish this?
No, I plan to use a single cell LiFePo4, so the voltage will be arround 3.2V and I should be ok to directly power the ESP with it, as some other forum posts suggested.
As far is I have found, it is common practice to power the ESP dev boards trough the 3.3V pin because this is how you can skip the internal regualtor.
I am aware of the overvoltage problem but the datasheet of the TP5000 indicates a cutoff at 3.6V which is also the max. that the ESP allows. But i know that this is taking a risk with 0 tolerance.
Doesn't make it correct.
I would say that it may be OK if you don’t currently have or plan to have anything connected to VBUS either on purpose or accidently and/or have USB connected or plan to have it conneced at the same time.
But connecting the USB was the whole purpose of this post. This is why I am trying to disconnect the battery the moment 5V is present at VBUS with the MOSFETs.
The big problem is that you are feeding a voltage into the output of the voltage regulator. What happens at VBUS (the input to the regulator) is undefined when you do that. You may well destroy the regulator when something is conneced to VBUS
If you want to be safe:
Don't connect anything to VBUS when 3.3V is connected
Remove any input to the 3.3V output before connecting USB
Only charge the battery when it is disconnected from the S2 mini
That is a question I can't answer.
Since the board will no longer be powered by the USB, I'm not sure if it will be recognized by your PC/laptop when plugged in.
Check out the Adafruit bqxxxx modules. There are a few of them and have the proper components for safe charging while using. There is NO good reason to use the output pin as Jim told you repeatedly.
You want make sure you don't charge your battery over 3.6V so you don't burn out your ESP. To be safe, I would only charge up to 3.5V and that is not possible with that board.
I disagree with the it won't work statement. The board design implements a separate voltage regulator that powers the board during charging with 3.3V. The cutoff for charging the battery is if 3.6V is reached.
After a battery is disconnected from the charger the voltage imediately drops a small amount.
Even if the 3.6V is surpassed by a few mV it will not be for long and this is also a private project that must not have huge safety margins. I tested my ESP and it continued to work even if 4V where present at the 3.3V pin.
But that is not needed. The official ESP opparating input voltage range is 2.8-3.6V so even down to 2.8V more than 95% of the usable capacity of a LiFePo4 cell can be used.
That sounds good - provided you actually test your project down to 2.8V. But also note that the rather oddball power path circuit feeds the battery output to the output of the then-unpowered AMS1117. So you will also need to test how much current flows back through the 1117 to ground when that happens. I would just say that there might be a better choice for that regulator, but that's just my bias because I hate the 1117.
The alternative would be to use a Li-ion or LIPO cell, but feed its output into the input of the regulator so that it would be regulated down to 3.3V in all cases. Jim and I have debated whether this can work, the main issue being the regulator's dropout voltage. But the Arduino MKR Zero schematic shows that setup. It uses the AP7215 regulator, which may be what's needed to make this work reliably.