Light sleep and timers
Light sleep and timers
Postby blubb » Thu Jul 20, 2017 11:28 pm
I found out that the automatic (not forced) light sleep (i.e. wifi_set_sleep_type) cannot be used with the os timers (os_timer_arm etc.). The timers become very unreliable. That is because CPU and clock is halted, right?
Now I wonder how the forced sleep functions work. I mean it is possible to set a timeout and still use light sleep, e.g.
wifi_fpm_do_sleep(50*1000);
What is their clock source and why can't this be implemented in the automatic light sleep functionality?
Now I wonder how the forced sleep functions work. I mean it is possible to set a timeout and still use light sleep, e.g.
wifi_fpm_do_sleep(50*1000);
What is their clock source and why can't this be implemented in the automatic light sleep functionality?
Re: Light sleep and timers
Postby pratik » Mon Jul 24, 2017 6:05 pm
The RTC peripheral memory and clock do work even when there is no active CPU. That is how events like deep sleep wake-up, etc are timed. The timer runs off the standard peripheral clock (which consumes lots of power), so regular timers are turned off.
What exactly is your system requirement? I can help find the sleep mode that will suit your application most.
What exactly is your system requirement? I can help find the sleep mode that will suit your application most.
Re: Light sleep and timers
Postby blubb » Mon Jul 24, 2017 8:14 pm
I have a web server running on the ESP. Also there is a timer (using os_timer_arm) which occurs every minute. There is not much to be done during that minute (usually).
So using MODEM sleep works. The web server is accessible all the time and also the timer callback is precisely called.
But in my opinion LIGHT sleep would be better. Wifi access is still ok (light sleep is interrupted by wifi), but the timer won't work anymore (at least not reliably). If there is no wifi access, the timer "oversleeps". So what I would need is an option to tell the automatic LIGHT sleep when to wake up. Like an RTC alarm of some kind.
So using MODEM sleep works. The web server is accessible all the time and also the timer callback is precisely called.
But in my opinion LIGHT sleep would be better. Wifi access is still ok (light sleep is interrupted by wifi), but the timer won't work anymore (at least not reliably). If there is no wifi access, the timer "oversleeps". So what I would need is an option to tell the automatic LIGHT sleep when to wake up. Like an RTC alarm of some kind.
Re: Light sleep and timers
Postby pratik » Tue Aug 08, 2017 3:58 pm
Light sleep turns the CPU off, so timed light sleep is a bit of an issue. Also, to use light sleep, wifi radio must be in NULL mode (radio off!).
So modem sleep is what you should use.
When ESP is the AP, power saving is not practical. An AP must stay up all the time. You can lower the transmit strength and PHY mode to save power if you wish to.
If you have ESP in station mode and server is enabled, then enable auto light-sleep or modem sleep, which will save power.
So modem sleep is what you should use.
When ESP is the AP, power saving is not practical. An AP must stay up all the time. You can lower the transmit strength and PHY mode to save power if you wish to.
If you have ESP in station mode and server is enabled, then enable auto light-sleep or modem sleep, which will save power.
Re: Light sleep and timers
Postby blubb » Tue Aug 08, 2017 4:27 pm
pratik wrote:If you have ESP in station mode and server is enabled, then enable auto light-sleep
This is exactly my case. But the timers get unreliable since the wake ups from light sleep depend on the signals from my wifi router. Sometimes nothing is received and the timers oversleep.
This is why I am using modem sleep.
It is unfortunate there is no other way to save more power.
An option to wake up from automatic light sleep every x seconds would be great...
Re: Light sleep and timers
Postby pratik » Tue Sep 05, 2017 8:47 pm
The nature of light sleep prevents such functionality, because it makes the core sleep and wireless activity must stop. You will need an external trigger to wake it up then.
Who is online
Users browsing this forum: No registered users and 300 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.