From a14c570db0fcfb511c63cdf04cf353f6f09a6cbb Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 30 Apr 2024 17:18:02 -0400 Subject: [PATCH] heltecV3 battery readings fix --- src/battery_utils.cpp | 4 ++++ src/power_utils.cpp | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index da3173a..9578453 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -24,6 +24,9 @@ namespace BATTERY_Utils { float checkBattery() { int sample; int sampleSum = 0; + #ifdef HELTEC_V3 + digitalWrite(ADC_CTRL, LOW); + #endif for (int i = 0; i < 100; i++) { #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa_A7670) || defined(TTGO_T_LORA32_V2_1_915) sample = analogRead(BATTERY_PIN); @@ -36,6 +39,7 @@ namespace BATTERY_Utils { } #ifdef HELTEC_V3 + digitalWrite(ADC_CTRL, HIGH); double inputDivider = (1.0 / (390.0 + 100.0)) * 100.0; // The voltage divider is a 390k + 100k resistor in series, 100k on the low side. return (((sampleSum/100) * adcReadingTransformation) / inputDivider) + 0.285; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements. #else diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 5fc6dc4..92442f6 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -130,7 +130,6 @@ namespace POWER_Utils { pinMode(VExt_CTRL,OUTPUT); // this is for GPS and TFT screen on Wireless_Tracker and only for Oled in Heltec V3 digitalWrite(VExt_CTRL, HIGH); pinMode(ADC_CTRL, OUTPUT); - digitalWrite(ADC_CTRL, HIGH); #endif }