Skip to content

Commit

Permalink
Merge pull request meshtastic#3545 from todd-herbert/paper-deepsleep-…
Browse files Browse the repository at this point in the history
…current

Reduce deep-sleep current for Heltec Wireless Paper
  • Loading branch information
caveman99 authored Apr 4, 2024
2 parents 46ad4bf + 30ebb6a commit f0b6ff9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nimble/NimbleBluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ void NimbleBluetooth::shutdown()
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->reset();
pAdvertising->stop();

#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0)
// Saving of ~1mA
// Probably applicable to other ESP32 boards - unverified
NimBLEDevice::deinit();
#endif
}

bool NimbleBluetooth::isActive()
Expand Down
11 changes: 11 additions & 0 deletions src/sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
if (shouldLoraWake(msecToWake)) {
enableLoraInterrupt();
}

#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0) // Applicable to most ESP32 boards?
// Avoid leakage through button pin
pinMode(BUTTON_PIN, INPUT);
rtc_gpio_hold_en((gpio_num_t)BUTTON_PIN);

// LoRa CS (RADIO_NSS) needs to stay HIGH, even during deep sleep
pinMode(LORA_CS, OUTPUT);
digitalWrite(LORA_CS, HIGH);
rtc_gpio_hold_en((gpio_num_t)LORA_CS);
#endif
#endif
cpuDeepSleep(msecToWake);
}
Expand Down

0 comments on commit f0b6ff9

Please sign in to comment.