diff --git a/src/main.ino b/src/main.ino index 8044027..374c0fb 100644 --- a/src/main.ino +++ b/src/main.ino @@ -7,6 +7,7 @@ #include #include +#include //https://github.com/bblanchon/ArduinoJson (use v6.xx) #include #define DEBUG true @@ -87,13 +88,16 @@ void loop() { String prepareDataForWiFi(float humidity, float temperature) { - String dataAsJson = "{\"Humidity\":\""; - dataAsJson += (String)humidity; - dataAsJson += "\", \"Temperature\":\""; - dataAsJson += (String)temperature; - dataAsJson += "\"}"; - return dataAsJson; + StaticJsonDocument<200> doc; + + doc["humidity"] = (String)humidity; + doc["temperature"] = (String)temperature; + + char jsonBuffer[512]; + serializeJson(doc, jsonBuffer); + + return jsonBuffer; } String sendDataToWiFi(String command, const int timeout, boolean debug)