Use NaN to signal no sensor values

The InfluxDB client will filter NaNs
This commit is contained in:
Florian Eitel 2019-08-04 13:18:28 +02:00
parent 007d2e4e73
commit 01d6737d60
No known key found for this signature in database
GPG key ID: 9987EAFEF6F686BB
2 changed files with 3 additions and 3 deletions

View file

@ -47,7 +47,7 @@
//*************************************************************************// //*************************************************************************//
const uint8_t VALUES = 8; 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])() = {}; float (*sensors[VALUES])() = {};
uint16_t update_sensor_cnt = 0; uint16_t update_sensor_cnt = 0;
@ -233,7 +233,7 @@ void _loop() {
if (sensors[i]) { if (sensors[i]) {
currentSensorData[i] = sensors[i](); currentSensorData[i] = sensors[i]();
} else { } else {
currentSensorData[i] = 0xFFFFFFFF; currentSensorData[i] = nan("no value");
} }
} }

View file

@ -1,4 +1,4 @@
float _sensor_battery_saveMode = 0; float _sensor_battery_saveMode = nan("no battery");
uint16_t energySavingIterations = 0; uint16_t energySavingIterations = 0;
// Copied from https://arduinodiy.wordpress.com/2016/12/25/monitoring-lipo-battery-voltage-with-wemos-d1-minibattery-shield-and-thingspeak/ // Copied from https://arduinodiy.wordpress.com/2016/12/25/monitoring-lipo-battery-voltage-with-wemos-d1-minibattery-shield-and-thingspeak/