power measurement work

1.2-legacy
geeksville 2020-02-11 16:04:25 -08:00
rodzic 5aaae9c4fe
commit 03eaef2c8f
2 zmienionych plików z 23 dodań i 1 usunięć

Wyświetl plik

@ -1,5 +1,7 @@
# High priority
* platformio sdkconfig CONFIG_PM and turn on modem sleep mode
* finish power measurements and est battery life
* have node info screen show real info (including time since last contact, distance and heading)
* make debug info screen show real data (including battery level & charging)
* make real implementation of getNumOnlineNodes
@ -27,7 +29,7 @@
* keep cpu 100% in sleep (some sort - deep?) Sleep until irq from radio wakes it (make plan based on power draw spreadsheet). Then stay awake for 30 secs to attempt delivery to phone.
* have radiohead ISR send messages to RX queue directly, to allow that thread to block until we have something to send
* use https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/ association sleep pattern to save power - but see https://github.com/espressif/esp-idf/issues/2070
* use https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/ association sleep pattern to save power - but see https://github.com/espressif/esp-idf/issues/2070 and https://esp32.com/viewtopic.php?f=13&t=12182 it seems with BLE on the 'easy' draw people are getting is 80mA
* stop using loop() instead use a job queue and let cpu sleep
* move lora rx/tx to own thread and block on IO
* measure power consumption and calculate battery life assuming no deep sleep

Wyświetl plik

@ -145,6 +145,23 @@ void doDeepSleep(uint64_t msecToWake)
esp_deep_sleep_start(); // TBD mA sleep current (battery)
}
#include "esp32/pm.h"
#include "esp_pm.h"
/**
* enable modem sleep mode as needed and available. Should lower our CPU current draw to an average of about 20mA.
*
* per https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/power_management.html
*/
void enableModemSleep() {
static esp_pm_config_esp32_t config; // filled with zeros because bss
config.max_freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ;
config.min_freq_mhz = 10; // 10Mhz is minimum recommended
config.light_sleep_enable = false;
DEBUG_MSG("Sleep request result %x\n", esp_pm_configure(&config));
}
void sleep()
{
#ifdef SLEEP_MSECS
@ -366,6 +383,8 @@ void setup()
BLEServer *serve = initBLE(getDeviceName(), HW_VENDOR, APP_VERSION); // FIXME, use a real name based on the macaddr
createMeshBluetoothService(serve);
}
enableModemSleep();
}
void loop()
@ -425,6 +444,7 @@ void loop()
if (!wasPressed)
{ // just started a new press
DEBUG_MSG("pressing\n");
esp_pm_dump_locks(stdout); // FIXME, do this someplace better
wasPressed = true;
minPressMs = millis() + 3000;
screen_press();