I've Arduino UNO and ESP8266 connected via a SoftwareSerial. Arduino UNO communicates with ESP8266 by sending AT commands.

And I need to write a function to fetch HTTP responses and return a response body as a string.

String fetch(String host, String url) {  
  // Enable Multiple Connections

  // Establishes TCP Connection with the host.
  esp8266.println("AT+CIPSTART=0,\"TCP\",\"" + host + "\",80");

  String payload = "GET " + url;

  esp8266.println("AT+CIPSEND=0," + String(payload.length() + 4)); 

  return esp8266.readStringUntil("SEND OK");

Unfortunately, it doesn't work as I expected. It never returns a whole response body. Most of the time just fails.

I don't understand how to block commands until they finish.

Based on ESP8266 AT commands doc, some commands finish with "OK", some without. Ideally, I need to wait for every command to finish, till I run next command.

Can somebody advise, is there a common way to write to serial and wait for command to finish?


I guess, if I know how to make following code blocking, I'll solve this problem:


It returns:



busy p... AT

busy p... AT

busy p...


  • AT+CIPMUX=1 is setup. it is not something you should set repeatly – Juraj May 3 at 18:49
  • 1
    after AT+CIPSEND you should wait for prompt >. you send AT+CIPCLOSE=0 while AT+CIPSEND is executing – Juraj May 3 at 18:51
  • You can program the ESP8266 with the Arduino IDE and put code to communicate however you want. It’s mostly way easier to deal with your own code on one of those than with AT commands. That’s why you hardly ever see anyone using AT commands with them anymore. It’s a pretty powerful MCU and depending on what exactly you want to do you most likely don’t need the UNO at all and that would make things infinitely easier. – Delta_G May 3 at 19:35
  • SoftwareSerial doesn't work reliably at 115220 baud. use 9600 baud. set it in AT firmware too – Juraj May 3 at 19:42
  • 115220 baud is another problem to solve. I've actually already set it to 9600. – mrded May 3 at 19:59

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.