Skip to content

Commit

Permalink
oversample ADC_RANGE by 32 like ADC_INPUT (#17975)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudor authored Feb 17, 2023
1 parent d8d9c54 commit 119aeca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ float AdcGetRange(uint32_t idx) {
// formula for calibration: value, fromLow, fromHigh, toLow, toHigh
// Example: 514, 632, 236, 0, 100
// int( ((<param2> - <analog-value>) / (<param2> - <param1>) ) * (<param3> - <param4>) ) + <param4> )
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;
}
Expand Down

0 comments on commit 119aeca

Please # to comment.