Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using esp32 sleep function #73

Open
dragoncoder047 opened this issue Apr 27, 2023 · 2 comments
Open

using esp32 sleep function #73

dragoncoder047 opened this issue Apr 27, 2023 · 2 comments

Comments

@dragoncoder047
Copy link

Right now the (sleep) function doesn't actually put the CPU to sleep, it just burns time in a delay() loop.

However, the ESP32 does have a light-sleep function that preserves the state - care to try it out?

esp_sleep_enable_timer_wakeup(secs * 1000000UL);
esp_light_sleep_start();

Also, I might add that maybe you can allow (sleep) to be called with no arguments, which means indefinite sleep -- on esp32 it just directly calls esp_light_sleep_start(), on AVR it calls sleep_enable(); sleep_cpu(); without enabling the watchdog for interrupts, etc.

@technoblogy
Copy link
Owner

technoblogy commented Apr 27, 2023

Yes, the sleep function puts the CPU to sleep on AVR and some ARM platforms, but I couldn't work out how to do it on the ESP32.

Also, I have done what you suggested on AVR - (sleep) goes to sleep for ever, and you could arrange an interrupt to wake you up.

I'll try implementing it on ESP32 as you've suggested.

@technoblogy
Copy link
Owner

Haven't done this yet - sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants