pdf-icon

Arduino Quick Start

2. Devices & Examples

Basic/Gray/M5GO Wakeup

Basic/Gray/M5GO 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
#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", M5.Display.width() / 2, M5.Display.height() / 2 - 20);
  M5.Display.drawString("to Sleep 5s", M5.Display.width() / 2, M5.Display.height() / 2 + 20);
}

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

  if (M5.BtnA.wasPressed()) {
    M5.Display.clear();
    M5.Display.drawString("Sleep 5s", M5.Display.width() / 2, M5.Display.height() / 2 + 20);
    M5.Power.timerSleep(5);//sec
  }
}

Since there is no independent RTC chip, The Fire cannot use RTC-related functions and can only implement second-level timed wake-up as demonstrated in the example program.

The example program runs as follows:

API

Basic/Gray/M5GO Power section uses the Power_Class in the M5Unified library. For more related APIs, you can refer to the following document:

On This Page