ESP8266 WiFi shield for long time running...

Hello,

I have a running project using the RedBoard and the ESP8266 WiFi shield…

These are the steps:

  1. Connect to the shield via (soft)serial

  2. Connect the access point

  3. send POST messages to some server

All these works perfectly…for 2-3 hours, but then POST messages are stop to reaching the server…

Adding some debug messages I found that the local IP address of the WiFi shield got corrupted (in normal it is like 10.0.0.x, but it becomes x.0.0.0, where x changes every few seconds)…To add this the connection to the access point still seems to be intact from both end…

I tried to restart and also unplug the module, but it have to be off for a long time (more than half hour) before comes back to normal functionality…

Anybody with some experience about such problem?

Some more details…

  1. The code (most of)
#include <SoftwareSerial.h>
#include <SparkFunESP8266WiFi.h>

static ESP8266Client _client;
static char _http[] = "POST http://10.0.0.5/LocalAPI/api/RFID HTTP/1.1\r\nContent-Type:application/x-www-form-urlencoded\r\nHost:10.0.0.5\r\nContent-Length:27\r\n\r\nid=000000000000000000000000";

void setup() {
    Serial.begin(9600);
    while (!Serial);

    while (!esp8266.begin(9600))
    {
        esp8266.reset();
    }

    while (esp8266.setMode(ESP8266_MODE_STA) < 0);

    esp8266.connect(_networkName, _password);
}

void loop() {
    _client.connect("10.0.0.5", 80);

    _client.print(_http);
}

I made some debugging, and found that if I remove the _client.print(_http); line, all works perfectly for 6-7 hours, but with that line in it it can go crazy very fast (I told 2-3 hours as that why I saw, but now I saw less than that - some 40 minutes)…

There is any problem with the print function?

And one more bit - this time much happier…

I found the solution, but! I would like an explanation, if someone has it :?

All I had to do is to read! back the answer after writing the POST string, so the code changed like this:

_client.print(_http);

while (_client.available())
{
   _client.read();
}

It seems that the buffer must be cleaned before the next print-out, otherwise something goes wrong with the communication…

Thanks for posting the solution. It seems most members here don’t have experience with the ESP8266 yet. But it seems that the Serial buffer was overflowing. Lots of info on this with a Google search. This was my first though when I read your original post, but wasn’t for sure since your symptoms are unique.