pdf-icon

Arduino Quick Start

PaperS3 Wakeup

PaperS3 sleep and wake-up related APIs and example programs.

Example Program

Build Requirements

  • M5Stack board manager version >= 2.1.4
  • Board selection = M5PaperS3
  • M5Unified library version >= 0.2.5
  • M5GFX library version >= 0.2.7
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>
#include <M5GFX.h>
int myIndex = 0;
void setup() {
M5.begin();
M5.Display.setRotation(0);
M5.Display.setFont(&fonts::FreeMonoBold24pt7b);
M5.Display.clear();
M5.Display.print("Sleep & Wakeup Test\n");
}
void loop() {
myIndex++;
M5.Display.setCursor(0, 100);
M5.Display.printf(" %4d", myIndex);
delay(250);
if (myIndex % 20 == 0) {
// M5.Power.timerSleep(5); // in seconds
// M5.Power.deepSleep(5000000, false); // in microseconds
M5.Power.lightSleep(5000000, false); // in microseconds
M5.Display.clear();
M5.Display.setCursor(0, 0);
M5.Display.print("Sleep & Wakeup Test\n");
}
if (myIndex >= 1000) {
myIndex = 0;
}
}

This program displays a counter that starts from 0 and increments by 1. Whenever it reaches a multiple of 20, the device enters light sleep for 5 seconds and then wakes up to continue running. If you modify the program to use timed sleep or deep sleep (the two commented-out lines), the device will restart the entire program upon waking up.

API

The sleep and wake-up functions of the PaperS3 use the Power_Class from the M5Unified library. For more related APIs, refer to the documentation below:

On This Page