Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By erbedo
#43112 Hi, I just wrote a sketch for my ESP8266 that simply has to read through the analogRead(A0) from an hygrometer sensor and report the data to a server. Quick and simple.

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:

Code: Select allmyESP::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?
User avatar
By somedude
#43413 What voltage is your sensor outputting?
The analog pin only takes 0.2 to 1.2 V signal, if you have a 3.3V or even 5V sensor, you might be pushing it too far...