pdf-icon

Arduino Quick Start

2. Devices & Examples

Capsule Wakeup

M5Capsule sleep-wake related APIs and case programs.

Note:
The power cannot be turned off and hibernate under USB power supply condition. The function works only under battery power condition.
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <M5Capsule.h>
void setup(void) {
auto cfg = M5.config();
M5Capsule.begin(cfg);
Serial.println("Press Btn to sleep");
Serial.println("After 5s Wakeup");
}
void loop(void) {
M5Capsule.update();
if (M5Capsule.BtnA.wasPressed()) {
M5Capsule.Power.timerSleep(5);
// M5Capsule.Power.timerSleep(const rtc_time_t& time);
// M5Capsule.Power.timerSleep(const rtc_date_t& date, const rtc_time_t&
// time);
// M5Capsule.Power.powerOff(); shutdown
}
}

API

The M5Capsule library is based on the M5Unified library implementation, the power supply part uses the Power_Class from the M5Unified library, for more related APIs you can refer to the following document:

On This Page