So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By kbdrox
#69434 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!
User avatar
By kbdrox
#69464 Moderation took so long that I actually have my answer:

Saving sensor data as string on .csv file in SPIFFS, getting said file with javascript I cobbled together and sending it to html code with getElementById.

Maybe my migraine will help someone else.
User avatar
By gdsports
#69468 Try this.

Code: Select allconst 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>%.1f<sup><small><small>F</p>\n"
"\n"
"\n"
"</body>\n"
"</html>"};

void setup()
{
  Serial.begin(115200);

  char html[256];
  float dhttemp = 25.0;
 
  snprintf_P(html, sizeof(html), index_html, dhttemp);
  Serial.print(html);
}

void loop()
{
}
User avatar
By dplumly
#82175 Hey @kbdrox,I know this is an old post, but I am looking to do the same thing as you. Since you said you figured it out did you make a Github repo of the code? If so, could you send me the link?