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

    M5.shutdown(x) does not last x seconds

    Scheduled Pinned Locked Moved Arduino
    3 Posts 2 Posters 4.9k Views
    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.
    • A Offline
      aafortinet
      last edited by

      I would like my M5 Core Ink to shutdown (to save battery), then automatically wake up after a given amount of seconds and resume its activity.
      For that, I use M5.shutdown(x) where x is the amount of seconds. To my understanding, that's typically what shutdown does.

      It is not working! For example, I specify 60 seconds as argument to M5.shutdown(), the program's loop() is still called every ~5 seconds!
      Strange: the eInk display is not refreshed... (at all).

      Precisely, my loop code

      • Gets the RTC time
      • Displays it (both Serial and eInk)
      • Calls M5.shutdown(60)

      The serial monitor shows that loop is called every ~6-7 seconds. Strange, the eInk screen is not refreshed and displays only the first RTC time.

      RTC Time 14:07:35
      Shutting down for 60 seconds
      RTC Time 14:07:41
      Shutting down for 60 seconds
      

      Code

      #define DELAY_SECONDS 60
      
      void loop() {
        // Get RTC time
        RTC_TimeTypeDef rtcTime;
        M5.rtc.GetTime(&rtcTime);
        
        // Display time
        sprintf(buf, "%02d:%02d:%02d", rtcTime.Hours, rtcTime.Minutes, rtcTime.Seconds);
        InkPageSprite.drawString(10,50,buf);
        InkPageSprite.pushSprite();
        Serial.printf("RTC Time %02d:%02d:%02d\n", rtcTime.Hours, rtcTime.Minutes, rtcTime.Seconds);
      
        // Sleep
        delay(100);
        Serial.printf("Shutting down for %d seconds\n", DELAY_SECONDS);
        M5.shutdown(DELAY_SECONDS);
      }
      

      I tried M5.shutdown(60000), same result. I also tried supplying a rtcTime to shutdown, but it didn't change anything either.

      The creation of the sprite is in setup:

      void setup() {
      
        M5.begin(); //Init CoreInk.  
        if( !M5.M5Ink.isInit()) //Init CoreInk screen.
        {
          Serial.printf("[-] M5Ink init failed");  
          while (1) delay(100);
        }
      
        M5.M5Ink.clear();   // Clear screen. 
        Serial.printf("[+] Clearing eInk screen\n"); 
        delay(1000);
      
        if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ){
          Serial.printf("[-] Ink Sprite create failed\n");
        }
      
        // set RTC time
        RTC_TimeTypeDef rtcTime;
        rtcTime.Hours = 14;
        rtcTime.Minutes = 6;
        rtcTime.Seconds = 0;
        M5.rtc.SetTime(&rtcTime);
        
        Serial.printf("[+] Setup success\n");
      }
      
      1 Reply Last reply Reply Quote 0
      • felmueF Offline
        felmue
        last edited by

        Hello @aafortinet

        the shutdown functionality only works when M5CoreInk is running from battery.

        Thanks
        Felix

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

        A 1 Reply Last reply Reply Quote 0
        • A Offline
          aafortinet @felmue
          last edited by

          @felmue said in M5.shutdown(x) does not last x seconds:

          the shutdown functionality only works when M5CoreInk is running from battery.

          ah haaaaaaaa! ok! Thanks for the remark! Indeed. And now it works (when from battery).

          And if somebody wonders, it might be useful to note in the doc that shutdown() actually has the M5 run again the setup() code (it makes sense, as it is "shut-down" but worth mentioning because it changes the way to implement things).

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post