Skip to content

Commit

Permalink
Improve power usage by ~20mA by reducing CPU clock
Browse files Browse the repository at this point in the history
  • Loading branch information
OK2MOP committed Dec 26, 2022
1 parent 1cc682a commit ee4d984
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/LoRa_APRS_Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
#include <OneButton.h>
#include <TimeLib.h>
#include <TinyGPS++.h>
#include <WiFi.h>
#ifdef ESP32
# include <WiFi.h>
#endif
#include <logger.h>

#ifdef ESP32
# include <driver/adc.h>
# include <esp_bt.h>
#endif
#include "BeaconManager.h"
#include "configuration.h"
#include "display.h"
Expand Down Expand Up @@ -91,10 +96,26 @@ void setup() {
digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW);
}

#ifdef ESP32
// make sure wifi and bt is off as we don't need it:
WiFi.mode(WIFI_OFF);
btStop();

esp_bt_controller_disable();
# if defined(TTGO_T_Beam_V1_0) // || defined(TTGO_T_Beam_V0_7)
// TTGO_T_Beam_V0_7 should probably work as well but could not be confirmed so it is disabled now
// We don't need built-in ADC for voltage measurement on T-beam 1.0
adc_power_off();

//Going to 20MHz breaks the display, 40 MHz reduces power consumption by ~15-20mA
if (! setCpuFrequencyMhz(40)) {
setCpuFrequencyMhz(80); // Some guides suggest this as backup for other CPUs
logPrintlnD("Setting CPU frequency to 80Mhz");
} else {
logPrintlnD("Setting CPU frequency to 40Mhz");
}
# endif
#endif
if (Config.button.tx) {
// attach TX action to user button (defined by BUTTON_PIN)
userButton.attachClick(handle_tx_click);
Expand Down

0 comments on commit ee4d984

Please sign in to comment.