1

I am working on a project where the ESP 8266 sends a very long string about 3000 chas over http as client. Likewise sensor data are determined. The loop repeats itself every 250ms. Now I noticed that my server gets the data of the ESP often slower. In rare cases it takes up to a minute until the server receives something.

How do these delays occur and why are they not constantly the same? Does the length of the string have something to do with it or how much does it affect the delay? Are calculation and sensors processed only after sending?

The ESP works with this function.

String http_GET(String value){
  String payload = "non_Message";
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
    //WiFiClient client;
    HTTPClient http;  //Declare an object of class HTTPClient
    String send_data = "http://" + web_conect + value; 
    //http.begin(client, send_data);
    http.begin(send_data);
    //http.begin("http://" + address + ":" + port + "/" + path +"?" + param + "=" + value);  //Specify request destination
    int httpCode = http.GET();                                  //Send the request

    if (httpCode > 0) { //Check the returning code

      payload = http.getString();   //Get the request response payload
      Serial.println(payload);             //Print the response payload
      cut_time_date(payload);

    }

    http.end();   //Close connection

  }
  return payload;
}

2
  • 1
    I suspect it could be Strings fragmenting your heap, making it take longer to find free slots as time goes on. Don't use String for long-running or repeatedly-running operations. Take the String usage out and see if it stop slowing down, if so, you found the problem. – dandavis Mar 2 at 17:57
  • I tried it once. Unfortunately, the problem is still there. For me it is not bad, but I would still be interested where these delays come from. – TrompetenTom Mar 4 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.