Thank you @ZinggJM
it is working, I hope below code will help some newbie like me who looking for
ESP32 Deep Sleep eInk Partial Update with GxEPD2
The serial debug log said it is came from deep sleep.
but from the usb power monitor, while ePaper actively changing, it used 0.32w (4.220v 0.6708a). while it is in deep sleep, it used 0.10w (4.9152v 0.0212a)
maybe something is lost in the hardware, like 5v to 3.3v?
not a hardware guy, anyone know which board has the lowest power consumption during deep sleep?
#define ENABLE_GxEPD2_GFX 0
#include <GxEPD2_BW.h>
#include <rom/rtc.h>
// Waveshare 7.5 inch 800*480 v2 Black White
GxEPD2_BW<GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT> display(GxEPD2_750_T7(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEW075T7 800x480
RTC_DATA_ATTR int bootCount = 0;
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
int TIME_TO_SLEEP = 10;
int box_width = 50;
void setup()
{
Serial.begin(115200);
delay(1000); //Take some time to open up the Serial Monitor
if (bootCount == 0)
{
display.init(115200); // uses standard SPI pins, e.g. SCK(18), MISO(19), MOSI(23), SS(5)
}
else
{
display.init(115200, false); // uses standard SPI pins, e.g. SCK(18), MISO(19), MOSI(23), SS(5)
}
// ********************************************************* //
// *** special handling for Waveshare ESP32 Driver board *** //
SPI.end(); // release standard SPI pins, e.g. SCK(18), MISO(19), MOSI(23), SS(5)
//SPI: void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
SPI.begin(13, 12, 14, 15); // map and init SPI pins SCK(13), MISO(12), MOSI(14), SS(15)
// *** end of special handling for Waveshare ESP32 Driver board *** //
// **************************
display.setPartialWindow(0, 0, display.width(), display.height());
display.fillScreen(GxEPD_WHITE);
int x = random(0, display.width() - box_width);
int y = random(0, display.height() - box_width);
display.firstPage();
do
{
display.fillRect(x, y, box_width, box_width, GxEPD_BLACK);
}
while (display.nextPage());
// do not use display.hibernate() , as previous screen shadow will show after wake up.
display.powerOff();
//Increment boot number and print it every reboot
Serial.println("Boot number: " + String(++bootCount));
//Print the wakeup reason for ESP32
verbose_print_reset_reason(rtc_get_reset_reason(0));
print_wakeup_reason();
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
Serial.println("set to sleep for every " + String(TIME_TO_SLEEP) + " Seconds");
Serial.flush();
esp_deep_sleep_start();
}
void loop() {};
void verbose_print_reset_reason(RESET_REASON reason)
{
switch ( reason)
{
case 1 : Serial.println ("Vbat power on reset");break;
case 3 : Serial.println ("Software reset digital core");break;
case 4 : Serial.println ("Legacy watch dog reset digital core");break;
case 5 : Serial.println ("Deep Sleep reset digital core");break;
case 6 : Serial.println ("Reset by SLC module, reset digital core");break;
case 7 : Serial.println ("Timer Group0 Watch dog reset digital core");break;
case 8 : Serial.println ("Timer Group1 Watch dog reset digital core");break;
case 9 : Serial.println ("RTC Watch dog Reset digital core");break;
case 10 : Serial.println ("Instrusion tested to reset CPU");break;
case 11 : Serial.println ("Time Group reset CPU");break;
case 12 : Serial.println ("Software reset CPU");break;
case 13 : Serial.println ("RTC Watch dog Reset CPU");break;
case 14 : Serial.println ("for APP CPU, reseted by PRO CPU");break;
case 15 : Serial.println ("Reset when the vdd voltage is not stable");break;
case 16 : Serial.println ("RTC Watch dog reset digital core and rtc module");break;
default : Serial.println ("NO_MEAN");
}
}
void print_wakeup_reason()
{
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
}
}