LightTracker VoltageRead Fix

This commit is contained in:
richonguzman 2025-02-09 12:15:38 -03:00
parent d19f1e8937
commit c5726dda28
1 changed files with 5 additions and 2 deletions

View File

@ -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