Hi folks,
Quite a few of you around here use deepsleep with pin wakeup: most importantly esp_sleep_enable_ext0_wakeup or esp_sleep_enable_ext1_wakeup. As many of you know, by default this increases the power consumption many-fold, with most V3 boards seeing a jump from roughly 20uA to 120uA which is rather painful.
After some digging around today, I have managed to tackle this problem with help from this issue.
A normal sketch to put the VME213 into deepsleep with wakeup from the user-button would look like this:
void deepsleep() {
  esp_sleep_enable_ext0_wakeup((gpio_num_t)21, LOW); // configure pin 21 as wakeup on LOW signal
  esp_deep_sleep_start();                            // start deepsleep
}
The Arduino-ESP32 package however automatically adds internal pull-up resistors on esp_deep_sleep_start, which are unnecessary as Heltec already integrated these into their design. As such, this should be âblockedâ in your code. The solution looks like this:
void deepsleep() {
  esp_sleep_enable_ext0_wakeup((gpio_num_t)21, LOW); // configure pin 21 as wakeup on LOW signal
  pinMode(21, OUTPUT);
  digitalWrite(21, HIGH);                            // set pin 21 to HIGH manually
  gpio_hold_en((gpio_num_t)21);                      // force pin 21 to stay HIGH
  gpio_deep_sleep_hold_en();                         // force all pins to keep their state during deepsleep
  esp_deep_sleep_start();                            // start deepsleep
}
Now enjoy zero additional power consumption during deepsleep!
Note that this applies to all V3 boards, not just the VME213 mentioned in the example!
Edit: refer to comment 8 for a crucial line to make this work in the Heltec_ESP32 framework.
 
      
    