Note: M5Paper Power Supply/Management
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.
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.
After M5.disableMainPower()
executed (setting GPIO2 to OFF), the MOS output is still HIGH and the power is still ON.
After that, if the USB Type-C cable unplugged further, the power goes off. Because the MOS output gets LOW.
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 M5.disableMainPower()
executed (setting GPIO2 to OFF), the MOS output and the power go 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.
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.
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.
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
- M5Paper, M5Stack
- M5Paper Shutdown() / Deep Sleep / Wakeup | M5Stack Community
- M5Stack CoreInk、M5Paperのバッテリーについて | Lang-ship (Japanese)
- Low-Cost, µP Supervisory Circuits - BM8563, BM8563 Datasheet, Shanghai Belling (Chinese)