testing multiple temp readings

This commit is contained in:
Rohan Sircar 2019-10-30 22:31:55 +05:30
parent 50af4b28f9
commit 56f6e9ca96

View File

@ -183,7 +183,10 @@ void loop()
Serial.println("Error creating temperature json");
}
JsonArray &temperatures = root.createNestedArray("temperatures");
temperatures.add(sensors.getTempCByIndex(0));
// temperatures.add(sensors.getTempCByIndex(0));
float temp = sensors.getTempCByIndex(0);
temperatures.add(temp);
temperatures.add(temp);
root.prettyPrintTo(Serial);
root.prettyPrintTo(temperaturesJson);
// dtostrf(sensors.getTempCByIndex(0), 1, 1, str_temp);
@ -330,7 +333,7 @@ void handleNotFound()
{ // if the requested file or page doesn't exist, return a 404 not found error
if (!handleFileRead(server.uri()))
{ // check if the file exists in the flash memory (SPIFFS), if so, send it
server.send(404, "application/json", "{\"status\":\"failed\",\"message\":\"File not found\"}");
server.send(404, "application/json", "{\"status\":\"failed\",\"message\":\"Resource not found\"}");
}
}
@ -368,7 +371,10 @@ void saveTemperatureJson()
// data.add(48);
// data.add(2);
JsonArray &temperatures = root.createNestedArray("temperatures");
temperatures.add(sensors.getTempCByIndex(0));
float temp = sensors.getTempCByIndex(0);
temperatures.add(temp);
temperatures.add(temp);
temperatures.add(1);
root.prettyPrintTo(Serial);
root.prettyPrintTo(temperaturesJson);
// if (SPIFFS.exists("/temperatures.txt"))