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, ®);
// 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