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

Moderator: igrr

User avatar
By GregryCM
#36696 Hello,

I have 2 ESP01 modules with fixed IP addresses, 1.123 and 1.124

1.123 is on my bench. 1.124 is in the garage, and reports if the door is up or down.

Both modules have ran for hundreds of hours. 1.124 has been up for 534 hours, 1.123 had been up for over 100 hours.

This evening, I could not connect to either module. Both modules failed to connect, and the browser returned a "Connection has timed out message".

1.123 has a heart beat LED that is controlled via an I2C port expander. It was not blinking. I connected the serial interface to the board and attempted to execute some debug commands, but got no response. This module appears to be hung.

Since both modules appeared to hang at the same time, I thought that some unhandled WiFi event may have occurred. I repowered the WiFi router, and 1.124 module came back online. It's WiFi Reconnections counter advanced, and the uptime was maintained, indicating that the module did not reset.

1.123 did not come back online, and the heart beat LED is still not blinking, it still appears to be hung.

Both modules check the WiFi.status() in loop() and start restart WiFi if !WL_CONNECTED.

Code: Select allvoid loop( void )
{
  #if WIFI_MODE == WIFI_MODE_STA
  //  Reconnect wifi if not connected
  if( WiFi.status() != WL_CONNECTED )
  {
    delay(10);
    StartWiFiSTA();
    UtilityWiFiReconnectInc();
    return;
  }
  #endif

  server.handleClient();
  yield();

  CommProcess();
  yield();

  //  Do Periodic Events
  if( Timer100mS )
  {
    Timer100mS = false;
    OpStateService();
  }
}


Both applications were built with 1.6.5-1084-ga39ce29.
It appears that the major difference between the modules is I2C. Could a WiFi event cause I2C to hang?

Suggestions?

Thanks,
Greg
User avatar
By GregryCM
#36853 I plugged the Serial Debugger into module 1.123 and learned some things.

1) The Chrome browser on my phone was asking for favicon on each refresh or page load. Other browsers only asked for it initially.
2) On occasional web page updates, the module would crash with an Exception 9 code.

Multiple Favicon requests was fixed by replacing:
server.send( 200, "text/html", "" );
with
server.send( 404, "text/plain", "" );

I also noticed that each time the web page is updated, Page_Main was sent, PAGE_StyleSheet, and PAGE_Favicon were sent. I send a serial message on each page load that indicates which page was loaded. I noticed sometimes that there was hesitation between the page loads.

I am not sure when the background tasks run, but thought that some of the sluggishness might be caused by the background task needing to catch up between page loads.

To address this, I added yield() statements as each page is sent and serial messages are sent, like this:

Code: Select allvoid HandleVersion()
{
  char temp[800];
  snprintf( temp, 800, PAGE_Version, __DATE__, __TIME__ );
  server.send( 200, "text/html", temp );
  yield();

  Serial.print( "Page: Version " );  Serial.println(ESP.getFreeHeap());
  yield();
}


I am not sure if all of the yields() are necessary, but it now appears to be stable again. If the background tasks do not need to run, I have read that control is returned quickly.

Hope this helps others.