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

    M5Paper Shutdown() / Deep Sleep / Wakeup

    Cores
    9
    15
    26.6k
    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.
    • felmueF
      felmue
      last edited by

      Hello @grundprinzip

      no worries. Thank you for sharing your conclusion. I appreciate it.

      Thanks
      Felix

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

      1 Reply Last reply Reply Quote 0
      • T
        Tbob
        last edited by

        Hi,
        I'm currently using this small work-around to differenciate the power source between battery and USB.
        It basically involves monitoring the voltage after initializing M5.BatteryADCBegin() (via M5.getBatteryVoltage() to be more precise). Measuring a voltage over 4200 mV (empirically evaluated!) indicates most of the time a USB-usage. Under that value, there are high chances that the device is on battery.
        So far, this work-around is doing its job pretty well for me.
        I hope it might help!
        Cheers,
        t.

        1 Reply Last reply Reply Quote 0
        • M
          middelbeek @felmue
          last edited by

          @felmue , I tried your proposal with Arduino IDE and my M5Stack Paper:

          gpio_hold_en(M5EPD_MAIN_PWR_PIN);
          gpio_deep_sleep_hold_en();

          but get an error :

          invalid conversion from 'int' to 'gpio_num_t' [-fpermissive]

          Whats going wrong?

          Hans

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

            Hello @middelbeek

            sorry about that. Try:

                gpio_hold_en((gpio_num_t) M5EPD_MAIN_PWR_PIN);
                gpio_deep_sleep_hold_en();
            

            Thanks
            Felix

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

            M 1 Reply Last reply Reply Quote 1
            • M
              middelbeek @felmue
              last edited by

              @felmue Super, now it works! Thanks, Hans

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

                Hello @middelbeek

                Thank you for reporting back. I am glad 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
                • JopJ
                  Jop
                  last edited by

                  As I promised here at end of my post under another thread, the shutdown() is rather buggy in the way awakening is performed.
                  I'll describe here what I experienced.

                  Anyway one should take this advice of @felmue in account.
                  There are different shutdown() overload variations and here bugs or weird things I found.

                  My goal was holding the M5Paper as much as possible sleeping, but at intervals of every full 5 minutes he should awake for about 10 to 15 seconds, perform some tasks (sensors) and go again sleeping to the next full 5-minute moment.

                  • overload-2 int shutdown( int seconds );
                    Even if I calc enough seconds to next 5-minute moment, it seems impossible to stay asleep for remaining 5 minutes. Every 3th minute it is awakening too. This consumes unnecessary double battery power.
                    So where I want to have this wake up schedule: hh:00 hh:05 hh:10 hh:15 hh:20 ...and so on...
                    I get this wake up schedule: hh:00 hh:03 hh:05 hh:08 hh:10 hh:13 hh:15 hh:18 hh:20 ...and so on...
                    This overload-2 has no problems by passing the midnight moment.

                  • overload-3
                    int shutdown( const rtc_time_t &RTC_TimeStruct );
                    This variation works best. Passing midnight (so date change) is no problem but 24:00u should be given als 00:00u.

                  • overload-4
                    int shutdown( const rtc_date_t &RTC_DateStruct, const rtc_time_t &RTC_TimeStruct );
                    is working, but passing midnight in a way to set awake time at 00:00h and increasing the date-parameter does NOT work! Also 24:00u without increasing the date does NOT work.
                    The only way to pass midnight is awaking just some seconds before midnight and stay awake till after midnight, do the things that has to be done (sample sensors) and go asleep for remaining period (in my case to 00:05u).

                  I hope others can take advantage of this info.

                  Kind regards,

                  Jop
                  
                  1 Reply Last reply Reply Quote 0
                  • C
                    casascius
                    last edited by

                    I'm coming in a bit late, but fought with this a little bit.

                    For me, shutdown() wouldn't wake up at all. The ultimate cause was that the i2c bus wasn't getting properly initialized (another issue for another post -- touchpanel related) so the command to the clock chip was never getting sent.

                    Once it got sent, doing a shutdown(10) to wake up after 10 seconds worked properly for me... in fact, so properly, you couldn't turn the device off because the alarm persists until deactivated. shutdown(-1) in setup() (after initializing i2c) is necessary to clear the timer alarm upon sketch restart (which I determined by inspecting the library source).

                    Also by inspecting the source and datasheet, overload 4 that Jop says isn't working, I am guessing is because he only advanced the day of month. It looks as though the clock chip compares not just hour/minute/day, but also the day of week (e.g. Thursday) and, reviewing the source code, it doesn't ever consider the month or year at all, nor does the chip even have registers to alarm on these. But it has one for the weekday, so if you don't advance the weekday, the comparison will fail per the datasheet.

                    T 1 Reply Last reply Reply Quote 0
                    • T
                      timattrn @casascius
                      last edited by timattrn

                      @casascius How did you even get that far? I have made a project using the new Unified library, and I can not even find the shutdown() functions at all.
                      EDIT: with the unified library, I am simply trying:

                      M5.Power.timerSleep(600);

                      Even when on USB power, this is 'caught', and so far wakeup is reliable.

                      1 Reply Last reply Reply Quote 0
                      • C
                        Cognitive5525
                        last edited by

                        @jop said in M5Paper Shutdown() / Deep Sleep / Wakeup:

                        overload-2 int shutdown( int seconds );

                        The timer function of the BM8563* is based on a 8 bit counter which can be set to be controlled by a clock frequency of 4096, 64, 1 or 1/60 Hz. This means it can timeout with following max interval @ resolution:

                        62,3 ms @ 244,1 µs
                        4 s @ 15,5 ms
                        255 s @ 1 s
                        15300 s (255 min) @ 60 s (1 min)

                        so intervals above 255 seconds (4 min and 25 seconds) needs to be timed at one minute resolution.
                        I have however tested this on my CoreINK (UiFlow/mocropython) and found that it rounds down in intervals of 2 minutes (120 s) for some reason.
                        I made a script to that just put the unit to sleep but increases the sleep interval with 10 sec every time and then uses the clock to measure the actual sleep time. This was the result:

                        0_1683278473886_4835f713-9fcf-4986-a3f7-f9f9ca8e3512-image.png

                        *) BM8563 datasheet

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