-1

i don't manage to find out a solution with my code using ESP8266 (esp-01) and WiFiEsp.h library. I can receive datas easily but when i add some code after client.stop(), the library stops run the code and displays TIMEOUT error. See the part of code who works fine:

void loop()
{
  // listen for incoming clients
  WiFiEspClient client = server.available();
  if (client)
  {
    incomingString =""; //clear for new one
    Serial.println("New client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected())
    {
      if (client.available())
      {
        //do something...
      }
    }
    client.stop();
    Serial.println("Client disconnected");
   }
 } // end of loop

This part runs fine and now this is the part of code who fails:

void loop()
{
  // listen for incoming clients
  WiFiEspClient client = server.available();
  if (client)
  {
    incomingString =""; //clear for new one
    Serial.println("New client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected())
    {
      if (client.available())
      {
        //do something...
      }
    }
    client.stop();
    Serial.println("Client disconnected");
   }

   Serial.println("do something else")...
   delay(1000); // simulate delay to run something else
 } // end of loop

When i run this part, this the serial message:

[WiFiEsp] TIMEOUT: 60

Can you explain me why? How can i solve that ?

  • Yes, If the delay time added after "do something else" is about 300ms, the serial terminal display randomly [TIMEOUT] but still running. If the delay is set to 1000ms, it fails. In fact, I need do something else if the ESP8266 do not receive data. If the arduino runs something else and the ESP8266 receives datas, the program fails and stop. – Teddol Dec 13 '18 at 16:01
  • Maybe I should use interrupt method? What do you think about it? How can I do it with the ESP8266 + Arduino Mega – Teddol Dec 13 '18 at 16:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.