This post describes a summary of the following conditions for the power supply/management of M5Paper.

  • Powered by USB Type-C or not
  • “Shutdown” or “DeepSleep”

The following figure is an excerpt from the outline diagram on the back of the M5Paper that relates to the power supply.

MOS BM 8563 BATTERY ESP32 D0WDQ6-V3 16M-FLASH 8M-PSRAM Li-Po 1150mAh 4.35V SY 7088 5V BUS SLM6635 USB-C G2 SDA21 SCL22 PWR G38
M5Paper Power Supply Outline Diagram

The following conditions must be achieved to keep the power ON:

  • Powered by USB Type-C;
  • Alarm IRQ from RTC (BM8563);
  • GPIO2 (M5EPD_MAIN_PWR_PIN) set to HIGH; or
  • Power button (GPIO38, M5EPD_KEY_PUSH_PIN)

Shutdown is achieved by setting all the above conditions to false. It indicates as long as M5Paper is connected and powered by USB Type-C, always it cannot shutdown.

Then how is the shutdown process of sample programs such as FactoryTest handled? The process is as follows:

void Shutdown()
{
    // **snip**
    M5.disableEPDPower();  // digitalWrite(M5EPD_EPD_PWR_EN_PIN, 0);
    M5.disableEXTPower();  // digitalWrite(M5EPD_EXT_PWR_EN_PIN, 0);
    M5.disableMainPower(); // digitalWrite(M5EPD_MAIN_PWR_PIN, 1);
    esp_deep_sleep_start();
    while(1);
}

If USB Type-C is connected, M5.disableMainPower() (setting GPIO2 to OFF) does not turn off its power and go to the next line and then deep sleep, not a genuine shutdown. If not, it shutdown immediately after M5.disableMainPower() (setting GPIO2 to OFF) and esp_deep_sleep_start() does not executed.

Case: Shutdown / Connected and Powered by USB Type-C

As long as M5Paper is connected and powered by USB Type-C, always one condition “Powered by USB Type-C” is true and it cannot shutdown.

Powered by USB Type-C

After M5.disableMainPower() executed (setting GPIO2 to OFF), the MOS output is still HIGH and the power is still ON.

Powered by USB Type-C, After main power disabled

After that, if the USB Type-C cable unplugged further, the power goes off. Because the MOS output gets LOW.

Powered by USB Type-C, After main power disabled and then USB Type-C unplugged

At this time, it is re-booted by pressing the PWR button, interrupt by the RTC Alarm, or plugging USB Type-C.

Case: Shutdown / USB Type-C Unpuggled

Other hand, if the USB Type-C cable is unplugged without calling M5.disableMainPower(), the GPIO2 output remains HIGH. Therefore, the power remains ON and is supplied from the LiPo battery.

It is the same condition as just after booting without the USB Type-C power supply.

After USB Type-C unplugged

After M5.disableMainPower() executed (setting GPIO2 to OFF), the MOS output and the power go off.

After USB Type-C unplugged and set GPIO2 to OFF

At this time, it is re-booted by pressing the PWR button, interrupt by the RTC Alarm, or plugging USB Type-C.

Case: Deep sleep / Connected and Powered by USB Type-C

The ESP32 immediately stops operating when it goes to deep sleep. The output of GPIO2 goes LOW. Because GPIOs do not keep their state in deep sleep to conserve power.

Deep sleep, powered by USB Type-C

Pressing the PWR button etc… does not wake up or restart from the deep sleep status. Because the MOS output remains HIGH and unchanged.

The ESP32 remains powered by USB Type-C, so the ULP coprocessor works. ESP32 wake-up functions such as esp_sleep_enable_timer_wakeup() or ULP coprocessor program can be used.

Case: Deep sleep / USB Type-C Unpuggled

The ESP32 immediately stops operating when it goes to deep sleep. The output of GPIO2 goes LOW. Because GPIOs do not keep their state in deep sleep to conserve power.

When USB Type-C Unpuggled, such a process causes MOS output to OFF and a transition to a state equivalent to a genuine shutdown.

After Deep sleep and USB Type-C unplugged

The ESP32 is not powered, so the ULP coprocessor does not work. esp_sleep_enable_timer_wakeup() or ULP coprocessor program cannot be used for wake-up.

At this time, it is re-booted by pressing the PWR button, interrupt by the RTC Alarm, or plugging USB Type-C.

It is possible to change this behaviour to add following to lines before going to deep sleep.

gpio_hold_en((gpio_num_t) M5EPD_MAIN_PWR_PIN);
gpio_deep_sleep_hold_en();
// ...snip...
esp_deep_sleep_start();

In this case, it keeps the GPIO2 even during deep sleep.

Deep sleep with keeping GPIO2 to HIGH, powered by USB Type-C

In this case, pressing the PWR button etc… does not wake up or restart from the deep sleep status. Because GPIO2 keeps HIGH and the MOS output remains HIGH and unchanged.

The ESP32 remains powered by the LiPo battery, so the ULP coprocessor works. ESP32 wake-up functions such as esp_sleep_enable_timer_wakeup() or ULP coprocessor program can be used.

Note: RTC Alarm issue

When writing a program to reboot using RTC (BM8563) Alarm, be aware of the following bugs!

  • https://github.com/m5stack/M5EPD/issues/26
  • https://github.com/m5stack/M5-CoreInk/pull/3

References