From a9b8ac3ff1277c821cb34bb6bb71e5fbbaefd1fc Mon Sep 17 00:00:00 2001 From: Matthias Prinke Date: Sat, 27 Apr 2024 07:52:13 +0200 Subject: [PATCH] Added ADC input control and battery voltage measurement for ARDUINO_heltec_wifi_lora_32_V3 --- src/adc/adc.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/adc/adc.cpp b/src/adc/adc.cpp index a66aac2..d7f5ed7 100644 --- a/src/adc/adc.cpp +++ b/src/adc/adc.cpp @@ -35,6 +35,8 @@ // 20240414 Added ESP32-S3 PowerFeather // Added getSupplyVoltage() // 20240423 Added define ARDUINO_heltec_wifi_lora_32_V3 +// 20240427 Added ADC input control and battery voltage measurement +// for ARDUINO_heltec_wifi_lora_32_V3 // // ToDo: // - @@ -81,7 +83,12 @@ uint16_t getBatteryVoltage(void) // Not implemented - no default VBAT input circuit (connect external divider to A0) return 0; #elif defined(ARDUINO_heltec_wifi_32_lora_V3) || defined(ARDUINO_heltec_wifi_lora_32_V3) - return 0; + // Enable ADC input switch, measure voltage and disable ADC input switch + pinMode(ADC_CTRL, OUTPUT); + digitalWrite(ADC_CTRL, LOW); + delay(100); + getVoltage(); + pinMode(ADC_CTRL, INPUT); #elif defined(ARDUINO_M5STACK_Core2) || defined(ARDUINO_M5STACK_CORE2) uint16_t voltage = M5.Power.getBatteryVoltage(); log_d("Voltage = %dmV", voltage);