📜 ⬆️ ⬇️

About tasty and healthy food ESP8266 from batteries

Many of those who make different things on ESP8266, at some point thought that it would be great to take that thing, put it in my pocket - and go for a walk with it. ESP8266 is so small, and asks. And here on our way there is a small obstacle - programming is not enough here, you have to take a soldering iron in your hands, but everything is not so bad, and I hope this article will help you.

The datasheet on the ESP8266 indicates a supply voltage from 3.0 to 3.6 volts, which, in principle, allows the ESP8266 to be powered directly from two AA batteries or one lithium 1S battery. If we are not very important stability and neat behavior of the device when the voltage drops, or do not mind the lithium battery, you can do with this, otherwise we face some questions.

Voltage conversion


In most cases, the battery voltage will be higher than the 3.3 V we need, and it will noticeably change as the battery discharges, so we need to lower it and stabilize it. The first thing you need to decide is whether we want to power the rest of the circuit from the stabilized voltage, or can be directly from the battery. The necessary current given by the voltage regulator depends on it. ESP8266 itself needs a maximum of 200 mA, throwing a little on top of the capacitor charge and other unexpected expenses, we can assume that 300. Sensors often like stable voltage, and powerful actuators are often better powered directly from the battery.

Next you need to decide on the type of regulator, there are two options, each with its own advantages and disadvantages - a linear regulator, or pulse.
')
Linear Voltage Regulator

The linear regulator, in fact, is a controlled resistor, on which all the “extra” voltage drops and is dissipated in the form of heat.

Advantages of a linear regulator:

The most common variant is a type 1117 microcircuit, produced by many manufacturers, usually produced in several versions on a line of fixed output voltages, among which there are always 3.3 V - for example, AZ1117C-3.3 manufactured by Diodes Inc.

image
Fig. 1. Typical wiring diagram for linear regulator type 1117

What you should pay attention to:

The disadvantage of the linear regulator is not very high efficiency, which strongly depends on the difference between the voltage on the battery and the output 3.3 V. This difference is uselessly dissipated by the regulator in the form of heat. If the device is powered by three AA batteries (4.5 V), then approximately 27% of the energy is wasted. If the battery voltage is 12 V, then 73% will be wasted.

Pulse controller

Pulse regulators usually have a higher efficiency, little dependent on the voltage difference between the input and output. Paying for it comes with the complexity of the scheme, as well as with certain wiring requirements for the PCB. Since the controller uses a relatively high frequency (usually from tens of kilohertz to a few megahertz), the circuit becomes sensitive to parasitic inductances and capacitances, so it’s not enough to connect the elements correctly, the relative positioning of the elements and conductors between them can also critically affect performance. In my practice, there was a case when, due to unsuccessful wiring of conductors on the board, the regulator began to work only when a finger was brought to it - that is, the introduction of additional parasitic capacitance. It may also not be the best choice if your circuit is sensitive to high-frequency interference — for example, there is a sensitive sensor near the PCB.

image
Fig. 2. A typical scheme for the inclusion of Texas Instruments company LM2736, the price is about 80 rubles

What you should pay attention to (much more points than the linear regulator!):


Battery voltage monitoring


There are at least two reasons why this may be necessary. Firstly, it allows an estimate of the remaining work time until full discharge. Secondly, if your device is powered by a lithium battery, then these batteries quickly swell and lose their characteristics from overdischarge, so it is highly desirable to turn off the device before the battery is completely discharged.

It is very simple to make it - just a divider of two resistors connected to the ADC input is enough. The divider is calculated so that the maximum voltage at the ADC input does not exceed 1 V (upper limit of the ADC). In principle, if it is a little higher, then nothing bad will happen, but you need to be careful not to exceed the supply voltage - remember that the battery voltage that we measure can be significantly higher than 3.3 V - if it is accidentally fed to the ADC then ESP8266 will burn.

The disadvantage is that it occupies the only available ADC. This problem, in turn, can be solved by using an external multiplexer (for example, NLAS4599 manufactured by ON Semiconductor, the price is about 10 rubles), but it, in turn, will take one or several GPIOs for control. Also to the disadvantages of this method can be attributed to the fact that the ADC can not hang interrupt, and it must be regularly interviewed himself.

Brownout detection


“Brownout” is a voltage drop below par, but not to zero. Why do you need to detect it? Imagine that you have a battery-powered heating pad on an ESP8266. It gets cold - the heater turns on, it becomes warm - it turns off. It would seem that could go wrong? But let's see more.

The battery as a power source has a certain internal resistance, when trying to pick up a large current from it (for example, when the heater is turned on) its output voltage sags. What happens to the ESP8266 if it sags below 3.3V? What happens is that a small drop in voltage is not enough for a general reset to take place and all outputs go into an inactive state, but not enough for the “moments to stop” for ESP8266 brains. As a result, in our example with a heating pad, it turns out that the ESP8266 turns on a heating pad, immediately goes into a comatose due to brownout, and the GPIO output controlling the heating pad keeps a high level - respectively, the heating pad continues to warm and warms you to a medium well state The battery does not end earlier and finally the long-awaited total reset does not occur.

In many serious microcontrollers, this problem has been solved by hardware for a long time, and often you can even choose a software response to brownout — this can be either a forced reset or an interrupt, in which the microcontroller can “translate itself” (without guarantees, of course) in a safe state. There is nothing like that in ESP8266, so you have to tackle the soldering iron. Fortunately, everything has long been invented before us, and to solve this problem, there have long been chips with only three leads that can be connected to the ESP8266 without any additional strapping. Where to connect - there are two options: either on reset or on GPIO and process the situation programmatically, possibly through an interrupt.

image
Fig. 3. A typical circuit for turning on the CAX803TTBI-T3 chip manufactured by ON Semiconductor, the price is about 10 rubles. Note that the ESP8266 has software-enabled pull-up resistances, so external resistance is not necessary.

That's all, in most cases, the above will suffice to provide your ESP8266 with tasty, healthy and inexpensive food. May the electromotive force be with you!

Source: https://habr.com/ru/post/304936/


All Articles