1
#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.....

1
  • 2
    Your seeing corruption from running software serial at 115200 baud. – Majenko May 27 at 10:19
1

There's two things to know here:

  1. You're seeing corruption in your output because SoftwareSerial is not capable of working reliably at 115200 baud. You need to reconfigure your ESP8266 to operate at a lower baud rate (such as 9600) to be able to use it with an Arduino that doesn't have enough physical UARTs.
  2. The response +IPD,4,41 is telling you about the response. It's not itself the response.

It means "IP Data on channel 4 of length 41". It is then your responsibility to request that data from the ESP8266 using whatever AT command the ESP8266 requires.

Personally I would scrap the AT firmware and program the ESP8266 directly. That way you solve both problems: you can choose what baud rate to communicate at (if you even need to communicate to an Arduino at all), and you have no AT commands to parse or craft. It is a far more efficient way of working with the ESP8266 that trying to fudge things with the AT firmware and an Arduino.

4
  • Thanks this answer was helpful for me... – farhan May 27 at 17:32
  • But i want to know that when i change the baud rate in serial moniter, its changed but the response from esp8266 on AT commands not show why? if i did wrong, then what i need to to solve this issue. – farhan May 27 at 17:35
  • secondly, i want to know which AT commands esp8266 requires to to request data from esp8266 or code which i need to used in the arduino ide.... – farhan May 27 at 17:37
  • You have to change the baud rate on the ESP itself as well as the Arduino. There's an AT command to do it, but it has been known to brick the ESP. there's different versions of the firmware and commands differ between them. There's a PDF available online somewhere that lists all the commands. – Majenko May 27 at 17:40
1

SoftwareSerial does not works well for baud rate higher than 9600bps, you need to change your Arduino and ESP8266 to operate at 9600bps.

  1. Use the AT+UART_DEF=9600,8,1,0,0 to set the ESP8266 to 9600Baud, with 8 bit, 1 stop bit and no parity. And also remember to configure the Arduino accordingly. The AT command with _DEF suffix means it will only need to be set once and the configuration will be saved in the ESP8266. ESP8266 AT Command Set would be handy when programming the ESP8266 with AT Commands.

  2. Add longer delay after sending AT+CIPSEND and Get request as those network activities sometime take longer time to establish.

  3. The +IPD,4,41 means that Connect 4 (which you established with AT+CIPSTART is connected and there are 41 bytes payload waiting to be read. You can refer to ESP8266 AT Command Examples for more information.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.