From c5726dda286e6c530e752977fba4af1034e0e4b3 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sun, 9 Feb 2025 12:15:38 -0300 Subject: [PATCH] LightTracker VoltageRead Fix --- src/power_utils.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 93b9ca6..f00f214 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -73,9 +73,12 @@ namespace POWER_Utils { #endif batteryMeasurmentTime = millis(); #endif - double voltage = (adc_value * 3.3 ) / 4095.0; + + double voltage = (adc_value * 3.3 ) / 4095.0; + #ifdef LIGHTTRACKER_PLUS_1_0 - return voltage * 6.783; + double inputDivider = (1.0 / (560.0 + 100.0)) * 100.0; // The voltage divider is a 560k + 100k resistor in series, 100k on the low side. + return (voltage / inputDivider) + 0.1; #endif #if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_GPS_915) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(TTGO_T_LORA32_V2_1_TNC_915) || defined(ESP32_DIY_LoRa_GPS) || defined(ESP32_DIY_LoRa_GPS_915) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(ESP32_DIY_1W_LoRa_GPS_915) || defined(ESP32_DIY_1W_LoRa_GPS_LLCC68) || defined(OE5HWN_MeshCom) || defined(TTGO_T_DECK_GPS) || defined(TTGO_T_DECK_PLUS) || defined(ESP32S3_DIY_LoRa_GPS) || defined(ESP32S3_DIY_LoRa_GPS_915) || defined(TROY_LoRa_APRS) return (2 * (voltage + 0.1)) * (1 + (lora32BatReadingCorr/100)); // (2 x 100k voltage divider) 2 x voltage divider/+0.1 because ESP32 nonlinearity ~100mV ADC offset/extra correction