From 01d6737d60bddb688b2258677dbdbee6d437bee0 Mon Sep 17 00:00:00 2001 From: Florian Eitel Date: Sun, 4 Aug 2019 13:18:28 +0200 Subject: [PATCH] Use NaN to signal no sensor values The InfluxDB client will filter NaNs --- firmware/firmware.ino | 4 ++-- firmware/sensor_battery.ino | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 9008d5b..f6b9201 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -47,7 +47,7 @@ //*************************************************************************// const uint8_t VALUES = 8; -float currentSensorData[VALUES] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; +float currentSensorData[VALUES] = {nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value")}; float (*sensors[VALUES])() = {}; uint16_t update_sensor_cnt = 0; @@ -233,7 +233,7 @@ void _loop() { if (sensors[i]) { currentSensorData[i] = sensors[i](); } else { - currentSensorData[i] = 0xFFFFFFFF; + currentSensorData[i] = nan("no value"); } } diff --git a/firmware/sensor_battery.ino b/firmware/sensor_battery.ino index 1a19a74..593be35 100644 --- a/firmware/sensor_battery.ino +++ b/firmware/sensor_battery.ino @@ -1,4 +1,4 @@ -float _sensor_battery_saveMode = 0; +float _sensor_battery_saveMode = nan("no battery"); uint16_t energySavingIterations = 0; // Copied from https://arduinodiy.wordpress.com/2016/12/25/monitoring-lipo-battery-voltage-with-wemos-d1-minibattery-shield-and-thingspeak/