Say, you’re starting your electronics journey with a few projects in mind. You have an ESP8266 board like the Wemos D1, a Li-Ion battery, you want to build a small battery-powered sensor that wakes up every few minutes to do something, and you don’t want to delve into hardware too much for now. Well then, does [Mads Chr. Olesen] have a tutorial for you! Here, you’ll learn the quick and easy way to get your sensor up and running, learn a few tricks for doing sleep Arduino environment, and even calculate how long your specific battery could last.
You’ll need a TP4056 board, providing charging and battery protection features, a jumper, and maybe a pushbutton – the Fritzing diagram shows everything you’d like to know. From there, you have examples on using deep sleep, do pushbutton or sensor-driven wakeup, manage WiFi, and even read the battery voltage – all of these are a single line of code away, and you learn the few important caveats there are. In the end, there’s even an embedded calculator for how long your Wemos D1 board can survive on a single charge – enter your capacity, the amount of time between wakeups, and see just how long your board will last.
This tutorial is truly accessible if you never touched ESP8266 deep sleep before but would like to start – it’s short and sweet, and you’ll have your battery-powered sensor up and running in no time. It doesn’t go into topics like optimizing the onboard hardware, but in all fairness, you don’t have to do that until you’re ready, and sometimes, it’s really software optimizations that will have a hefty payoff . And, if you ever want to learn more about Li-Ion-powered devices, our tutorials are there for you.
Damn, I almost googled what a Lilon battery is…
My bad, I ought to use Li-Ion more instead! Changed!
I think it is a Lion 🦁 Battery 🤣
Wow. I guess that approach would work. Pretty cumbersome. Maybe it’s the WemosD1 causing the extra effort, I’ve never used those. The ESP8266 has a perfectly functional sleep or deepsleep mode. And many of the sensors like BMExxx can also turn the sensor(s) on/off as needed.
NO…It’s been much simpler. The Adafruit ESP32-S2 has all of this and more on a single board.
Well, *technically*, the article was about a “Battery-powered **ESP8266** sensor” never being easier, and your comment was about an **ESP32** board, so…. :-)
But an ESP32 is more battery efficient if using WiFi. So it can be a better option.
The ESP32 is technically superior in all aspects. The only thing that keeps 8266 alive is it’s cost. For me efficiency, simplicity and power trump a few bucks everytime for a few devices
Won’t the linear regulator and USB chip on the Wemos board eat a good portion of current, regardless of whether the ESP is sleeping or not?
oh yeah fair point, I forgot to mention that. You’ll surely want to swap the linear reg at some point – the stock ones shut off at like, 4V. I did cover this here!
Isn’t a low-drop linear regular actually more efficient for quiescent power?
ESP8266 can work years from fully charged 18650. You must use low drop voltage regulator as it was mentioned earlier, USB converter chip should be removed, which leaves you with basic ESP8266; and most important – communication should be via ESP-NOW, not WiFi. On time will be reduced to under 0.1 of a second compared to few seconds with WiFi.
But would would using ESP-Now prevent you from sending the sensor data to an app like Blynk. Just curious because I would still want the web server functionality.
It will, but you can get around this by having another esp_now “Hub” that is plugged in or otherwise provided with more power to act as a handler for all the wireless sensors, and then it can connect to WiFi and send to an app via http or mqtt. It all depends on how often the sensor needs to send data. If it is only say once every 30 minutes or so, then you can get by with WiFi and deep sleep in-between. If it needs to be more often, then the sensor->Hub->WiFi is way more energy efficient, just requirements an extra component built.
Regarding energy saving with an ESP8266, I have learned a lot by reading the articles on this blog:
https://www.bakke.online/index.php/2017/05/21/reducing-wifi-power-consumption-on-esp8266-part-1/
https://www.bakke.online/index.php/2017/05/21/reducing-wifi-power-consumption-on-esp8266-part-2/
https://www.bakke.online/index.php/2017/06/24/esp8266-wifi-power-reduction-avoiding-network-scan/
That info was helpful when I was trying to do something similar, but I think it’s also a bit out of date. IIRC there have been a number of changes to the ESP8266 Arduino core files, some made his code to manipulate the wifi state not work as he describes, and one that makes sure wifi is off while the Arduino code is loading.
Also, there is WiFiState.h that contains code and structures to store wifi state data to RTC and restore it on waking from sleep. It works fine as long as you don’t need to store anything else to the RTC RAM, but some sort of standardized layout for the RTC RAM along with some getters and setters would be something I’d like to see (and maybe there is one now since I haven’t revisited this in a while).
With an ESP01, an LDO, and SHT30, I could eek out just about a month of runtime with 4AAA batteries with my measurements set to 1 minute intervals (just an arbitrary number I was messing with). With a 18650, the run time is much longer and I rarely need to think about batteries.
I guess that approach would work. Pretty cumbersome
oh, how is this cumbersome?
I just saw similar circuits that were smaller and had a slightly simpler implementation.
this came at the right moment! I just ordered a bunch of ESP8266 and DHT22 sensors and they arrived just after christmas :)
But would would using ESP-Now prevent you from sending the sensor data to an app like Blynk. Just curious because I would still want the web server functionality.
FWIW I made 3x ESP8266 + DHT22 each using 2x AA alkaline batteries. 3.3V regulators removed from both ESP an DHT22 which came with SHTC3 sensor. Both LED’s removed on ESP and 3mm external LED wired for TX indication. Wire added for deep sleep. WIFI router uses static IP for sensors.
They transmit UDP WIFI data every ~5 minutes. Data comprises of sensor number, temperature, humidity, battery voltage (as there’s no voltage regulator) , wake time which is timer + 10ms added just before TX and sleep, WIFI signal level and station SSID (as there are multiple choices).
Normal wake time is 250ms (0.25 seconds) including sensor unless the router isn’t available in which case it tries for up to 10 seconds. So far they have been running 1 year and 4 months, now at 2.6V so maybe not much longer.
Testing with PSU showed 2.4V as lower limit. One sensor is in the attic with temperatures sometimes reaching over 50C.
Very impressive, did you write it up in more detail anywhere (esp board type etc)?