Powering ESP32 with LIPO-which approach for this project?

the project is a conversion of an existing project to actually be wireless. this system is a digital read out for my lathe. Each of 3 scales (linear encoders) communicates its position to a dedicated esp32-wroom32. Those boards send that info to a parent board to be displayed. Parent board & display will remain plug ins. Its the child boards I want 3.7v lipos on. The scales draw 80mA + the esp32 @ 240mA max, probably want to call it 350mA total, to be safe?

On the charge side, I was thinking some prebuilt TP4056 based chips. Please advise if I should look at something different. Only question I have is, do I need to isolate the charging circuit from the "run" circuit with a switch or something? I read trying to charge whilst drawing from the battery can damage things. I dont need to keep using it when its charging, but I dont really want to power it off every time I charge, I'd loose all my positioning. Maybe there is a better charging chip out there?

Load side: from what I can tell, the two strategies for powering the esp32 from a 3.7v battery are:

  1. use an LDO to get within ~200mV or so of the batter voltage & apply it directly to Vcc.

    I need recommendations on chips here, I saw the MCP1700 used in an example, but its max current is 250mA, probably not enough.

  2. use a buck-up converter (mt3608 based?) to run the 3-4.2v battery up to 5, maybe 5.3v and then apply it to Vin, using the internal regulator just as I am now with the external power supply.

my thinking: the LDO approach is appealing in its simplicity and given the esp32 will run as low as 2.2v, it would probably run the chip fine. Problem is, my encoders are technically 5v(per documentation), I have tested them at 3.3v & everything seemed fine, but I dont know if they continue to operate under 3.3. On the other hand, the buck-up + linear regulator probably isn't very efficient

Really could use some expertise in choosing the best approach. This is my first battery powered attempt, and I'm not all that great at the rest of it as it is. I get it & I can put together the hardware, it just takes me ages. My head is kinda spinning after my internet dive that got me to this point.

Thanks for reading!

ps(edit)-- I would also like to monitor the voltages during use. nothing fancy, just enough to know when I need to recharge. Was planning on just a simple voltage divider into an analog pin, but I'm still open to ideas there.

LDOs that handle more current than the MCP1700 tend to also have higher dropout voltage. But you might consider using two MCP1700s in parallel to provide the additional current but still keep the low dropout. I've seen this done in several commercial circuits, but I don't know if it's an approved practice.

To have the charger properly terminate charging, you don't want there to be any load current flowing through the charger. The solution is the standard "load sharing" circuit, consisting of a P-channel mosfet, a schottky diode, and a resistor. It has the external charging source powering the load directly whenever it's plugged in, while charging takes place independently, if needed.

thank you for your helpful response. I didn't know that about LDO's. I think I can manage this circuit...only think I'm not totally understanding is that switch before the LDO? Is that just an on/off for the device, or am I missing something?

just for confirmation: so when you plug in a power supply, the voltage is used to trigger the mosfet and stop the output from the charge controller. Simultaneously, that charge line flows directly to the LDO to continue to power the device. have I got that right?

do I need to be concerned about what happens when the charge is full & the charger is still connected? I mean, I know I can unplug the charger, but is anything bad gonna happen if I dont get to it right away? I'd plan to put these on charge at the end of the night, so I wouldnt be there to stop the charge right away.

edit: I can get those mcp1700 's in a fixed (3.3v) or adjustable. both would work, about the same price, which one should I use?

Well, it's an on/off switch for the regulator and the device, but not the charger. It's the right place because it prevents wasting battery power in the regulator when the device is off, but with the switch off you can still charge the battery.

Yes. It's a P-channel mosfet, so when USB power is present, the gate is high, which turns off the mosfet. When USB is absent, the resistor pulls the gate to ground, which turns it on - so the battery can power the load. The mosfet lets you do this without producing the voltage drop of a diode, which makes the battery last longer.

No, the TP4056 will automatically terminate charging when the battery is fully charged. You can leave it connected to USB as much as you want.

If 3.3V is what you need, get the fixed version. It will save you from having to add two resistors to set the output voltage of the variable version. Those resistors are already inside the fixed version.

You'll need to add input and output capacitors to the LDO. Those aren't shown in the schematic I posted.

man, I get more out of a few paragraphs from a helpful person like you than HOURS of researching! Thank you.

That was all helpful & good news until the last line. still helpful, just inconvenient as I just placed my order and it was like $8 shipping on a $15 order! that irritates me. But I have loads of capacitors & old boards around, I can probably scavenge something.

There is an example circuit in the datasheet that shows a 1uF ceramic cap from vin --> ground and from vout--> ground. Is there a little wiggle room on that 1uF? if I had 5uF's, would that be an issue? Would any other type of cap work? I'm almost sure I have some tantalum caps in that size?

Thanks again for taking the time to help me! I'm primarily a metal worker & farmer. electronics is really out of my comfort zone.

I think for this regulator pretty much any type of capacitors will work, including tantalum. If you don't have 1uF, go with something larger rather than something smaller. And the input and output caps don't have to be the same.

I assume you are using a TP4056 charger module. If so, it is typically set to charge at 1A. What battery will you be using?

yes, I order the chargers as modules, save myself the fuss.

I have a bunch of single cell lithium batteries from an old set of phones we had. I had bought a bulk pack of them & most were never used. I've been checking them over the last few days, they appear to take & hold a charge**--using old phones to test this(me being a hoarder finally paying off!). I have at least 4 good ones right, only need 2 immediately. the battery # is B105BU, branded samsung. They are single cell, 3.7V lithium, 1800 mAH. 4 contact pad, +/- clearly identified, assuming the other two are probably a thermistor or other sensing circuit.

**oddly enough, 2 of the batteries initially measure 0v across the terminals, assumed they were dead, but I stuck one in a phone & it took a charge, all the way to 4.2V. Its been in the phone all day and battery seems great. I have a second one that also took a charge, but hasn't started load testing yet. That one was still in the packaging, so I know it had never been used...possible that was the case for the other one too, I dont remember.

@mtraven
From the MCP1700 datasheet:

The minimum VIN must meet two conditions: VIN >= 2.3V and VIN >= VR + 3.0% + VDROPOUT

Dropout voltage is defined as the input to output differential at which the output voltage drops 2% below its measured value with a VR + 1V differential applied.

VIN = 3.3 + 3% + 350mV = 3.4 + 350mv = 3.75V

That's more than your LiPo battery. Not a good solution

Well, first, 350mv is the maximum dropout voltage, whereas the typical value is 178mV. This is shown in Figure 2-12, which is for 2.8V regulated voltage. And we know that at 3.3V it will be less than that because Figure 2-13, which is for 5V, shows the dropout considerably lower at about 121mV. So typical dropout may be closer to 165mV at 3.3V. With the 3% additional, that would put minimum Vin at around 3.56V. And of course that's only the worst case at maximum current per LDO of 250mA.

And 3.7V is just the nominal voltage of lithium cells. They will fully charge to almost 4.2V, and at 3.56V will be mostly discharged anyway.

And if Vin does go too low, the LDO output will follow it on down. So while you might lose regulation, since it's battery power everything might continue to work ok down to 3.2V or 3.1V, or who knows how low.

So since this isn't a commercial product, why don't we wait and see how his LDOs and batteries actually perform before writing this off as a bad idea. My prediction is that it will work just fine.

I forgot to say - I don't know about powering the ESP32 with 3.3V directly. That may depend on what ESP32 version/module is being used. If it's normally powered at 5V, with a 3.3V regulator on board, then the concern would be what happens if you power with 3.3V at what is normally the output of that regulator.

I'm good with that. plus the comps are already on their way.

RE: direct power. its an esp32 Wroom-32 ..dev1...i think.

I thought this was an accepted practice. I know I've done this with an Arduino, never with a battery. But with a power supply into a linear regulator directly to Vcc.

but lets logic this out: if there is nothing connected to the input of the regulator (Vin), whats the concern? The output is gonna sit at 3.3v, just as it would have. maybe I need a diode or something to prevent reverse flow, but I've never done that before.

but then I dont know what happens if I DO apply voltage to Vin, directly(avoidable) or by way of pluggin in the USB? That wont be too frequent, but I do intend to tweak my system from time to time. Maybe I wire the battery in with a couple of jumpers that could be pulled to disconnect the battery for usb use, they could even be located to physically prevent plugging the usb in without disconnecting the battery. Hell, the esp32's are in sockets, I could just pull the modules when I need to flash them. although, I wouldn't be able to debug the system that way.

you think the jumper thing will work? I mean I know it works, I've done it before, but does it address your concern?

edit/ add: on the battery voltage topic. I'm testing one of those batteries in the phone it was for. Got 4.2V fully charged, phone reported 100%. Checked it just now, 3.87V with the phone showing 62%. More data points to come.

care to purpose a better one?

There have been quite a few forum posts on this topic or generically how to get 3.3V from a 3.7V Li-Ion battery. It's difficult because of the low dropout required (3.7-3.3 = 400mV) and may not be possible depending on the current you require.
The selection of 3.3V regulators in through hole packages is very limited. There may be a good surface mount device available, some only useful if If you are making a PCB, the others may be hand solderable, if you can do it.

Otherwise, most people wind up using a boost regulator to boost the 3.7V to 5V and go from there.
Are surface mount parts, in any package style acceptable to you?

@mtraven
The TPS79533D has a maximum dropout of 160mA @ 500mA
However, it's in an SOT223 package

Another is the MAX1857. Guaranteed Maximum Dropout = -137mV/V X VOUT(NOM) + 704mV = 252mV

The concern is that current would flow back into the regulator from the 3.3V pin and then out through the regulator's ground pin. There is always going to be at least a little of that kind of current. In fact there's usually a resistor divider inside the regulator that sets its output voltage, and current would flow through that to ground. But usually it's not enough to worry about. If your 3.3V regulator is a 1117 of some kind, like on an Arduino, then I don't think there would be a problem. In fact, I doubt it would be a problem if it's any kind of linear regulator. So take a look at your ESP32 module, and tell us what regulators it has. There should be a 5V and a 3.3V.

Then you would have the ESP32's 3.3V regulator competing with your esternal LDO. I don't think that would be a problem for anything downstream since the one with the higher output voltage would supply the load. There might be an issue of current backflow into the lower-output regulator. But I think that only becomes a problem with competing 5V regulators, one of which is fed from USB. That's not the case here. I don't think it will be a problem, but if it were me, I would disconnect the external LDO while USB is connected, which would eliminate any possible concern. If you can do that with jumpers, that would be fine.

Yeah, but you kinda need to be measuring voltage under the load your project will see. Your phone may not be drawing the same current as your ESP will when it's doing radio stuff.

yes, its got an AMS1117 doing the on module regulating. As far as I can tell, thats the only regulator on the board, no 5V. Read about it a little last night, most people seem to think there is no issue connecting a regulated 3.3v source to the output...they say the datasheet says it explicitly, but I find it somewhat ambiguous. either way, I think I'll be ok. If not, I'll smoke a chip & learn a lesson. I think I'll include the jumper disconnect, just to be safe.

re:batteries

this is my first battery controlled MC project, so I'm open to whatever you have to teach me there. But just so you know, I'm not using the measurements I'm taking to estimate how long they'll last on my system, I realize they are very different. My system in particular pushes the wifi HARD(to its max) at times. I have 2 objectives in taking these battery measurements:

  1. to test the batteries, just make sure they at least seem like they are good.

  2. establishing at what voltage the phone reports what %. I'll need this when I write the code to monitor battery charge. we are down to 30% @3.76V --seems like things are looking good.

2b--to see if my batteries charge & discharge schedule is roughly inline with what you outlined earlier.

any ideas on why I have batteries that measured 0.0v, but seem to have taken a full charge and now read 4.2v? I shouldn't look a gift horse in the mouth, but I really need to know why!

Thank you Jim, I will research those options tonight.

Before, when you laid out the math...I should have mentioned, the esp32 will run as low as 2.2V. 3.3 is just the target. I'm testing some cell phone batteries for this, I'm still at 3.76v with the phone reported 30% remaining charge. Does any of that information change your opinion of using the MCP1700?

I certainly thought about the buck up option you suggested, honestly it seemed like a coin flip, with the LDO option potentially being more efficient. Wouldn't surprise me if I had to do a 180 and go with that option.

as for surface mount comps: I ought to be able to manage. I have small tips & a reflow gun. As long as I can get them to somewhat line up a on perf board, I think its doable. Hell, the MCP1700's I already orders are surface mount, so I better be able to do it!

Since the maximum battery voltage is higher than the 3.3V your ESP32 will be running at, you'll need a resistive divider to make that measurement.

Edit: I think the ESP8266 only measures 0 to 1V on an analog read. However, some ESP8266 modules include a divider to reduce 3.3V to 1V.

The only thing I can think of is that your battery has protection built in, and the over-discharge protection had tripped. In that case, it would read zero volts, but wouldn't actually be zero volts. The negative battery terminal would just have been disconnected.

In your first post you said you had the ESP32-WOOM32
The voltage range is 3.0V to 3.6V
3.6V is the Absolute Maximum
FYI: the pin spacing on the parts I suggested is less than 0.1"

its WROOM32, but yah thats the right chip. and I hadn't thought about my specific chip when I said 2.2v. But in the copy of the the wroom32 data sheet I have, its listed as 2.7-3.6V (see attached screenshot)

But even if its 3.0, thats still 0.3v, with as close as the numbers you showed were, isn't that a critical 0.3v?