[SOLVED] is timed light sleep possible?

dnc40085
Posts: 5
Joined: Tue Jul 19, 2016 9:55 am

[SOLVED] is timed light sleep possible?

Postby dnc40085 » Tue Aug 02, 2016 5:37 am

Hello, I've been working on exposing the forced sleep API on NodeMCU and I can't get the timed light_sleep to work, every time I execute the following code, the current consumption stays at MODEM_SLEEP_T levels(~17mA) and the CPU is still active.

Code: Select all

wifi_set_opmode_current(NULL_MODE);
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
wifi_fpm_open();
wifi_fpm_set_wakeup_cb(wake_cb);
wifi_fpm_do_sleep(10*1000*1000);


Am I doing something wrong or is timed light_sleep just not possible?

pratik

Re: is timed light sleep possible?

Postby pratik » Wed Aug 03, 2016 10:04 am

Hello,

Please consult the documentation to ensure you are doing everything right:
http://espressif.com/sites/default/file ... ons_en.pdf

The recent SDKs (v.1.5.4, etc) seemed to have some sleep mode current related bugs, which were fixed with patch releases. If you are using v.1.5.x then please make sure your SDK is updated.

dnc40085
Posts: 5
Joined: Tue Jul 19, 2016 9:55 am

Re: is timed light sleep possible?

Postby dnc40085 » Sat Aug 06, 2016 4:16 pm

My mistake, I never said that I tested this with both 1.5.4.1 and 2.0.0.

I did some further testing with a blink example and the timed light sleep is working correctly, I mistakenly assumed NodeMCU didn't have any timers running, which seems to be what is causing my light sleep problems.

From ESP8266 Non-OS SDK API reference 2.0.0:
Timer will prevent the chip from entering light-sleep mode, please disable all timers in
application before entering light-sleep.

Does this apply to both HW and SW timers? Is there anything other than the timers that can prevent timed light sleep?

Is there a way to pause all timers temporarily, so timed light sleep can be achieved without restarting each individual timer?

pratik

Re: is timed light sleep possible?

Postby pratik » Mon Aug 08, 2016 11:10 am

Hello,

Technically, software timers run when software is running... so as long as no interrupt is allowed or hardware timer is disabled, software timer will not be a problem.
You will need to stop the hardware timer for sure though. That should be sufficient.

dnc40085
Posts: 5
Joined: Tue Jul 19, 2016 9:55 am

Re: is timed light sleep possible?

Postby dnc40085 » Sat Aug 13, 2016 5:42 am

Thank you for the information.
I didn't find a way to pause the timers, but I did find the pointer to the beginning of the linked list for the timers "extern os_timer_t *timer_list", after finding this pointer I was able to determine what software timers were preventing light sleep and got it to successfully enter light sleep.
Success!

However I have a few more questions if you don't mind,
1. Is there a way to get the value of the timer or variable that is used in comparison with "ETStimer.timer_expire" to determine when to fire the timer?
2. After setting an interval for light sleep, then waking by gpio. Is there any way to determine whether wakeup cause was from gpio or timeout and is there a way to get the amount of time slept before wake by gpio?

pratik

Re: is timed light sleep possible?

Postby pratik » Mon Aug 15, 2016 12:33 pm

Hello,

By your first question, if you mean whether it is possible to read the timer count, yes it is. May not be possible on software timer (if it has been implemented internally in non-open source code), you may however read the timer count at any time by directly accessing the corresponding timer registers.

For the second question, yes you can find the time from RTC and the reset source from API system_get_rst_info ()

Who is online

Users browsing this forum: No registered users and 3 guests