Hey guys,
Ive just started to work with ESP8266-12 board. I am trying to perform the following AT commands inside the void setup(). But I am unable to get the response from ESP8266 after each command except for the first one, which does come after all Serial.println statements have been executed. Have a look at the screenshot attached!
My objective is to print the response of each AT command after its executed. Here's my code:
#include <AltSoftSerial.h>
AltSoftSerial ESPserial;
void setup()
{
Serial.begin(9600); // communication with the host computer
ESPserial.begin(9600); // Start the software serial for communication with the ESP8266
Serial.println("Starting ESP266.....!");
do{
ESPserial.println("AT+RST");
delay(1000);
if(ESPserial.find("Ready"))
{
Serial.println("Module Ready!");
espStart = true;
if (ESPserial.available()) {
String msg = ESPserial.readString();
Serial.println(msg);
}
Serial.println("==============================");
Serial.println("Listing out Access points:...");
ESPserial.println("AT+CWLAP");
if(ESPserial.available())
{
delay(1000);
Serial.write(ESPserial.read());
}
delay(1000);
Serial.println("Joining Defined AP...");
delay(2000);
ESPserial.println("AT+CWJAP=" + ssid +"," + pass );
if(ESPserial.available())
Serial.write(ESPserial.read());
delay(1000);
Serial.println("Setting CWMODE=1...");
delay(1000);
ESPserial.println("AT+CWMODE=1");
if(ESPserial.available())
Serial.write(ESPserial.read());
delay(1000);
Serial.println("Accepting multiple connections...");
delay(1000);
ESPserial.println("AT+CIPMUX=1");
if(ESPserial.available())
Serial.write(ESPserial.read());
delay(1000);
Serial.println("Setting server with port value as 80.....");
delay(1000);
ESPserial.println("AT+CIPSERVER=1,3333");
if(ESPserial.available())
Serial.write(ESPserial.read());
delay(1000);
Serial.println("Obtaining server IP address....");
delay(1000);
ESPserial.println("AT+CIFSR");
if(ESPserial.available())
Serial.write(ESPserial.read());
}
else
{
Serial.println("Module not ready!");
espStart = false;
}
}while(espStart==false);
I have attached the screenshot of my arduino serial window! Pls help me out!
Thanks in advance! ![]()
