🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Wakeup from Lightsleep using Button A?

    M5 Stick/StickC
    2
    4
    5.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      guardian5
      last edited by

      Hello everyone,
      I am can successfully put my StickC to light sleep using a timer, but I would like to be able to wake it up either using the timer (on its own), or by pressing the A button.
      This is the code I'm using:

      #define BUTTON_PIN_BITMASK 0x2000000000 // 2^37 in hex
      
        esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
        esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH); //wake up when Button A is pressed
        Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
        " Seconds");
        esp_light_sleep_start();
      
      

      This is the guide I used: https://randomnerdtutorials.com/esp32-external-wake-up-deep-sleep/

      My guess is that it's got something to do with the PIN 37 being interlanny pulled up or down, but I'm stuck now...
      What do you think?

      Thank you all in advance!

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @guardian5

        are you aware that the buttons, when pressed, pull their respective GPIO low (and not high)? Have you tried using ESP_EXT1_WAKEUP_ALL_LOW instead?

        For reference: M5StickC schematic.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • G
          guardian5
          last edited by

          Thank you Felix, I solved my problem, it was clearly an internal pullup detail:

            esp_sleep_enable_ext0_wakeup(GPIO_NUM_37,0);//Configure GPIO37 as ext0 wake up source for low logic level
            gpio_pullup_en(GPIO_NUM_37);
          1 Reply Last reply Reply Quote 0
          • felmueF
            felmue
            last edited by

            Hello @guardian5

            you are welcome. I am happy to hear you got it working.

            Cheers
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0
            • First post
              Last post