Post topics, source code that relate to the Arduino Platform

User avatar
By Linton_Samuel_Dawson
#26364 Yeah of course, I meant if a method like Serial.find() could be useful.. I use that to check if the module is ready or connected but i'm not sure it's useful for parsing too.

anyway, I made a little sketch to get the data but it does not seem to open the connection... I got to connect to the AP (checking there i see that the ESP is connected):
mySerial.print("AT+CWJAP=\"A_Nexus5\",\"***\"\r\n");

but then I can't open the connection with the server or get any data:

Code: Select allSerial.println("AT+CIPSTART=2,\"TCP\",\"coolparis.azundo.com\",80\r\n");
    mySerial.print("AT+CIPSTART=2,\"TCP\",\"coolparis.azundo.com\",80\r\n");
    delay(8000);
    if (mySerial.find("CONNECT")){
      Serial.println("connected to server");
    }
    else
    Serial.println("what?");


but I never get to see "connected to server"

Code: Select allString getdata = "GET / HTTP/1.1\r\nHost: coolparis.azundo.com\r\n\r\n";
   int lengthreq = getdata.length();
   String lengthreqS = String(lengthreq);

  //for (int i = 0; i<3; i++){
  String reqconn = "AT+CIPSEND=2," + lengthreqS + "\r\n";
    mySerial.print(reqconn);
    Serial.print(reqconn);
    delay(5000);
    mySerial.print(getdata);
    Serial.print(getdata);
    delay(5000);
      if (mySerial.find("IDP"))
        Serial.println("got something!");
  //}
  delay(7000);

  Serial.println("data should be there");

  if (mySerial.find("+IPD,2")){
    Serial.println("bula bula bula");
User avatar
By martinayotte
#26392 I don't think the way you process the Serial is good. During the delay(8000) The RX buffer is fill of to its maximum because you simply never read it, then it get probably overflowed and new characters coming in overwrite older one, that is why your find() doesn't find the "CONNECT" string.
You need to stay in a loop, reading characters manually, keeping them in your own buffer, and then check that buffer for the "CONNECT". That will help also to debug since you can output the buffer into your second serial.
Same thing will apply for the other parsings.