heltecV3 battery readings fix

This commit is contained in:
richonguzman 2024-04-30 17:18:02 -04:00
parent 708742f43d
commit a14c570db0
2 changed files with 4 additions and 1 deletions

View file

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

View file

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