arkhipenko / TaskScheduler

Cooperative multitasking for Arduino, ESPx, STM32, nRF and other microcontrollers
http://playground.arduino.cc/Code/TaskScheduler
BSD 3-Clause "New" or "Revised" License
1.26k stars 230 forks source link

Using esp_light_sleep_start() can break WiFi, should be configurable to use delay()/xTaskNotifyWait() instead. #191

Open ranma opened 1 month ago

ranma commented 1 month ago

With the default of esp_light_sleep_start() I see WiFi connection problems.

Using delay() can still noticeably reduce the SoC temperature. In my limited testing, the temperature reported by CpuTemperature.read() reduced from ~58 °C to ~52 °C after enabling -D_TASK_SLEEP_ON_IDLE_RUN=1 and hacking it to use delay() instead of esp_light_sleep_start().

arkhipenko commented 1 month ago

Hi, Which version of TaskSxheduler are you running. I believe I disabled light sleep in the latest version since yes, it causes WiFi issues. Simple delay(1) (or vTaskDelay(1) ) works better.

ranma commented 1 month ago

Which version of TaskSxheduler are you running.

The master branch: https://github.com/arkhipenko/TaskScheduler/blob/master/src/TaskSchedulerSleepMethods.h#L61

ranma commented 3 weeks ago

Simple delay(1) (or vTaskDelay(1) ) works better.

One problem with a simple delay is that when using StatusRequest to wake from an interrupt, the delay is not interrupted.

So for ESP32 even better is to use xTaskNotifyWait() to sleep and xTaskNotify()/xTaskNotifyFromISR() to interrupt the sleep.