So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By bartj1
#89049 Hello,

Am considering an ESP8266 as part of a remote control project but I have some questions that I was unable to find concrete answers to in the forum. The questions revolve around the power saving modes. The application requires that when a human presses a button, a message will go out via WIFI within a few ms. It appears that in deep sleep it would take between 2.5 - 5 seconds to re-establish the WIFI connection so that mode is surly out of the question. Using an external signal to the ESP8266, can I pull it out of modem sleep and/or light sleep within a few ms and pass messages via WIFI? Does light sleep maintain the WIFI connection? Is there an advantage to one sleep mode over the other in terms of wake-up time?

Any further discussion on timing concerning waking up from these sleep modes appreciated.

Thanks
User avatar
By davydnorris
#89056 While you can drastically speed up the wifi connection by caching the access point information like channel and MAC address, and by using a static IP address so that there's no DHCP lag, you will always have some level of lag if you turn off the radio.

Caching also decreases power consumption as well because it avoids a channel scan for the AP.

The only mode that keeps the radio on is modem sleep - both light and deep sleep shut down the radio, which means you will need to reconnect to the AP. Modem sleep shuts down the radio but maintains connection to the AP by using the DTIM timers to periodically wake, send a heartbeat, and look for packets, so the AP thinks you're still alive.
User avatar
By bartj1
#89057 Thanks for the explanation.

If you are in "modem sleep" and want to wake back up(external signal says wake up now), how long would you estimate the lag before being able to start sending data via the WIFI?

Thanks again!
User avatar
By davydnorris
#89087 In modem sleep you're always awake - there's no lag. Basically the CPU is still on but the radio is shut down in between DTIM heartbeat events. This gives the AP the appearance that your unit is still associated but the radio gets turned off, saving some power.

This is actually the default mode of the wifi unit.

Light sleep turns off the CPU and system clock but keeps the memory powered, and also follows the DTIM heartbeat in order to appear to be still associated with the AP.

Deep sleep shuts down everything except the RTC memory. In this mode you lose association with the AP and have to re-establish it.

Both light and deep sleep need to be woken externally - in deep sleep it's done via a pulse to GPIO16, and in light sleep it's done on a GPIO of your own choosing (any except for GPIO16).

In your case I think light sleep would be a perfect choice - it requires a GPIO to wake, and takes 3ms before you're transmitting again.

See below:
https://diyi0t.com/how-to-reduce-the-esp8266-power-consumption/
https://www.mischianti.org/2019/11/21/wemos-d1-mini-esp8266-the-three-type-of-sleep-mode-to-manage-energy-savings-part-4/
https://www.espressif.com/sites/default/files/9b-esp8266-low_power_solutions_en_0.pdf