Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By thesun93pp
#20892 Hi everyone!

I use Arduino and ESP8266 for send and receive data with server. ESP8266 send(POST) data to server sucessfully. But when i use receice(GET) data (html,txt,xml...) from web server, My data are wrong. they are special characters.this problem takes me many days!
I can not understand!Please help me!
( My English is not good!)

This is code to read data from server:
Code: Select allString readData(long timeout)//const int timeout
{
  String response;
  char c ;
  unsigned long time = millis();
  while ( (time + timeout) > millis())
  {
    while (Serial1.available()>0)
    {
      // The esp has data so display its output to the serial window
     // response = response + char(esp.read());
      c =Serial1.read();
      Serial.write(c);//At this, printed special data
      response =response+ c; // read the next character.
     
    }
  }
  return response;
}

This is my screen when it prints:
Code: Select allGET /data.txt HTTP/1.1
Host: 192.168.1.11
Accept: "text/html,ap
SEND OK

+IPD,274:HTTP/1.1 200 OK
Date: Fri, 19 Jun 2015 08:10:58 GMT
Server: Apae4(n nL. /.1
tdi ,  58:G
g58e7
c-gbsone:
niceotptpnho


thank you!
User avatar
By tytower
#20974
Code: Select allwhile (Serial1.available()>0)
    {
      // The esp has data so display its output to the serial window
     // response = response + char(esp.read());
      c =Serial1.read();
      Serial.write(c);//At this, printed special data
      response =response+ c; // read the next character.     
    }
  }
  return response;
}

So how does response fit into it?
I would try
Code: Select allwhile (Serial1.available()>0)
    {
      // The esp has data so display its output to the serial window
     // response = response + char(esp.read());
      c =Serial1.read();
      Serial.write(c);//At this, printed special data
      //response =response+ c; // read the next character.     
    }
  }
  return response;
}