I'm getting started with the Arduino Yun Parse SDK and followed the basic example to save an object.
I'm reading a temperature from a sensor every minute and saving it to Parse as such:
void loop() {
delay(60000);
float temperature = dht.readTemperature();
if (isnan(temperature)) return;
ParseObjectCreate create;
create.setClassName("SensorReading");
create.add("temperature", temperature);
ParseResponse response = create.send();
Serial.print(response.getJSONBody());
if (!response.getErrorCode()) {
String objectId = response.getString("objectId");
Serial.print("Object id:");
Serial.println(objectId);
} else {
Serial.println("Failed to save the object");
}
response.close();
}
This will work initially, but if I keep it running for an extended period of time (30+ minutes), I start getting this error:
{"code":107,"error":"invalid JSON"}
It will give this error code for all subsequent saves until I restart my sketch.
I'm a bit confused as to how the JSON generated by the Parse API could become invalid after a while. The temperature value is a valid float even in those failed save requests.
Maybe it has to do with my Parse token expiring? Am I supposed to refresh it by calling Parse.begin() again?
This was due to a memory leak in the Parse Arduino Yun library version 1.0.0. It's fixed in version 1.0.1.