From 06617c7fcb6a6fcd0cccb06859e833535df427d5 Mon Sep 17 00:00:00 2001 From: rice103 <90975508+francescoadriani@users.noreply.github.com> Date: Sun, 23 Jan 2022 18:27:32 +0100 Subject: [PATCH] Using FastPrecisePow instead of pow --- tasmota/xsns_02_analog.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/xsns_02_analog.ino b/tasmota/xsns_02_analog.ino index 9c845561c..e934decad 100644 --- a/tasmota/xsns_02_analog.ino +++ b/tasmota/xsns_02_analog.ino @@ -383,12 +383,12 @@ float AdcGetMq(uint32_t idx) { _adc = AdcRead(Adc[idx].pin, 2); avg += _adc; } - float voltage = (avg/ retries) * ANALOG_V33 / ((pow(2, ANALOG_RESOLUTION)) - 1); + float voltage = (avg/ retries) * ANALOG_V33 / ((FastPrecisePow(2, ANALOG_RESOLUTION)) - 1); float _RS_Calc = ((ANALOG_V33 * _RL) / voltage) -_RL; //Get value of RS in a gas if (_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted. float _ratio = _RS_Calc / _R0; // Get ratio RS_gas/RS_air - float ppm= Adc[idx].param2/ANALOG_MQ_DECIMAL_MULTIPLIER*pow(_ratio, Adc[idx].param3/ANALOG_MQ_DECIMAL_MULTIPLIER); // <- Source excel analisis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents + float ppm= Adc[idx].param2/ANALOG_MQ_DECIMAL_MULTIPLIER*FastPrecisePow(_ratio, Adc[idx].param3/ANALOG_MQ_DECIMAL_MULTIPLIER); // <- Source excel analisis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents if(ppm < 0) ppm = 0; //No negative values accepted or upper datasheet recomendation. char ppm_chr[6]; dtostrfd(ppm, 2, ppm_chr);