I wrote simple sketch in Arduino IDE, which makes ESP as AP and prints IP in Arduino IDE Serial Console. Everything was okey, but this Arduino program worked only once. Now, when i connect Arduino via USB, ESP will have two LED's always active (red and blue), will work as AP (i can connect to it via wifi from smartphone), but ESP now doesn't respond to Arduino AT commands. I thought that AT command: AT+CWMODE=2 will work only once, and if I disconnect Arduino, ESP will reset too. Now it doesn't even respond with "OK" command after sending "AT" command. I haven't changed my sketch. Do i need to reset ESP or flash firmware?
Here is my program:
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3);
void setup()
{
Serial.begin(9600);
esp8266.begin(115200);
while(!Serial);
Serial.println("Testing serial output");
sendAT("AT",500); //respond: OK
sendAT("AT+IPR=9600",500); //change baud rate, because SoftwareSerial don't like 115200
esp8266.begin(9600);
sendAT("AT+CWMODE=2",1000); //change mode to AP
sendAT("AT+CIFSR",2000); // show IP Address
}
void loop()
{
}
boolean sendAT(String commandAT, int time_){
Serial.print("Sending AT command:");
Serial.println(commandAT);
esp8266.println(commandAT);
delay(time_);
String response = "";
while(esp8266.available()){
response = esp8266.readString();
}
Serial.println("Message from ESP:");
Serial.println(response);
return 1;
}