mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-05-10 07:04:26 +02:00
heltecV3 battery readings fix
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user