From c89486bd31be5088889c20ff71bbb53a4b3640e3 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 14 Sep 2022 12:42:01 +0200 Subject: [PATCH] Fixed valid data checks and prevented to copy nan data to webUpdater. --- firmware/firmware.ino | 2 +- firmware/webUpdater.ino | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 84ea6c7..aded435 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -450,7 +450,7 @@ void _fsm_loop() #ifdef INFLUXDB_FEATURE for (uint8_t i = 0; i < 5 and validData == false; i++) { - if (currentSensorData[i] != 0) + if (currentSensorData[i] != 0 and currentSensorData[i] != nanf("no value") and (not isnan(currentSensorData[i]))) { validData = true; } diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index fc03e76..5f53de1 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -80,7 +80,7 @@ void setSensorData(float sensorValues[]) for (uint8_t i = 0; i < 5 and wuValidData == false; i++) { - if (sensorValues[i] != 0) + if (sensorValues[i] != 0 and sensorValues[i] != nanf("no value") and (not isnan(sensorValues[i]))) { wuValidData = true; // at least one value is not zero, the data } @@ -88,7 +88,11 @@ void setSensorData(float sensorValues[]) for (uint8_t i = 0; i < VALUES; i++) { - _webUpdater_sensValues[i] = sensorValues[i]; + if (sensorValues[i] != nanf("no value") and (not isnan(sensorValues[i]))) + { + // only copy real float values + _webUpdater_sensValues[i] = sensorValues[i]; + } } }