switch back to NaN as string

This commit is contained in:
Nicu Hodos 2022-10-14 16:59:50 +02:00
parent 41e777f586
commit 0e92f31c4b
2 changed files with 5 additions and 5 deletions

View File

@ -10,8 +10,8 @@ platform:
steps:
- name: upload
commands:
- service ser2net stop
- cd gateway
- service ser2net stop
- pio run -e pro-mini
- echo -n 'reset' > /dev/ttyUSB0; sleep 1s; avrdude -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:.pio/build/pro-mini/firmware.hex:i -v
- service ser2net start

View File

@ -2,8 +2,6 @@
#include <RCSwitch.h>
#include <Adafruit_Sensor.h>
#include "Tiny.h"
#define ARDUINOJSON_ENABLE_NAN 1
#include <ArduinoJson.h>
#include "Dht.h"
@ -50,8 +48,10 @@ bool buildSensorJson(JsonDocument& jsonDoc, unsigned long value) {
JsonObject sensor = jsonDoc.createNestedObject("sensor");
unsigned long voltage = GET_VCC(value);
sensor["voltage"] = voltage == 0 ? NAN : (float)voltage / 1000;
float voltage = (float)GET_VCC(value) / 1000;
if (voltage != 0) {
sensor["voltage"] = voltage;
}
switch (GET_TYPE(value)) {
case SensorType::GENERIC: