ESP32-C3 wakeup and interrupt

Mattgo
Posts: 5
Joined: Tue May 16, 2023 7:04 pm

ESP32-C3 wakeup and interrupt

Postby Mattgo » Mon Apr 08, 2024 6:35 am

Hello, I would like to ask about setting wakeup from light sleep on ESP32-C3.
I am not able to configure wakeup and also attach the interrupt to the same pin (non RTC pin). Any attempt to attach or detach interrupt on wakeup pin cancel the wakeup function and vice versa. Is there any way to properly set both fucntions on same pin at once or do I have to configure wakeup before sleep and attach interrupt after wakeup each cycle? What are the best practices in this case?
Thank you

Code: Select all

  detachInterrupt(digitalPinToInterrupt(20));
  gpio_wakeup_enable(GPIO_NUM_20, GPIO_INTR_LOW_LEVEL);
  esp_sleep_enable_gpio_wakeup();
  esp_light_sleep_start();
  attachInterrupt(digitalPinToInterrupt(20), test, CHANGE);

liaifat85
Posts: 200
Joined: Wed Dec 06, 2023 2:46 pm

Re: ESP32-C3 wakeup and interrupt

Postby liaifat85 » Mon Apr 08, 2024 7:46 am

Before entering sleep mode, configure the pin for wakeup using gpio_wakeup_enable() and enable GPIO wakeup using esp_sleep_enable_gpio_wakeup(). This prepares the microcontroller to wake up when a specific event occurs on the configured pin.

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

Re: ESP32-C3 wakeup and interrupt

Postby MicroController » Mon Apr 08, 2024 9:17 am

liaifat85 wrote:
Mon Apr 08, 2024 7:46 am
Before entering sleep mode, configure the pin for wakeup using gpio_wakeup_enable() and enable GPIO wakeup using esp_sleep_enable_gpio_wakeup(). This prepares the microcontroller to wake up when a specific event occurs on the configured pin.
Are you sure you're not an A.I.?

Who is online

Users browsing this forum: No registered users and 169 guests