# What happens when a LIPO drops under 3V? WeMos in DeepSleep doesn't start up again?

I have a Lipo (18650) which is charged by a solar panel (6V/6W + TP4056 charger). It's feeding a WeMos D1 Mini which is put in DeepSleep every 10 seconds. When it's awake, it sends something to Blynk. By connecting pin D0 to RST it works perfectly, until the voltage of the battery gets too low (< 2.8V).

The WeMos doesn't wake up at all after that. I have to manually reset the WeMos, then it works again.

I also noticed the battery doesn't get fully charged after the WeMos is 'dead'?

Sorry for my basic explanation: I'm really new to the world of ESP8266...

As far as I understand, the voltage regulator is automatically used by using the 5V-pin. I was using the 3.3V pin, but I changed it to the 5V pin. All is working OK for a few hours.

Andreas Spiess recommended the TP4056 charger in one of its great videos. Normally it handles the charging of the LiPo and the power of the Wemos. I'm using the TP4056 with protection, so normally it protects the battery from damage (?).

In other posts people suggest to attach the Wemos directly to the battery, while the TP4056 is handling the charging of the battery. But it wasn't clear if they are using the unprotected or protected TP4056.

I'm monitoring the battery by connecting it to the A0 pin and reading the RAW-values so I know the battery voltage. I can test it in software and if it gets too low put it in an endless deepsleep (esp.deepsleep(0)) but this will not wake the Wemos when the battery is charged again.

Maybe this is a solution?

https://www.sparkfun.com/products/10617

The SparkFun LiPo Fuel Gauge connects your battery to your project and uses a sophisticated algorithm to detect relative state of charge and direct A/D measurement of battery voltage. In other words, it tells your microcontroller how much ‘fuel’ is left in the tank. The LiPo Fuel Gauge communicates with your project over I2C and an alert pin also tells you when the charge has dropped below a certain percentage.

But again: Will this restart the ESP8266 when the battery is filled again?

• Does the energy coming in exceed that demanded or required by the WeMos ?If not, then you will always get a flat battery.... – Solar Mike Sep 12 '18 at 10:27
• The WeMos requires 3.3V but the battery and the TP4056 charger gives it when fully loaded 4.2V... – Bart Sep 12 '18 at 10:32

It looks like your WeMos embeds a voltage regulator, do you use it? Or put it another way, which pin do you use to power the WeMos, the "3V3" one or the "5V" one? The voltage regulator input is connected to the 5V pin, and its output is connected to the 3V3 pin and the ESP8266.

In any case, the ESP8266 input voltage must be between 2.5V and 3.6V according to the datasheet (table 5-1 p18). You should use the 5V pin because your battery voltage can be as high as 4.2V and you will probably kill the ESP8266 if you power it directly without the voltage regulator. However, a voltage regulator can only lower the voltage, not raise it, and will always have a small dropout voltage usually around 300mV. This means that when your battery voltage falls below 2.8V, the ESP8266 input voltage falls below 2.5V, outside of its specs, and its behavior becomes undefined. I've had the case in the past with microcontrollers "freezing" or acting strangly with bad input voltage because it caused execution errors that the CPU couldn't recover from, so I'm not surprised that you need a manual reset. If the ESP8266 freezes into a state where it draws lots of current, this can also prevent your battery from charging.

In any case, it is usually not recommended to drop a LiPo below 3V. I guess the best answer to your problem is an UVLO (under-voltage lockout circuit) which will disconnect the battery when its voltage falls below 3V. I usually go for a LMS33460 3V voltage detector together with a MIC94083 power switch for this purpose. You could also try to find another battery with a PCM (Protection Circuit Module, the small board hidden in the orange tape on the end of the battery) that cuts at about 3V, such as this one from Adafruit (look at the batteries datasheets).

Also, keep in mind that if you directly charge the battery while the WiMos is still powered on it, the current consumption of the WiMos might interfere with the charging algorithms of the TP4056. Usually, some kind of power multiplexing circuit is required. This can be as simple as adding a wire and a diode, see how Adafruit does it on their HUZZAH board (top left corner) : the battery is connected to the regulator through a diode, and the +5V coming from the USB is connected both to the charger input and the regulator input. When a USB charger is plugged in, the diode will be blocked by a reverse voltage (5V > 4.2V), effectively disconnecting it and allowing the regulator to charge it cleanly. The downside is that you substract the diode's drop voltage to your useful battery voltage. By the way, if you want to make your circuit simpler, you might consider replacing your WeMos with a HUZZAH which has everything builtin.

• Thanks for your insights! As far as I understand the voltage regulator is automaticaly used by using the 5V-pin. I was using the 3.3V pin but I changed it to the 5V pin. All is working ok since a few hours. Andreas Spiess recommended in one of its great videos the TP4056 charger. Normally it handles and the charging of the LiPo and the power of the Wemos. I'm using the TP4056 with protection so normally it protects the battery from dammage (?). In other posts people suggest to attache the Wemos directly to the battery while the TP4056 is handling the charging of the battery. – Bart Sep 12 '18 at 19:41
• Maybe this is a solution??? sparkfun.com/products/10617 "The SparkFun LiPo Fuel Gauge connects your battery to your project and uses a sophisticated algorithm to detect relative state of charge and direct A/D measurement of battery voltage. In other words, it tells your microcontroller how much ‘fuel’ is left in the tank. The LiPo Fuel Gauge communicates with your project over I2C and an alert pin also tells you when the charge has dropped below a certain percentage." But again: will this reastart the ESP8266 when the battery is filled again? – Bart Sep 12 '18 at 19:45
• @Bart the battery gauge will not help you with your problem, it will just tell you a more precise estimation of the remaining battery capacity. Look at my updated answer for more information. – Foaly Sep 12 '18 at 20:35
• Ok Foaly, I understand about the LiPo Fual Gauge. In that case I made it myself by connecting the battery and a 100K resistor to the A0-pin. – Bart Sep 13 '18 at 7:55
• About my project: it's now running with the LiPo connected to the 5V pin of the WeMos. I changed the deepsleep time from 8 seconds to 10 minutes. This way the battery can deliver a much longer time the power it has to deliver. And in daytime it can be charged by the sunpanel. This doesn't answer the problem: what happens when the voltage drops too low but it is a start. In the meantime I will look at your suggestions: a lot of information for a beginner like me ;-) But I will try what you suggested or search on the net what it is all about. Thanks again! Greatly appreciated! – Bart Sep 13 '18 at 8:06