Adjusted examples to not send error codes (e.g. -1) to server

This commit is contained in:
Achim
2022-11-01 14:04:41 +07:00
parent 84fe9c2575
commit dc1a070ee3
6 changed files with 264 additions and 192 deletions

View File

@ -182,13 +182,15 @@ void showTextRectangle(String ln1, String ln2, boolean small) {
void sendToServer() {
if (currentMillis - previoussendToServer >= sendToServerInterval) {
previoussendToServer += sendToServerInterval;
String payload = "{\"wifi\":" + String(WiFi.RSSI())
+ ", \"rco2\":" + String(Co2)
+ ", \"pm02\":" + String(pm25)
+ (Co2 < 0 ? "" : ", \"rco2\":" + String(Co2))
+ (pm25 < 0 ? "" : ", \"pm02\":" + String(pm25))
+ ", \"atmp\":" + String(temp)
+ ", \"rhum\":" + String(hum)
+ (hum < 0 ? "" : ", \"rhum\":" + String(hum))
+ "}";
if(WiFi.status()== WL_CONNECTED){
Serial.println(payload);
String POSTURL = APIROOT + "sensors/airgradient:" + String(ESP.getChipId(), HEX) + "/measures";