Skip to main content
2 of 2
added 244 characters in body
chrisl
  • 16.6k
  • 2
  • 18
  • 27

How esp8266 gets response from server..?

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

SoftwareSerial ESP8266 (rxPin, txPin);

void setup() {
  Serial.begin(115200);   
  ESP8266.begin(115200);
  delay(2000);
}

void printResponse() {
  String s="";
  while (ESP8266.available()) {
    s+=ESP8266.readStringUntil('\n');
  }
  
  Serial.println(s);
  // now here you can parse and look for "+IPD" look for another line ending (if there is) and then extract the numeric value. 
}

void loop() {

  ESP8266.println("AT+CIPMUX=1");
  delay(1000);
  printResponse();

  ESP8266.println("AT+CIPSTART=4,\"TCP\",\"www.tcpss.000webhostapp.com\",80");
  delay(1000);
  printResponse();

  String cmd = "GET /test.html HTTP/1.1";
  ESP8266.println("AT+CIPSEND=4," + String(cmd.length() + 4));
  delay(1000);

  ESP8266.println(cmd);
  delay(1000);
  ESP8266.println();
  delay(1000);
  printResponse();

  delay(5000);
}

i have run this code and i am able to get this response from server like "+ipd 4,41".... what does it mean? here is the response after run the code in arduino......

WIFI GOT IP
AT+CIPLUX=1


OK
AT+CHPSTART=4,"TCP","www.tcpss.000webhostapp.com",80

4,CONNEC
AR)CR5NB⸮b⸮⸮k

j⸮L⸮⸮
Recv 27 bytes

SEND OK

+IPD,4,41

Thanks in advance.....