We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ab4129a commit a8001b8Copy full SHA for a8001b8
src/main.ino
@@ -128,8 +128,17 @@ void sendDataToAWS(void)
128
{
129
StaticJsonDocument<200> doc;
130
131
- doc["time"] = String(millis());
132
- doc["values"] = Serial.readString(); // read data coming from Uno board
+ // read data coming from Uno board and put into variable "doc"
+ DeserializationError error = deserializeJson(doc, Serial.readString());
133
+
134
+ // Test if parsing succeeds.
135
+ if (error) {
136
+ Serial.print(F("deserializeJson() failed."));
137
+ return;
138
+ }
139
140
+ // parsing succeeded, continue and set time
141
+ doc["time"] = String(millis());
142
143
char jsonBuffer[512];
144
serializeJson(doc, jsonBuffer);
0 commit comments