I've been struggling with the webserver part of a project. Originally this project ran on a MEGA2560 but needed external wifi (via esp8266) and RTC. All function are now re-coded into a ESP32 WROVER (via Arduino IDE)..
Everything was going well except the web server part of the code crashes in about 50min and the EXP32 exception decoder has not been helpful.
I was hoping of you experts out there could take a look at my server code to see if you can spot anything obvious the could lead to this problem???
Many thanks
TOM
void pID() {
xTaskCreatePinnedToCore(
taskOne, /* Task function. /
"TaskOne", / String with name of task. /
30000, / Stack size in bytes. /
NULL, / Parameter passed as input of the task /
1, / Priority of the task. */
NULL,
0);
pause;
}
void taskOne( void * parameter )
{
for(;;){
digitalWrite(blUe, LOW);
digitalWrite(amBer, LOW);
digitalWrite(grEen, HIGH);
digitalWrite(reD, HIGH);
//WEB SERVER STARTS HERE
digitalWrite(blUe, LOW);
digitalWrite(amBer, LOW);
digitalWrite(grEen, HIGH);
digitalWrite(reD, HIGH);
bool currentLineIsBlank = true;
String readString;
// listen for incoming clients
WiFiClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
readString += c;
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html; charset=utf-8");
client.println("Access-Control-Al-Origin: http://192.168.4.2:80");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 2 sec
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
client.println("
iQUEbbq FIREWORKS REPORTS
"); client.println("Cook Temp Target = "); client.print(CT); client.println(" °F
"); client.println("GRID TEMPERATURE IS
"); client.println(""); client.print(gridT); client.println(" °F
"); client.println("PRB1 TEMP = "); client.print(prBt1); client.println(" PRB2 TEMP ="); client.println(prBt2); client.println("
"); client.println("THE COOKING TIME IS
"); client.println(Webt); client.println("
"); //client.println(""); //client.println(""); client.println("");if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
// give the web browser time to receive the data
delay(1000);
// close the connection:
client.stop();
Serial.println("client disconnected");
}}}}
{ if (analogRead(36)<= 50)
{
Serial.println("restarting");
for (int i = 0 ; i < 10; i++)
{
EEPROM.write(i, 0);
}
setup();
}
}
}
}
SERVER.txt (8.28 KB)