switch back to NaN as string
This commit is contained in:
parent
41e777f586
commit
0e92f31c4b
@ -10,8 +10,8 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: upload
|
- name: upload
|
||||||
commands:
|
commands:
|
||||||
- service ser2net stop
|
|
||||||
- cd gateway
|
- cd gateway
|
||||||
|
- service ser2net stop
|
||||||
- pio run -e pro-mini
|
- 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
|
- 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
|
- service ser2net start
|
||||||
|
|||||||
@ -2,8 +2,6 @@
|
|||||||
#include <RCSwitch.h>
|
#include <RCSwitch.h>
|
||||||
#include <Adafruit_Sensor.h>
|
#include <Adafruit_Sensor.h>
|
||||||
#include "Tiny.h"
|
#include "Tiny.h"
|
||||||
|
|
||||||
#define ARDUINOJSON_ENABLE_NAN 1
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include "Dht.h"
|
#include "Dht.h"
|
||||||
|
|
||||||
@ -50,8 +48,10 @@ bool buildSensorJson(JsonDocument& jsonDoc, unsigned long value) {
|
|||||||
|
|
||||||
JsonObject sensor = jsonDoc.createNestedObject("sensor");
|
JsonObject sensor = jsonDoc.createNestedObject("sensor");
|
||||||
|
|
||||||
unsigned long voltage = GET_VCC(value);
|
float voltage = (float)GET_VCC(value) / 1000;
|
||||||
sensor["voltage"] = voltage == 0 ? NAN : (float)voltage / 1000;
|
if (voltage != 0) {
|
||||||
|
sensor["voltage"] = voltage;
|
||||||
|
}
|
||||||
|
|
||||||
switch (GET_TYPE(value)) {
|
switch (GET_TYPE(value)) {
|
||||||
case SensorType::GENERIC:
|
case SensorType::GENERIC:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user