M5Stack CoreInk RTC does not boot the device



  • Hi everyone!

    I can't get my M5Stack CoreInk RTC to boot the device. I came across this forum and could not find anyone with similar problems, but everyone here seems really helpful, so I hope you might be able to help me.

    I am working on this project where we use an M5Stack CoreInk and ESP-IDF, not this library. My goal is to turn off everything in the device except for the RTC and have the RTC boot the device. I do not have trouble turning off the device on battery by pulling GPIO12 LOW after setting the RTC's alarm, but i do have trouble booting it again. This is all without having USB-power connected, since I want to use its internal battery.

    I use the following code to see if the RTC alarm is set correctly and if the RTC interrupt signal works as it should (the code works when i provide USB-power because that prevents the device from turning off):

               // Set RTC alarm.
                rtc_set_alarm(nextTaskTime_s);
                
                // Pull GPIO12 LOW.
                // When not on USB-power, the device does turn off here.
                powerpin_reset();
    
                // This will run when USB power is supplied for testing.
                while (true)
                {
                    // Read RTC alarm flag.
                    uint8_t reg;
                    bm8563_ioctl(&bm8563, BM8563_CONTROL_STATUS2_READ, &reg);
    
                    // Get the time from the RTC and print it to the console.
                    rtc_print_time();
    
                    // Get the RTC alarm.
                    auto rtcTime = rtc_get_alarm();
                    
                    // Print the alarm time and RTC clock time to the console.
                    ESP_LOGI(TAG,
                             "RTC alarm time: %d:%d, wday (0 = sun) %d, mday %d.\n"
                             "RTC alarm flag: %s.\n"
                             "RTC Interrupt: %s",
                             (localtime(&rtcTime))->tm_hour,
                             (localtime(&rtcTime))->tm_min,
                             (localtime(&rtcTime))->tm_wday,
                             (localtime(&rtcTime))->tm_mday,
                             reg & BM8563_AF ? "1" : "0",
                             gpio_get_level(GPIO_NUM_19) ? "HIGH" : "LOW");
                }
    

    This is the console output when before the alarm is triggered:

    D (8095) print: RTC clock time: Thu Jul 28 13:37:26 2022 (day 209)
    
    I (8095) Scheduler: RTC alarm time: 13:38, wday (0 = sun) 4, mday 28.
    RTC alarm flag: 0.
    RTC Interrupt: HIGH
    

    The first line shows the current time of the RTC clock (which is correct).
    The second line is what the RTC alarm is set to.
    The third line is the alarm flag (which should turn to 1 when triggered).
    The last line shows the RTC interrupt signal (which is connected to GPIO19 and should be LOW when triggered).

    This is the console output when before the alarm is triggered:

    D (88485) print: RTC clock time: Thu Jul 28 13:38:02 2022 (day 209)
    
    I (88485) Scheduler: RTC alarm time: 13:38, wday (0 = sun) 4, mday 28.
    RTC alarm flag: 1.
    RTC Interrupt: LOW
    

    The first line shows the current time of the RTC clock (which is correct). Time is still correct.
    The second line is what the RTC alarm is set to. It is still the same.
    The third line is the alarm flag (which should turn to 1 when triggered). It is now.
    The last line shows the RTC interrupt signal (which is connected to GPIO19 and should be LOW when triggered). It is now.

    So when I keep USB power connected, it seems to all work correctly, at least to me. When I disconnect the USB and boot the device by holding the power button on the side, it will turn on (I turn on an LED when it is on). It will however, not turn back on when the RTC alarm and interrupt fires.

    Thanks!
    Nick



  • Hello @nick-vr

    your code works fine on my M5CoreInk. I've tried with 20 seconds and 70 seconds shutdown time.

    That said, there were / are some anomalies with newer M5CoreInk devices which use the CH9102 USB serial chip. See here and here.

    Thanks
    Felix



  • Hi @felmue

    Thanks for your answer, sorry for my late reply. Apparently I forgot to watch this topic.

    I think I did find both topics that you linked, but they seem to have a slightly different problem than me, since I don't have a problem with turning the device off and I want to wake the device up with the RTC all without having the USB-power connected.

    By "your code works fine on my M5CoreInk. I've tried with 20 seconds and 70 seconds shutdown time.", do you mean that it shuts down and boots after 20 or 70 seconds without USB-power connected?



  • Hello @nick-vr

    yes, that is what I mean, my M5CoreInk does shutdown and then boot again after 20 or 70 seconds with your code and USB-power not connected.

    Note: the M5CoreInk I was using to test doesn't yet have the CH9102. (If that is relevant to your issue I don't know though.)

    Thanks
    Felix



  • After a lot of testing I came to the following conclusion:

    The problem was that I waited too long before enabling GPIO pin 12 in my code. This pin is used to keep the device powered by the battery.

    I'm just speculating here, but it seems like there is a time frame in which you need to enable this pin, otherwise the device will not successfully boot.

    Thanks!
    Nick