Skip to content

Commit

Permalink
Improve power usage by reducing CPU clock
Browse files Browse the repository at this point in the history
  • Loading branch information
OK2MOP committed Feb 16, 2023
1 parent 56bd2de commit 214d2c0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/LoRa_APRS_Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
#include <OneButton.h>
#include <TimeLib.h>
#include <TinyGPS++.h>
#ifdef ESP32
#include <WiFi.h>
#endif
#include <logger.h>

#ifdef ESP32
#include <esp_bt.h>
#endif
#include "BeaconManager.h"
#include "configuration.h"
#include "display.h"
Expand Down Expand Up @@ -93,10 +97,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();

logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi and BT controller stopped");
esp_bt_controller_disable();
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "BT controller disabled");
#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
// Going to 20MHz breaks the display in 3.0.x SDK
// 40 MHz reduces power consumption by ~15-20mA but is broken in present SDK
// Using 80 MHz as a safe value works
if (setCpuFrequencyMhz(80)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz");
} else {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency unchanged");
}
#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 214d2c0

Please sign in to comment.