Reduce sender power draw (RX windows + CPU/WiFi/ADC/pins)
- Add LoRa idle/sleep/receive-window helpers and use short RX windows for ACK/time sync - Schedule sender time-sync windows (fast/slow) and track RX vs sleep time in debug - Lower sender power (80 MHz CPU, WiFi/BT off, reduced ADC sampling, unused pins pulldown) - Make SERIAL_DEBUG_MODE a build flag, add prod envs with debug off, and document changes
This commit is contained in:
@@ -10,7 +10,10 @@ static constexpr float BATTERY_CAL = 1.0f;
|
||||
static constexpr float ADC_REF_V = 3.3f;
|
||||
|
||||
void power_sender_init() {
|
||||
setCpuFrequencyMhz(80);
|
||||
WiFi.mode(WIFI_OFF);
|
||||
esp_wifi_stop();
|
||||
esp_wifi_deinit();
|
||||
btStop();
|
||||
analogReadResolution(12);
|
||||
pinMode(PIN_BAT_ADC, INPUT);
|
||||
@@ -22,14 +25,19 @@ void power_receiver_init() {
|
||||
pinMode(PIN_BAT_ADC, INPUT);
|
||||
}
|
||||
|
||||
void read_battery(MeterData &data) {
|
||||
const int samples = 8;
|
||||
uint32_t sum = 0;
|
||||
for (int i = 0; i < samples; ++i) {
|
||||
sum += analogRead(PIN_BAT_ADC);
|
||||
delay(5);
|
||||
void power_configure_unused_pins_sender() {
|
||||
// Board-specific: only touch pins that are known unused and safe on TTGO LoRa32 v1.6.1
|
||||
const uint8_t pins[] = {32, 33};
|
||||
for (uint8_t pin : pins) {
|
||||
pinMode(pin, INPUT_PULLDOWN);
|
||||
}
|
||||
float avg = static_cast<float>(sum) / samples;
|
||||
}
|
||||
|
||||
void read_battery(MeterData &data) {
|
||||
uint32_t sum = 0;
|
||||
sum += analogRead(PIN_BAT_ADC);
|
||||
sum += analogRead(PIN_BAT_ADC);
|
||||
float avg = static_cast<float>(sum) / 2.0f;
|
||||
float v = (avg / 4095.0f) * ADC_REF_V * BATTERY_DIVIDER * BATTERY_CAL;
|
||||
|
||||
data.battery_voltage_v = v;
|
||||
|
||||
Reference in New Issue
Block a user