Looking for some help on this please. It is a little long winded, but the point of it is I cannot retrieve a string response via my ESP8266 ESP-01S.

I connect my ESP to my Ardiuno using SoftwareSerial esp8266(2,3).

I can quite happily send POST and GET commands to my server and process the request server side. This is done through the AT sequence below. My server uses a REST API to receive the request and responds with a simple string (for example 'HELLO'). If I attempt the same client side functionality through C# code or Python on my Pi I receive the response from the server no problem. But on my Arduino the response is always 32 when reading via ESP.read() (which I believe is in bytes and signals end of data). I have also tried esp.readString() and esp.readStringUntil('\n') all with no luck.

Is it not possible to access the response sent back to the ESP using my approach?

I see many examples go down the route of programming the ESP directly. I'm not really looking to do that on this attempt as I am creating some basic Arduino tutorials for family and friends and would prefer to not add that complexity.

Result server response

while (esp8266.available() > 0) {
  Serial.println("." + esp8266.readString() + ".");

So I guess in short, am I wrong in expecting the


String data = "=DATA1";


String postRequest =
  "POST " + URI + " HTTP/1.1\r\n" +
  "Host: " + HOST + ":" + PORT + "\r\n" +
  "Accept: *" + "/" + "*\r\n" +
  "Content-Length: " + String(data.length()) + "\r\n" +
  "Content-Type: application/x-www-form-urlencoded\r\n" +
  "\r\n" +

// GET

String postRequest =
  "GET " + URI + "?data=" + data + " HTTP/1.1\r\n" +
  "Host: " + HOST + ":" + PORT + "\r\n" +
  "Accept: *" + "/" + "*\r\n" +
  "Connection: keep-alive\r\n" +
  "Content-Length: " + String(0) + "\r\n" +
  "Content-Type: text/plain\r\n" +
  • 1
    the host header value should not contain port – Juraj Feb 20 at 9:42
  • @Juraj That's not true. It's not needed only if it's the default, but even then it's nothing wrong having it. – gre_gor Feb 20 at 17:44
  • Those AT commands are missing arguments. 32 is the ASCII code for a space character. The HTTP server's first character of the response should be "H". Neither your POST or GET request have the proper format for the parameters. GPIO3 is a hardware serial's RX pin. – gre_gor Feb 20 at 18:04
  • thank you, @gre_gor. now I regret I was lazy to open the RFC – Juraj Feb 20 at 18:27
  • Juraj. Thanks, I understand. Although what is RFC? @gre_gor, thanks for your response but I'm pretty new to this and what you've said is above my head. I've followed other tutorials (my project is a hybrid of many of them) to get here. Do you know what arguments I am missing? As I seem to have included enough to covert sending data to my server? – Adam Plumridge Feb 20 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.