Handling Light Sleep on One Core While Running Code on Another Core with ESP32

Roconx
Posts: 1
Joined: Fri Sep 06, 2024 8:37 am

Handling Light Sleep on One Core While Running Code on Another Core with ESP32

Postby Roconx » Fri Sep 06, 2024 8:44 am

Hi everyone,

I’m working on a project where I use the ESP32 in light sleep mode to wake up when an interrupt occurs, such as when a user presses a button or after a timeout period elapses. The function I’m using is designed to put the ESP32 into light sleep mode and wake up based on these conditions.

I am also using a SIM7600 module to make HTTP requests to the internet. Ideally, I would like to make a request while the or handling user input is in light sleep mode or in a similar low-power mode so I don't need to change the code too much and I am not using something like an infinite loop. My goal is to have one core (Core 0, for instance) in light sleep mode or similar, waiting for an interrupt, while the other core (Core 1) remains active and is able to execute tasks, such as making a network request.

However, I noticed that putting one core in light sleep mode causes the other core to also go into light sleep, stopping the execution of the ongoing task.

So, my question is:

Is there a way to put one core to sleep (e.g., waiting for a GPIO interrupt or timer) while keeping the other core active and able to execute code (such as making a network request)? Additionally, once the network request is completed by the active core, both cores should enter light sleep mode again and continue waiting until either a timeout has elapsed or a GPIO pin goes high, as per the original code running on the first core.

Any suggestions or insights on achieving this would be greatly appreciated!

Thank you!

MicroController
Posts: 1699
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Handling Light Sleep on One Core While Running Code on Another Core with ESP32

Postby MicroController » Fri Sep 06, 2024 12:47 pm

Roconx wrote:
Fri Sep 06, 2024 8:44 am
Is there a way to put one core to sleep [...] while keeping the other core active [...]?
No.
Additionally, once the network request is completed by the active core, both cores should enter light sleep mode again and continue waiting until either a timeout has elapsed or a GPIO pin goes high, as per the original code running on the first core.
You probably want to look into enabling "automatic light sleep". This (mostly) relieves you of having to manually coordinate when to enter light sleep, entering light sleep automatically when the system "sees" that there's nothing to do (in any task, on either core) for some time.

Who is online

Users browsing this forum: Google [Bot] and 133 guests