From de81fd687c5f71f1724073ec4257cda19060c6a7 Mon Sep 17 00:00:00 2001 From: Barbudor Date: Fri, 17 Feb 2023 21:47:02 +0100 Subject: [PATCH] oversample ADC_RANGE by 32 like ADC_INPUT --- 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 5abb6b56a9e6..afccacbc8547 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; }