Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By woodwax
#32637 Hello

I wrote program for home watering system with webserver on ESP8266.

The ESP always crash when I call many times(10-15x one after another, fast) this webpage from browser. On serial interface I see:

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld


Is it possible to prevent this crash from ESP side?
User avatar
By woodwax
#32670 Thank you for the answer!

I trying develop delay functions but it not working. This is my code, can you modify this?

Code: Select allvoid loop() {
  delay(100);   //I tried dealay function but it not helped

//------------NOT IMPORTANT!!!!!!!!,SOME FUNCTIONS, PERIODIC TIMER, ETC, NOT IMPORTANT!!!!!!------------//
  struct Locsolo locsolo[LOCSOLO_NUMBER];
  strcpy(locsolo[0].Name,"locsolo1");
  strcpy(locsolo[1].Name,"locsolo2");
  if(timer_flag)
  {
    Serial.print("Periodic Timer:");  Serial.print(TIMER_PERIOD);  Serial.println("s");
    time_out(&locsolo[0]);
    DHT_sensor_read(&locsolo[0]);
    auto_ontozes(&locsolo[0]);
    timer_flag=0;
    if(flag==0){
        now();
        now();
        server_start.second=second();
        server_start.minute=minute();
        server_start.hour=hour();
        flag=1;
        }
    Serial.println("Periodic Timer end");
  }
//------------------END OF NOT IMPORTANT--------------------------------------------------// 

  WiFiClient client = server.available();
  if (!client) {
   return;
  }
  temp_expire=timer.timer_expire;
  os_timer_disarm(&timer);
  while(!client.available())   {
    Serial.print(".");   
    delay(1);   
    timeout++;
    if(timeout>500) {Serial.println("INFINITE LOOP BREAK!");  client.flush(); client.stop(); break;}
    }
    timeout=0;
   
    String request = client.readStringUntil('\r');  // Read the first line of the request
    Serial.println(request);
    if (request.indexOf("/locs1=on") != -1)  {           //NOT IMPORTANT
      locsolo[0].set = HIGH;
      Serial.print("locsolo[0]=");
      Serial.println(locsolo[0].set);
    }
    else if (request.indexOf("/locs1=off") != -1)  {      //NOT IMPORTANT
      locsolo[0].set = LOW;
      Serial.print("locsolo[0]=");
      Serial.println(locsolo[0].set);
      }
    else if (request.indexOf("/locs1=auto") != -1)  {     //NOT IMPORTANT
      if(locsolo[0].autom) locsolo[0].autom = 0;
      else locsolo[0].autom = 1;
      Serial.print("locsolo[0]=");
      Serial.println(locsolo[0].autom);
      }
    else if (request.indexOf("/status") != -1)  {         //NOT IMPORTANT, CALLED IN EVERY 30 SECONDS
      status_respond(&client,&locsolo[0],LOCSOLO_NUMBER);
      }
    else if(request.indexOf("/") != -1)  {      //RETURN THE WEBPAGE FOR THE BROWSER
        html_index(&client,&locsolo[0]);     //AT THIS POINT I RETURN THE WHOLE OF WEBPAGE, SEE ATTACHMENT
      }
    client.flush();
    delay(1);
    client.stop();
    os_timer_arm(&timer, TIMER_PERIOD*1000, 1);
    timer.timer_expire=temp_expire;
    Serial.println("Client disonnected\n");
    delay(100);                               //I tried dealay functions but it not helped
 }


Also I include html_index function with HTML page.
Sry for some reason I must rar because i cannot upload
You do not have the required permissions to view the files attached to this post.
User avatar
By mrburnette
#32883
woodwax wrote:<....>
Code: Select allvoid loop() {
  delay(100);   //I tried dealay function but it not helped
<.... code...>
    delay(100);                               //I tried dealay functions but it not helped
 }



The RTOS is "feed" automatically at each iteration of loop, so the delays you put in are useless. You need to profile your code and breakup lengthly sections with the function yield()
OR, sprinkle yield() everywhere to see if it "fixes" your WDT then start removing them to clean it up.

igrr commented on May 19
WDT APIs (ESP.wdtEnable(), ESP.wdtDisable(), ESP.wdtFeed()) are now included in the latest release.


If you cannot get a handle on your timings, the WDT is controllable - but you are on your own if you screw-up.


Ray