From db94ef818a1f786c332c1926e8901d1439484298 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 19 Sep 2021 08:51:37 -0500 Subject: [PATCH 1/2] Fix bad if statements. --- src/TTGO_T-Beam_LoRa_APRS.ino | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 8ac1bfc..dd50850 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -567,11 +567,10 @@ String prepareCallsign(const String& callsign){ tel_sequence = tel_sequence + 1; } preferences.putUInt(PREF_TNC_SELF_TELEMETRY_SEQ, tel_sequence); - - } - #endif + #endif + } } - #endif +#endif // + SETUP --------------------------------------------------------------+// void setup(){ From b760fd9a233def702cfebadd4b93d237a7df9775 Mon Sep 17 00:00:00 2001 From: LucaIU2FRL Date: Sun, 19 Sep 2021 16:54:50 +0200 Subject: [PATCH 2/2] Trying to reduce power consumption --- include/taskWebServer.h | 2 +- src/TTGO_T-Beam_LoRa_APRS.ino | 28 ++++++++++++++++------------ src/taskWebServer.cpp | 8 ++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/taskWebServer.h b/include/taskWebServer.h index cb0dce9..760e622 100644 --- a/include/taskWebServer.h +++ b/include/taskWebServer.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifndef TASK_WEBSERVER #define TASK_WEBSERVER @@ -24,7 +25,6 @@ typedef struct { int SNR; } tReceivedPacketData; - extern QueueHandle_t webListReceivedQueue; [[noreturn]] void taskWebServer(void *parameter); diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index c49c958..1f60f8f 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -400,6 +400,7 @@ void batt_read(){ InpVolts = axp.getVbusVoltage()/1000; #elif T_BEAM_V0_7 BattVolts = (((float)analogRead(35) / 8192.0) * 2.0 * 3.3 * (1100.0 / 1000.0))+0.41; // fixed thanks to Luca IU2FRL + //BattVolts = adc1_get_raw(ADC1_CHANNEL_7)/1000; #else BattVolts = analogRead(35)*7.221/4096; #endif @@ -441,15 +442,15 @@ String getSatAndBatInfo() { String line5; if(gps_state == true){ if(InpVolts > 4){ - line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V *"; + line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V*"; }else{ - line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 1) + "V"; + line5 = "SAT: " + String(gps.satellites.value()) + " BAT: " + String(BattVolts, 2) + "V"; } }else{ if(InpVolts > 4){ - line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V *"; + line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V*"; }else{ - line5 = "SAT: X BAT: " + String(BattVolts, 1) + "V"; + line5 = "SAT: X BAT: " + String(BattVolts, 2) + "V"; } } @@ -578,19 +579,22 @@ String prepareCallsign(const String& callsign){ tel_sequence = tel_sequence + 1; } preferences.putUInt(PREF_TNC_SELF_TELEMETRY_SEQ, tel_sequence); - + #endif } - #endif } - #endif +#endif // + SETUP --------------------------------------------------------------+// void setup(){ -//#ifdef T_BEAM_V0_7 -// adcAttachPin(35); -// adcStart(35); -// analogReadResolution(10); -//#endif +#ifdef T_BEAM_V0_7 /* + adcAttachPin(35); + adcStart(35); + analogReadResolution(10); + analogSetAttenuation(ADC_6db); */ + pinMode(35, INPUT); + //adc1_config_width(ADC_WIDTH_BIT_12); + //adc1_config_channel_atten(ADC1_CHANNEL_7,ADC_ATTEN_DB_11); +#endif SPI.begin(SPI_sck,SPI_miso,SPI_mosi,SPI_ss); //DO2JMG Heltec Patch Serial.begin(115200); diff --git a/src/taskWebServer.cpp b/src/taskWebServer.cpp index b3608ca..922056f 100644 --- a/src/taskWebServer.cpp +++ b/src/taskWebServer.cpp @@ -402,6 +402,9 @@ void handle_saveDeviceCfg(){ int retryWifi = 0; WiFi.begin(wifi_ssid.c_str(), wifi_password.length() ? wifi_password.c_str() : nullptr); Serial.println("Connecting to " + wifi_ssid); + // Set power to minimum (max 20) + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html + esp_wifi_set_max_tx_power(8); while (WiFi.status() != WL_CONNECTED) { Serial.print("Not connected: "); Serial.println((int)WiFi.status()); @@ -417,6 +420,8 @@ void handle_saveDeviceCfg(){ Serial.print(apSSID.c_str()); Serial.print(" Password: "); Serial.println(apPassword.c_str()); + // Set power to minimum (max 20) + esp_wifi_set_max_tx_power(8); break; } } @@ -430,6 +435,9 @@ void handle_saveDeviceCfg(){ infoApPass = apSSID.c_str(); infoApAddr = WiFi.softAPIP().toString(); } else if (WiFi.getMode() == 1) { + // Save some battery + //WiFi.setSleep(true); + esp_wifi_set_ps(WIFI_PS_MAX_MODEM); Serial.println("Connected. IP: " + WiFi.localIP().toString()); apConnected=true; infoApName = wifi_ssid.c_str();