Reading Serial response from AT command (ESP8266,ESP-01) problem

Hello,

Im trying to get html response from server via esp01 module

when using the serial monitor in arduino studio everything works fine

here is the serial monitor output

AT+CIPSTART="TCP","aaaa.aaaa",80

CONNECT

OK
AT+CIPSEND=43


OK
> 
Recv 43 bytes

SEND OK

+IPD,227:HTTP/1.1 200 OK
Date: Sat, 19 Jan 2019 18:42:58 GMT
Server: Apache
X-Powered-By: PHP/7.2.11
Vary: Accept-Encoding,User-Agent
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

10
Hello from server

0

CLOSED

but when im trying to do the same from the sketch my response is returned partially (63 bytes always)

AT+CIPSTART="TCP","aaaa.aaaa",80

CONNECT

OK
AT+CIPSEND=43


OK
> 
Recv 43 bytes

SEND OK

+IPD,227:HTTP/1.1 200 OK
Date: S

it ends on the first letter of date for some reason

here is my sketch

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX //serial for comunication with esp
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.setTimeout(5000);//dont know if i need this

  delay(10000);

  //check wifi module
  mySerial.println("AT");
  delay(1000);
  if(mySerial.find("OK"))
  {
    Serial.println("Initializing");
  }else{
    Serial.println("Error initializing");
  }
}

void loop() { // run over and over

  Serial.println("go");
mySerial.println("AT+CIPSTART=\"TCP\",\"aaaa.aaaa\",80");
delay(1000);
    while(mySerial.available()){
    Serial.write(mySerial.read());
     delay(1);
  }
mySerial.println("AT+CIPSEND=43");
delay(1000);
    while(mySerial.available()){
    Serial.write(mySerial.read());
     delay(1);
  }
mySerial.println("GET /load.php HTTP/1.1");
delay(100);
    while(mySerial.available()){
    Serial.write(mySerial.read());
     delay(1);
  }
mySerial.println("Host: aaaa.aaaa");
delay(100);
    while(mySerial.available()){
    Serial.write(mySerial.read());
     delay(1);
  }
mySerial.println("");
delay(2000);


    while(mySerial.available()){
    Serial.write(mySerial.read());
     //delay(100);
  }

delay(5000);

}

what is the reason for this behavior? how can i fix this?
i've tried increasing baud rate. this did not helped.

All those delay()s just get in the way. Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

Robin2:
All those delay()s just get in the way. Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

but i need some kind of delay to receive response from the server.
how would you approach that?

kosmos1:
but i need some kind of delay to receive response from the server.

Why?

Generally speaking a "listener" should be listening all the time in case it misses something.

You need to give more details of what you are trying to achieve.

...R

Of course Robin is right about advising you to go for a 'non-blocking' Serial reception, but that has nothing to do with your issue.mySerial.print("AT+CIPSTART=\"TCP\",\"aaaa.aaaa\",80\r\n");ESP AT-mode needs both CR & NL as a line ending (which is what you must have 'set' in your Serial Monitor or you would be having the same issue.