pdf-icon

Arduino Quick Start

2. Devices & Examples

Core2 Wakeup

Core2 Wakeup related APIs and example program.

Example

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#include <M5Unified.h>

void setup(void) {
  auto cfg = M5.config();
  M5.begin(cfg);

  M5.Display.setTextDatum(middle_center);
  M5.Display.setTextFont(&fonts::FreeSerifBold9pt7b);
  M5.Display.setTextSize(1);

  M5.Display.drawString("Press BtnA to Sleep", M5.Display.width() / 2, M5.Display.height() / 2 - 20);

  //RTC wakeup must use following code
  // m5::rtc_time_t time = {  9 , 0 , 55};//hour,min,sec  
  // m5::rtc_date_t date = {2025, 1 ,  1 , 1};//year,mon,date,wed
  // M5.Rtc.setTime(date);
  // M5.Rtc.setTime(time);
}

void loop(void) {
  M5.update();

  if (M5.BtnA.wasPressed()) {
    M5.Display.clear();

    M5.Power.timerSleep(5);//sec
    // m5::rtc_time_t time = {9, 1, 0};
    // m5::rtc_date_t date = {2025, 1 ,  1 , 1}
    // M5.Power.timerSleep(time);
    // M5.Power.timerSleep(date, time);
    // M5.Power.powerOff(); 
  }
}

The example program runs as follows:

API

Core2 Power section uses the Power_Class in the M5Unified library. For more related APIs, you can refer to the following documents:

On This Page