(solved) unable to enter deep sleep

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

(solved) unable to enter deep sleep

Postby mzimmers » Wed Oct 24, 2018 5:23 pm

Hi all -

I'm attempting to enter deep sleep mode when the following conditions are met:

1. Line power is removed (running on battery)
2. Battery voltage drops below a certain threshold.

I'm successfully invoking the code below:

Code: Select all

    esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
    esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
    esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
    esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF);

    ESP_LOGI(TAG, "shutdown(): entering deep sleep.");
    vTaskDelay(1);
    esp_deep_sleep(0xffffffffffffffff);
And here's what happens:

Code: Select all

I (4289) PowerMgr: shutdown(): entering deep sleep.
I (12) boot: ESP-IDF v3.1-dirty 2nd stage bootloader
I (12) boot: compile time 10:05:01
What could be waking me up? I don't want anything but line power to wake me up, and I'm not restoring line power in my testing.
Last edited by mzimmers on Thu Oct 25, 2018 2:45 pm, edited 1 time in total.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: unable to enter deep sleep

Postby mzimmers » Wed Oct 24, 2018 8:04 pm

Well, I managed a workaround. Evidently the esp_deep_sleep() routine doesn't like the value 0xffffffffffffffff, and it ends immediately. I tried this instead, and it works:

Code: Select all

    const uint64_t SLEEP_TIME = (uint64_t) 0x7fffffffffffffff;
    esp_deep_sleep(SLEEP_TIME);
Perhaps somewhere in the ESP internals, the uint64 is being treated as a int64?

Doesn't really matter to me, as 0x7fffffffffffffff microseconds is still a very very long time.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: unable to enter deep sleep

Postby WiFive » Wed Oct 24, 2018 8:37 pm


User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: unable to enter deep sleep

Postby mzimmers » Wed Oct 24, 2018 8:39 pm

Bam. Should we alert someone to modify the docs (or the software)?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: unable to enter deep sleep

Postby WiFive » Wed Oct 24, 2018 10:36 pm

I guess docs could be updated since a 63-bit value is ~300 millennia but other users may try "sleep forever" as max(uint64_t). If you don't want to wake up by timer then you could call esp_deep_sleep_start instead.

Who is online

Users browsing this forum: No registered users and 83 guests