generate basic JSON output
This commit is contained in:
parent
badd6deaad
commit
1a1df7a2b9
16
things.ino
16
things.ino
@ -381,6 +381,22 @@ void setup() {
|
|||||||
delay(100);
|
delay(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
http_server.on("/json", [](){
|
||||||
|
read_sensor();
|
||||||
|
DynamicJsonBuffer jsonBuffer;
|
||||||
|
JsonObject& json = jsonBuffer.createObject();
|
||||||
|
json["mqtt_server"] = mqtt_server;
|
||||||
|
json["mqtt_port"] = mqtt_port;
|
||||||
|
json["mqtt_topic"] = mqtt_topic;
|
||||||
|
json["temperature"] = str_temperature;
|
||||||
|
json["humidity"] = str_humidity;
|
||||||
|
json["heatindex"] = str_heatindex;
|
||||||
|
String response;
|
||||||
|
json.printTo(response);
|
||||||
|
http_server.send(200, "text/plain", response);
|
||||||
|
delay(100);
|
||||||
|
});
|
||||||
|
|
||||||
// start the web server
|
// start the web server
|
||||||
http_server.begin();
|
http_server.begin();
|
||||||
Serial.println("HTTP server started");
|
Serial.println("HTTP server started");
|
||||||
|
Loading…
Reference in New Issue
Block a user