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

    Is it possible to wakeup M5stack paper from the shutdown mode using Port A, B or C?

    Arduino
    2
    9
    1.7k
    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.
    • ScheduleDisplayS
      ScheduleDisplay
      last edited by

      Hello,
      I have understand that the M5 stack paper can wakeup from the shutdown mode by long pressing the side button but sometimes it is not feasible.

      Is it possible to configure M5 stack paper in a way that:

      1. It will wake up from short press of the side button?
      2. It will wake up using Port A, B or C by connecting the external button? e.g this button from M5
      felmueF 1 Reply Last reply Reply Quote 0
      • felmueF
        felmue @ScheduleDisplay
        last edited by

        Hello @ScheduleDisplay

        unfortunately that is not possible; all GPIOs (Port A, B and C) and the GPIO used for the side button go directly to ESP32 which is powered off in shutdown mode.

        The only two options (I know of) to wakeup M5Paper from shutdown mode are:

        • long press of side button
        • RTC alarm

        Thanks
        Felix

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

        ScheduleDisplayS 2 Replies Last reply Reply Quote 0
        • ScheduleDisplayS
          ScheduleDisplay @felmue
          last edited by

          @felmue Thank you very much for your reply.

          1 Reply Last reply Reply Quote 0
          • ScheduleDisplayS
            ScheduleDisplay @felmue
            last edited by

            @felmue
            Hello,
            Today I did some testing with the external button to wakeup the M5 stack paper from the deep sleep mode.
            I connect the button at the PORT B of Epaper. please see the attached pictures.

            1. Not connected to the charger: The Epaper didn't woke up from the deep sleep, as expected, as you said.

            2. Connected with the charger: The Epaper continously keep restarted after executing the shutdown command, until I unplug the button from the PORT B.
              Do you have an idea about this behavior, what is going on with Epaper?

            This is the code I am running on Epaper

            #include <M5EPD.h>
            #include <Arduino.h>
            
            M5EPD_Canvas canvas(&M5.EPD);
            
            #define WAKEUP_PIN_26 26  // GPIO pin on PORT B (G26)
            #define WAKEUP_PIN_33 33  // GPIO pin on PORT B (G26)
            void setup() {
                wakeupM5OnButtonPressMode();
            }
            
            void loop() {
            }
            
            void wakeupM5OnButtonPressMode(){  
                M5.begin();
                M5.EPD.SetRotation(90);
                M5.EPD.Clear(true);
                canvas.createCanvas(540, 400);
                canvas.setTextSize(4);
            
                gpio_hold_dis((gpio_num_t)M5EPD_MAIN_PWR_PIN);
                gpio_deep_sleep_hold_dis();
            
                // Display battery voltage before shutting down
                Serial.print("\nVoltage before shut down: " + String(M5.getBatteryVoltage() / 1000.0));
                
                // Update the e-ink display with messages
                canvas.drawString("Press button on PORT B to wake up!", 5, 160);
                canvas.drawString("Going to sleep in 5 secs...", 5, 200);
                canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
                delay(5000);
            
                // Enter deep sleep
                shutdownEPD();
            }
            
            void shutdownEPD() {
                Serial.println("\nShutting down...");
                
                // Display voltage after shutdown (for debugging purposes)
                Serial.print("\nVoltage after shutdown: " + String(M5.getBatteryVoltage() / 1000.0));
                Serial.print("\n*********************************************\n");
                
                // Prepare for deep sleep
                M5.shutdown();                    // Shutdown the display and peripherals
                M5.disableEPDPower();             // Disable e-paper power
                M5.disableEXTPower();             // Disable external power supply
                
                // Configure GPIO for wake-up on button press (PORT B - G26)
                pinMode(WAKEUP_PIN_26, INPUT_PULLUP);  // Enable internal pull-up for stability
                esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_PIN_33, LOW);  // Wake when pin goes LOW
                
                // Hold power pins to preserve state during deep sleep
                gpio_hold_en((gpio_num_t)M5EPD_MAIN_PWR_PIN);
                gpio_deep_sleep_hold_en();
                
                // Enter deep sleep
                esp_deep_sleep_start();
            }
            

            WhatsApp Image 2024-11-28 at 18.00.00_c82f412d.jpg
            WhatsApp Image 2024-11-28 at 18.00.00_64f8f70d.jpg

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

              Hello @ScheduleDisplay

              maybe below lines are the issue?

              pinMode(WAKEUP_PIN_26, INPUT_PULLUP);  // Enable internal pull-up for stability
              esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_PIN_33, LOW);  // Wake when pin goes LOW
              

              you enable wakeup on GPIO33 while the pullup is set for GPIO26.

              Thanks
              Felix

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

              ScheduleDisplayS 1 Reply Last reply Reply Quote 0
              • ScheduleDisplayS
                ScheduleDisplay @felmue
                last edited by

                @felmue Hello,
                Thank your for the reply.
                I updated the typo and now using the correct GPIO26 pin, but the behavior of E-paper is still the same.

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

                  Hello @ScheduleDisplay

                  in order to use ESP32 deep sleep ESP32 and external power to the Grove ports need to stay on. Grove power is required for the pull-up resistors in the button unit. (Internal pull-up is too weak.)

                  I can get your sketch to work if I comment the following lines:

                  //    M5.shutdown();                    // Shutdown the display and peripherals
                  
                  //    M5.disableEXTPower();             // Disable external power supply
                  

                  and adding this line:

                  gpio_hold_dis((gpio_num_t)M5EPD_EXT_PWR_EN_PIN);
                  

                  after the other gpio_hold_dis() line.

                  Plus adding this line:

                  gpio_hold_en((gpio_num_t)M5EPD_EXT_PWR_EN_PIN);
                  

                  after the other gpio_hold_en() line.

                  Thanks
                  Felix

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

                  ScheduleDisplayS 1 Reply Last reply Reply Quote 0
                  • ScheduleDisplayS
                    ScheduleDisplay @felmue
                    last edited by ScheduleDisplay

                    @felmue
                    Thank you very much for your reply and help.
                    The code is working now. The M5 paper is now waking up with and without the USB charger connection. :)

                    Just a quick question. Now we have commented out the below lines, so does that means that the battery will drain out much faster as the M5 paper is in light sleep mode?

                    M5.shutdown();
                    
                    M5.disableEXTPower(); 
                    
                    felmueF 1 Reply Last reply Reply Quote 0
                    • felmueF
                      felmue @ScheduleDisplay
                      last edited by

                      Hello @ScheduleDisplay

                      I am glad to hear it works for you now.

                      Yes, the battery will drain much faster when using ESP32 deep sleep or light sleep compared to a full shutdown.

                      You can find the currents for all three modes here.

                      Thanks
                      Felix

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

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