-->
Page 1 of 1

Arduino ESP8266 ESP-12 AP Web Server Question

PostPosted: Tue Feb 06, 2018 2:59 pm
by Jim Odom
I built a sketch setting up my ESP as an AP Server to monitor my BBQ Smoker Temp. It reads the Max6675 probe and gathers the temperature. I connect to the server with my Browser and it becomes a display for my recurring temperature updates.

I'm stumped on an issue and looking for advice.

I want to keep sending updates to the browser with temperature changes and found that I can just loop and continue sending the HTML string below after I update the Ftemp. My Web Screen continues to get the temperature messages and just scrolls on forever. Just what I wanted. But the problem is if the connection is broken or I want to exit and check my internet. I cant reconnect with the ESP because my code is apparently still looping. I have to power the ESP down to reconnect.

CODE:/* prepare to send temp
//**************************************************
String x = "<!DOCTYPE HTML>\r\n<html>\r\n";
x += "<p>&nbsp;</p>";
x += "<h2>Probe Temperature</h2>";
x += String(Ftemp);
x += "</html>\n";
client.print(x);
delay(5000);


Q - How to Continuously send the temp to my browser but exit out of the loop when the connection is lost so that I can start my sketch back at the beginning?

IE is there something I can check in the code to tell me if the Browser connection is down or broken so I can start over?

Would the code I use below to start my sketch work for checking to see if the browser is gone?
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}