SoftwareSerial esp (8,9);
void setup()
{
esp.begin(9600);
esp.println("AT+CWMODE=3");
delay(100);
esp.println("AT+CIPSTART=\"TCP\",\"192.168.8.100\",5555");
delay(1000);
esp.println("AT+CIPSEND=3");
delay(100);
esp.println("bbb");
delay(100); }
The string "bbb" is recieved on the server and the server responds back, which is shown in the serial monitor as:
+IPD,19:the string is found
I want to read this response and use it back in the code for further conditional statements. But i am unable to do this. So far i have tried these methods.
1st method by using esp.readString() as shown below:
String buffer="";
while (esp.available()>0)
buffer+= esp.readString();
Serial.print(buffer);
2nd by using esp.read() as shown below:
String buffer="";
char c;
while (esp.available()>0) {
c= esp.read();
buffer+=c;}
Serial.print(buffer); // i have also tried using esp.write() directly for prinitng here intead of storing it in a buffer
These two methods returned with incomplete information in the response string buffer ie i only get:
busy s...
Recv 3 bytes
SEND OK
+IPD,19:the string
I can not get the entire response in the buffer as mentioned in the start i.e the string is/isnt found. On the other hand if i execute the command AT+CWLAP and store its response in the buffer string, i get the entire thing. So i cant understand why is there a difference storing these two response using the same technique.
Lastly i have also used esp.readBytes() as shown:
char c[500];
esp.readBytes(c,400);
esp.write(c);
This code gives me the whole response sometimes but sometimes it just gives a long garbage value. But the times it does give me the complete +IPD response, it switches some of the alphabets ie `the string is found` becomes `the strjng is gound`
If anyone could help me out i'll be very thankful.