M5.shutdown(x) does not last x seconds

  • 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


    #define DELAY_SECONDS 60
    void loop() {
      // Get RTC time
      RTC_TimeTypeDef rtcTime;
      // Display time
      sprintf(buf, "%02d:%02d:%02d", rtcTime.Hours, rtcTime.Minutes, rtcTime.Seconds);
      Serial.printf("RTC Time %02d:%02d:%02d\n", rtcTime.Hours, rtcTime.Minutes, rtcTime.Seconds);
      // Sleep
      Serial.printf("Shutting down for %d seconds\n", 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"); 
      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;
      Serial.printf("[+] Setup success\n");

  • Hello @aafortinet

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


  • @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).