However, the ESP-12 randomly crashes, and I have no idea why. Also, it happens in different parts of the code, sometime when I am building a string, sometimes when I do the GET to the server, sometimes when I check if I am connected. Also, sometimes it happens on the first read, sometimes on the 10th, sometimes on the 100th.
The code is quite simple. In the loop, I simply do an analogRead() and then I call the following function:
myESP::void myESP::doGet(String data, String sensor, int duration) {
// Serial.println("Trying to send it...1");
WiFiClient client;
const int httpPort = 5000;
Serial.println("Before checking connection");
if (!client.connect(_host, httpPort)) {
Serial.println("connection failed");
}
Serial.println("Trying to send it data.");
const char* host = "192.168.1.200";
uint8_t mac[6];
WiFi.macAddress(mac);
Serial.println("Building string");
String url = "/postmultipledata";
Serial.println("1");
url += "?data=";
Serial.println("2");
url += data;
Serial.println("3");
url += "&deltaT=";
Serial.println("4");
url += duration;
Serial.println("5");
url += "&mac=";
Serial.println("6");
url += macToStr(mac);
Serial.println("7");
url += "&sensor=";
Serial.println("8");
url += sensor;
// Serial.print("Requesting URL: ");
Serial.println(url);
Serial.println("Doing GET");
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(10);
}Don't look at all the Serial.println(), they're just there for debugging purposes.
Any idea?