esp8266 / esp8266/Arduino

Forced light sleep being locked in delay function

Open
#8,480 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

I need the ESP to sleep and be able to wake up by both the GPIO and the timer, follow the functions below:

void esp8266_disable_wifi()
{
WiFi.enableAP(false);
WiFi.mode(WIFI_OFF);
WiFi.disconnect(true);
WiFi.forceSleepBegin();
wifi_set_opmode(NULL_MODE);
}

void esp8266_light_sleep(int wakeup_pin, long time_sleep){
long sleepTimeMilliSeconds = time_sleep * 1e3;

extern os_timer_t *timer_list;
timer_list = nullptr;
Serial.print("system time start Sleep"); Serial.println(RTCmillis());

wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
wifi_fpm_set_wakeup_cb(wakeupCallback);
gpio_pin_wakeup_enable(GPIO_ID_PIN(wakeup_pin), GPIO_PIN_INTR_HILEVEL);
wifi_fpm_open();
wifi_fpm_do_sleep(sleepTimeMilliSeconds * 1000);
delay(sleepTimeMilliSeconds + 1);
}

ESP goes into forced light sleep mode, but when the time defined in wifi_fpm_do_sleep ends, the esp is stopped in delay(sleepTimeMilliSeconds + 1) consuming 60mA

Another problem I found is that esp only wakes up with the timer after the first interruption by gpio, is this correct?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.