From 119aeca4d9f1af8b364bfc5f8dc4c209b0cce2dd Mon Sep 17 00:00:00 2001 From: Barbudor Date: Fri, 17 Feb 2023 22:33:06 +0100 Subject: [PATCH] oversample ADC_RANGE by 32 like ADC_INPUT (#17975) --- tasmota/tasmota_xsns_sensor/xsns_02_analog.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino index 5abb6b56a..afccacbc8 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino @@ -452,7 +452,7 @@ float AdcGetRange(uint32_t idx) { // formula for calibration: value, fromLow, fromHigh, toLow, toHigh // Example: 514, 632, 236, 0, 100 // int( (( - ) / ( - ) ) * ( - ) ) + ) - int adc = AdcRead(Adc[idx].pin, 2); + int adc = AdcRead(Adc[idx].pin, 5); double adcrange = ( ((double)Adc[idx].param2 - (double)adc) / ( ((double)Adc[idx].param2 - (double)Adc[idx].param1)) * ((double)Adc[idx].param3 - (double)Adc[idx].param4) + (double)Adc[idx].param4 ); return (float)adcrange; }