From 7475c8647ceebe93bf0ef056373a93183aa8b480 Mon Sep 17 00:00:00 2001 From: code8buster Date: Fri, 26 May 2023 11:16:40 +0000 Subject: [PATCH] 2.5dB could be a more appropriate attenuation for heltec ADCs (#2511) Co-authored-by: Ben Meadors --- src/Power.cpp | 5 ++++- variants/heltec_v3/variant.h | 1 + variants/heltec_wsl_v3/variant.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Power.cpp b/src/Power.cpp index 685181e3..2969c327 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -30,8 +30,11 @@ RTC_NOINIT_ATTR uint64_t RTC_reg_b; #endif // BAT_MEASURE_ADC_UNIT esp_adc_cal_characteristics_t *adc_characs = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t)); - +#ifndef ADC_ATTENUATION static const adc_atten_t atten = ADC_ATTEN_DB_11; +#else +static const adc_atten_t atten = ADC_ATTENUATION; +#endif #endif // BATTERY_PIN && ARCH_ESP32 #ifdef HAS_PMU diff --git a/variants/heltec_v3/variant.h b/variants/heltec_v3/variant.h index 16ee6d71..d9fc0b4c 100644 --- a/variants/heltec_v3/variant.h +++ b/variants/heltec_v3/variant.h @@ -9,6 +9,7 @@ #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_ATTENUATION ADC_ATTEN_DB_2_5 // lower dB for high resistance voltage divider #define ADC_MULTIPLIER 4.9 #define USE_SX1262 diff --git a/variants/heltec_wsl_v3/variant.h b/variants/heltec_wsl_v3/variant.h index 38b38e75..0ecc5bea 100644 --- a/variants/heltec_wsl_v3/variant.h +++ b/variants/heltec_wsl_v3/variant.h @@ -10,6 +10,7 @@ #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_ATTENUATION ADC_ATTEN_DB_2_5 // lower dB for high resistance voltage divider #define ADC_MULTIPLIER 4.9 #define USE_SX1262