Passing a variable to HTML on ESP8266
Posted: Thu Aug 24, 2017 2:23 pm
What I have is an ESP8266 running a DHT22 to get temperature and running a web server with an HTML file that has the formatting that I am looking for. The HTML is included as a .h file:
char index_html[] PROGMEM{
"<!DOCTYPE html>\n"
"<html>\n"
"<body>\n"
"<body style=\"background-color:black; color:cyan;; font-family:verdana\">\n"
"\n"
"\n"
"<p style=\"font-size:500%; text-align:center\">\n"
"<I><b>DHT22 TEMP GOES HERE<sup><small><small>F</p>\n"
"\n"
"\n"
"</body>\n"
"</html>"};
The code for the server:
void handleRoot() {
temp = dht.readTemperature();
server.send_P(200, "text/html", index_html);
}
I have no problem with my code displaying the formatted HTML to a browser but I want that temp variable passed to the HTML.
I've googled... I've youtubed... My head hurts. Please someone have mercy on this newbie.
Thanks!
char index_html[] PROGMEM{
"<!DOCTYPE html>\n"
"<html>\n"
"<body>\n"
"<body style=\"background-color:black; color:cyan;; font-family:verdana\">\n"
"\n"
"\n"
"<p style=\"font-size:500%; text-align:center\">\n"
"<I><b>DHT22 TEMP GOES HERE<sup><small><small>F</p>\n"
"\n"
"\n"
"</body>\n"
"</html>"};
The code for the server:
void handleRoot() {
temp = dht.readTemperature();
server.send_P(200, "text/html", index_html);
}
I have no problem with my code displaying the formatted HTML to a browser but I want that temp variable passed to the HTML.
I've googled... I've youtubed... My head hurts. Please someone have mercy on this newbie.
Thanks!