I have here such code of sending commands with arduino mega on esp8266. Get requests go through well. But I need to get a response from the server. How can I do that?

Output to console:

Code:

#include <SoftwareSerial.h> #define RX 50 #define TX 51 String AP = "Home_S2"; String PASS = "supremum"; int countTimeCommand; unsigned long lastTimeMillis = 0; boolean found = false; SoftwareSerial ESP8266(RX,TX); void setup() { Serial.begin(9600); ESP8266.begin(115200); ESP8266.println("AT+RST"); // Перезагрузка esp8266 sendCommand("AT+CWMODE=1",5,"OK"); sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK"); makeGetRequest("alexey.surnin.com.ua","/push.php"); } void loop() { if (ESP8266.available()) { Serial.write(ESP8266.read()); } if (Serial.available()) { ESP8266.write(Serial.read()); } } void makeGetRequest(String host, String url){ ESP8266.println("AT+CIPMUX=1"); delay(1000); ESP8266.println("AT+CIPSTART=4,\"TCP\",\""+host+"\",80"); delay(1000); String cmd = "GET " + url + " HTTP/1.1\r\nHost:" + host + "\r\nConnection: close"; ESP8266.println("AT+CIPSEND=4," + String(cmd.length() + 4)); delay(1000); ESP8266.println(cmd); delay(1000); ESP8266.println(""); } void sendCommand(String command, int maxTime, char readReplay[]) { Serial.print("at command => "); Serial.print(command); Serial.print(" "); while(countTimeCommand < (maxTime*1)) { ESP8266.println(command);//at+cipsend if(ESP8266.find(readReplay))//ok { found = true; break; } } if(found == true) { Serial.println("OYI"); countTimeCommand = 0; } if(found == false) { Serial.println("Fail"); countTimeCommand = 0; } found = false; } 

    1 answer 1

    The maximum bitrate for ESP8266 is 19200. Apparently, this is the reason.

    • The “native” bitrate of ESP8266, according to which AT commands run by default - 115200. - insolor