5 ms·
The ESP8266 has 5 sleep modes, as summarized by this README.md in the Arduino ESP8266 Core: https://github.com/esp8266/Arduino/tree/master/libraries/esp8266/exa
by bxparks 4y ago
The ESP8266 has 5 sleep modes, as summarized by this README.md in the Arduino ESP8266 Core: https://github.com/esp8266/Arduino/tree/master/libraries/esp8266/examples/LowPowerDemo https://github.com/esp8266/Arduino/tree/master/libraries/esp...
The `delay(1)` triggers the "Automatic Modem Sleep" mode, which keeps the WiFi connection alive. It should draw about 15-16 mA, which is pretty close to the 18-24 mA measured in the TFA.
The WiFi radio consumes a lot of power. During initialization, I believe it can consume 500 mA or more. In normal usage, WiFi apparently has a continuous drain of ~70 mA. If WiFi is not needed, the ESP8266 can be placed into "Forced Deep Sleep" mode, with an idle current of 0.02 mA. Using a ~2000 mAh battery (e.g. 3xAA NiMh, or 1x18650 Li-Ion), that means over 11 years on battery, if no other work is performed. The lowest current that I have measured personally is 0.04 mA on various ESP-01 modules. But that still means about 5.5 years on a single charge.
If the WiFi is needed only intermittently, the ESP8266 can be placed into "Forced Deep Sleep" mode, with the internal RTC configured to wake it up after a certain time, e.g. 15-30 minutes. It can then connect to WiFi, transmit the data payload, then go back to Deep Sleep again. Unfortunately, the ESP-01 module does not support this (without hardware hacking), because it does not expose the GPIO16/D0 pin necessary to trigger the RESET.
Other ESP8266 dev boards (e.g. D1 Mini, NodeMCU) do support waking up from Deep Sleep. But these dev boards often contain a voltage regulator which consumes a quiescent current. On my D1 Mini boards, I get about 0.22 mA in Forced Deep Sleep mode. In theory, that's enough for 1 year of life on a single charge of a 2000 mAh battery. But waking it up every 15 minutes, for 5-6 seconds of WiFi time, reduces the battery life to about 4-5 months. At this point, the active power usage during the 5-6 seconds of WiFi is already 2X the power consumption of the 15 minutes of Deep Sleep, so I have not attempted to reduce the idle consumption any further.
- antoniuschan99 4y agoYou can actually get the wifi state as low as 2 seconds in very ideal conditions. Average less than 4 seconds. If rssi is extremely low then it will def take longer. Yea the voltage regulator is very important and the ones on the nodemcu have very high quiecient current. Also on the top end you have to look for regulators that can handle the ~500mA peak current too. Otti Arc or Nordic PPk2 is an invaluable tool!
- bxparks 4y agoPeople do say that WiFi reconnect can be done in 2 seconds, but I have never been able to achieve that myself on my network, no matter the signal strength. I tried static IP, static subnet, and various configs before going to sleep (to retain WiFi signal strength? I can't remember). I always get 5-6 seconds. I think I remember measuring the NodeMCU with a higher Deep Sleep current than the D1 Mini, but I don't remember what that value was. The other thing I forgot to mention that consumes current is the USB-Serial converter on boards like the D1 Mini and NodeMCU, but not present on the ESP-01. I don't know which consumes more, the voltage regulator or the USB-Serial converter.
- antoniuschan99 4y agoIt also could be if you're still using 8266 vs esp32 or if you're on Arduino vs esp-idf. Arduino esp32 is a wrapper on top of the idf so not sure what added things could be slowing the program? Static ip might be even faster! Also, I have it initialized station mode. I do recall the d1 mini having a really low quiescent current. Yea the converters can also take up power I separate that and place it on a jig.
- dragontamer 4y agoThe current-usage on WiFi power is just nuts. Anyone trying to do wireless with low power should be using other protocols. Zigbee, Bluetooth, Z-Wave, ANT... anything but WiFi. I mean, WiFi just wasn't designed for low-power like these other protocols. Hell, you might do better with LoRa (long-range, ~3-miles) signals than WiFi. > Other ESP8266 dev boards (e.g. D1 Mini, NodeMCU) do support waking up from Deep Sleep. But these dev boards often contain a voltage regulator which consumes a quiescent current. On my D1 Mini boards, I get about 0.22 mA in Forced Deep Sleep mode. In theory, that's enough for 1 year of life on a single charge of a 2000 mAh battery. But waking it up every 15 minutes, for 5-6 seconds of WiFi time, reduces the battery life to about 4-5 months. At this point, the active power usage during the 5-6 seconds of WiFi is already 2X the power consumption of the 15 minutes of Deep Sleep, so I have not attempted to reduce the idle consumption any further. Have you tried going even slower? You can cut your current usage in half by going every 30-minutes, and then in a quarter by connecting every 60-minutes (etc. etc.) until your current consumption is as low as you want. There are practical limits (is one connection per day sufficient?), but 15 minutes still has some leeway depending on the application. If you need low-power but still wireless and more updates than that... having a faster-to-initialize and lower power usage to boot (10mA for those 30ms, rather than for 100mA for 2000mS), you'll grossly cut down your power consumptions.
- bxparks 4y agoYou are not wrong about WiFi. But sometimes worse is better. :-) With WiFi, I don't need any other technology stack, no hubs, no bridges. I can use my existing network infrastructure. The data packets from the ESP8266 devices get delivered directly to the MQTT broker over TCP/IP over WiFi. It's cheap (~$3 for a D1 Mini), dead simple, and good enough. Every 15 minutes seems about right for temperature/humidity sensors. Increasing it beyond 15-30 minutes becomes a diminishing return, because at that point, the Deep Sleep power usage becomes greater than active WiFi usage.
- dragontamer 4y agoYeah, obviously getting the project done is highest priority. So if it works, and you're at .5 mA average, its good enough. Still though, WiFi's specs are pretty awful. It bothers me to see such huge numbers whenever people talk about WiFi. And since we're in tiny microcontroller land, its not like any of us are actually tranferring GBs or MBs of data. We're all just passing a few kB, so much slower protocols (ex: Zigbee) are very reasonable. Things start to get silly below the 500uA levels anyway. You start worrying about aluminum capacitors with 22uA leakage current and such... and realizing you need to upgrade to Tantalum capacitors with specified 2uA or 1uA leakage.