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

    Has anyone gotten M5.Rtc.setAlarmIRQ to work on ESP32S3? for

    SOFTWARE
    2
    3
    411
    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.
    • W
      wsanders
      last edited by wsanders

      Trying to get M5.Rtc.setAlarmIRQ to work. Note: Device is PaperS3, so this function may not be implemented yet.

      M5.Rtc.setAlarmIRQ(30);
      M5.Power.powerOff();
      

      This should reboot the device every 30 sec but doesn't.

      M5.Power.timeSleep works, and is coded thus in Power_Class.cpp:

      void Power_Class::timerSleep( int seconds )
      {
        M5.Rtc.disableIRQ();
        M5.Rtc.setAlarmIRQ(seconds);
      #if !defined (M5UNIFIED_PC_BUILD)
        esp_sleep_enable_timer_wakeup(seconds * 1000000ULL);
      #endif
        _timerSleep();
      }
      

      However, for the PaperS3, M5UNIFIED_PC_BUILD is not defined, so the RTC timer call is not used, and the esp timer is called instead. I'm not sure why, because the PaperS3 has the same RTC chip as all the other M5 devices, and getting and setting the RTC clock seems to work. Yet, when I call M5.Rtc.disableIRQ and M5.Rtc.setAlarmIRQ separately in my code, it doesn't work.

      It's also unclear form the ESP documentation is esp_sleep_enable_timer_wakeup even puts the ESP to sleep. You can put the ESP in deep sleep with a wakeup time, but the PaperS3 still drains about 5mA of power, much more than it should if it were completely powered off. (It is a known issue that M5.Power.powerOff doesn't completely power off the PaperS3, but this should not affect the Rtc alarm.)

      I hope this is not a bug in the odd PMS150G power chip since that chip cannot be reprogrammed in the PowerS3.

      Any ideas?

      W felmueF 2 Replies Last reply Reply Quote 0
      • W
        wsanders @wsanders
        last edited by wsanders

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • felmueF
          felmue @wsanders
          last edited by felmue

          Hello @wsanders

          you answered your question yourself - power off functionality is not implemented yet on M5PaperS3 and therefore RTC alarms do not work.

          Some background (as I understand it). Some M5Stack devices - like M5Paper (non S3 version) - can not power off while being powered from USB so the current code in Power_Class does the following: it sets up both, RTC alarm and ESP sleep functions (e.g. deep sleep and light sleep). It then first attempts to power off - which works when powered from battery, so the code execution ends here. However when powered from USB, power off does nothing and the 'backup' ESP sleep functions take over.

          So with M5PaperS3 and the current state of Power_Class when you call timerSleep(int seconds) it works because ESP sleep function is setup and can take over. However when you call the other timerSleep() functions nothing happens as the ESP sleep functions are not setup here and power off isn't implemented yet.

          And when you call setAlarmIRQ(30) and powerOff() manually nothing happens either - same reason again - power off is not implemented yet.

          BTW: you can still test your code though - during the 30 seconds you can double-click the side button to actually power off M5Paper and when the time is up it should power on again.

          Thanks
          Felix

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

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