From c867af852287f843e5fa13c645e09be6ee86699b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 9 Feb 2022 13:37:48 -0600 Subject: [PATCH] Adjusted adc_multiplier for heltec2.1 and added adc_mulitplier_override (#1183) --- src/Power.cpp | 6 +++++- variants/heltec_v2.1/variant.h | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index ed2eeae63..6c5301f15 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -100,6 +100,10 @@ class AnalogBatteryLevel : public HasBatteryLevel #ifndef ADC_MULTIPLIER #define ADC_MULTIPLIER 2.0 #endif + // Override variant or default ADC_MULTIPLIER if we have the override pref + float operativeAdcMultiplier = radioConfig.preferences.adc_multiplier_override > 0 ? + radioConfig.preferences.adc_multiplier_override : + ADC_MULTIPLIER; #ifdef BATTERY_PIN // Do not call analogRead() often. @@ -109,7 +113,7 @@ class AnalogBatteryLevel : public HasBatteryLevel uint32_t raw = analogRead(BATTERY_PIN); float scaled; #ifndef VBAT_RAW_TO_SCALED - scaled = 1000.0 * ADC_MULTIPLIER * (AREF_VOLTAGE / 1024.0) * raw; + scaled = 1000.0 * operativeAdcMultiplier * (AREF_VOLTAGE / 1024.0) * raw; #else scaled = VBAT_RAW_TO_SCALED(raw); //defined in variant.h #endif diff --git a/variants/heltec_v2.1/variant.h b/variants/heltec_v2.1/variant.h index 5b40e0e09..daa1ab880 100644 --- a/variants/heltec_v2.1/variant.h +++ b/variants/heltec_v2.1/variant.h @@ -24,8 +24,7 @@ #define LORA_DIO1 35 // Not really used #define LORA_DIO2 34 // Not really used -// ratio of voltage divider = 3.20 (schematic R12=100k, R10=220k) -// device to device variations, the actual ratio can be between 3.2 and 4 -#define ADC_MULTIPLIER 3.6 // best fit +#define ADC_MULTIPLIER 3.8 + #define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.