sforkowany z mirror/meshtastic-firmware
isolate gpios for minimum deep sleep current draw
rodzic
02ed249374
commit
be8df34722
|
@ -42,7 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#define DEBUG_PORT Serial // Serial debug port
|
#define DEBUG_PORT Serial // Serial debug port
|
||||||
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
||||||
#define SLEEP_MSECS (24 * 60 * 60 * 1000) // Sleep for these many millis (or a button press or a lora msg?)
|
#define SLEEP_MSECS (30 * 24 * 60 * 60 * 1000LL) // Sleep for these many millis (or a button press or a lora msg?)
|
||||||
#define MESSAGE_TO_SLEEP_DELAY 5000 // Time after message before going to sleep
|
#define MESSAGE_TO_SLEEP_DELAY 5000 // Time after message before going to sleep
|
||||||
#define LOGO_DELAY 5000 // Time to show logo on first boot
|
#define LOGO_DELAY 5000 // Time to show logo on first boot
|
||||||
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
||||||
|
|
38
src/main.ino
38
src/main.ino
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "rom/rtc.h"
|
#include "rom/rtc.h"
|
||||||
|
#include <driver/rtc_io.h>
|
||||||
#include <TinyGPS++.h>
|
#include <TinyGPS++.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "BluetoothUtil.h"
|
#include "BluetoothUtil.h"
|
||||||
|
@ -56,6 +57,8 @@ void doDeepSleep(uint64_t msecToWake)
|
||||||
// not using wifi yet, but once we are this is needed to shutoff the radio hw
|
// not using wifi yet, but once we are this is needed to shutoff the radio hw
|
||||||
// esp_wifi_stop();
|
// esp_wifi_stop();
|
||||||
|
|
||||||
|
BLEDevice::deinit(false); // We are required to shutdown bluetooth before deep or light sleep
|
||||||
|
|
||||||
screen_off(); // datasheet says this will draw only 10ua
|
screen_off(); // datasheet says this will draw only 10ua
|
||||||
|
|
||||||
// FIXME, shutdown radiohead interrupts before powering off device
|
// FIXME, shutdown radiohead interrupts before powering off device
|
||||||
|
@ -63,6 +66,18 @@ void doDeepSleep(uint64_t msecToWake)
|
||||||
// Put radio in sleep mode (will still draw power but only 0.2uA)
|
// Put radio in sleep mode (will still draw power but only 0.2uA)
|
||||||
radio.sleep();
|
radio.sleep();
|
||||||
|
|
||||||
|
#ifdef RESET_OLED
|
||||||
|
digitalWrite(RESET_OLED, 1); // put the display in reset before killing its power
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef VEXT_ENABLE
|
||||||
|
digitalWrite(VEXT_ENABLE, 1); // turn off the display power
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LED_PIN
|
||||||
|
digitalWrite(LED_PIN, 0); // turn off the led
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef T_BEAM_V10
|
#ifdef T_BEAM_V10
|
||||||
if (axp192_found)
|
if (axp192_found)
|
||||||
{
|
{
|
||||||
|
@ -72,9 +87,26 @@ void doDeepSleep(uint64_t msecToWake)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VEXT_ENABLE
|
/*
|
||||||
digitalWrite(VEXT_ENABLE, 1); // turn off the display power
|
Some ESP32 IOs have internal pullups or pulldowns, which are enabled by default.
|
||||||
#endif
|
If an external circuit drives this pin in deep sleep mode, current consumption may
|
||||||
|
increase due to current flowing through these pullups and pulldowns.
|
||||||
|
|
||||||
|
To isolate a pin, preventing extra current draw, call rtc_gpio_isolate() function.
|
||||||
|
For example, on ESP32-WROVER module, GPIO12 is pulled up externally.
|
||||||
|
GPIO12 also has an internal pulldown in the ESP32 chip. This means that in deep sleep,
|
||||||
|
some current will flow through these external and internal resistors, increasing deep
|
||||||
|
sleep current above the minimal possible value.
|
||||||
|
|
||||||
|
Note: we don't isolate pins that are used for the LED, i2c, spi or the wake button
|
||||||
|
*/
|
||||||
|
static const uint8_t rtcGpios[] = { /* 0, */ 2,
|
||||||
|
/* 4, */ 12,13, /* 14, */ /* 15, */
|
||||||
|
/* 25, */ 26, /* 27, */
|
||||||
|
32,33,34,35,36,37,/* 38, */ 39 };
|
||||||
|
|
||||||
|
for(int i = 0; i < sizeof(rtcGpios); i++)
|
||||||
|
rtc_gpio_isolate((gpio_num_t) rtcGpios[i]);
|
||||||
|
|
||||||
// FIXME - use an external 10k pulldown so we can leave the RTC peripherals powered off
|
// FIXME - use an external 10k pulldown so we can leave the RTC peripherals powered off
|
||||||
// until then we need the following lines
|
// until then we need the following lines
|
||||||
|
|
Ładowanie…
Reference in New Issue