Can I determine which was the GPIO that woke up in "Light Sleep"?

GustavoGB
Posts: 18
Joined: Fri Jan 15, 2021 1:46 am

Can I determine which was the GPIO that woke up in "Light Sleep"?

Postby GustavoGB » Wed Apr 07, 2021 12:19 pm

I have the following code (taken from examples) that determines what was the reason why it woke up.

Code: Select all

...  
  esp_light_sleep_start();

  printf("WakeUP!\n");

  /* Determine wake up reason */
  const char* wakeup_reason;
  switch (esp_sleep_get_wakeup_cause()) {
      case ESP_SLEEP_WAKEUP_TIMER:
          wakeup_reason = "timer";
          break;
      case ESP_SLEEP_WAKEUP_GPIO:
          wakeup_reason = "pin";
          break;
      default:
          wakeup_reason = "other";
          break;
  }
  printf("Returned from light sleep, reason: %s\n", wakeup_reason);
...
However in case of having several GPIO interrupts I would like to determine which of them was executed.
Is there a saved value for this? Or do I have to do a kind of "trick" of reading the GPIO right after the interrupt? Any better way than that?
Thank you.

Gustavo

Who is online

Users browsing this forum: No registered users and 94 guests