So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Johnny Slow
#59017 I have esp8266 shield and Arduino uno. The esp8266 methods begin, setMode, connect,getAP often require many tries before succeeding. Is this normal?
Here is the code:

void setup() {
int retries = 0;
char connectedSSID[24];
memset(connectedSSID, 0, 24);

Serial.begin(9600);
Serial.println("start");
while (esp8266.begin() != true)
{
retries += 1;
Serial.print("try begin esp8266 #");
Serial.println(retries);
delay(5000);
}
Serial.println("esp8266 begin success");
retries = 0;
while (esp8266.setMode(ESP8266_MODE_STA) < 0)
{
retries += 1;
Serial.println("try station mode #");
Serial.println(retries);
delay(5000);
}
Serial.println("station mode success");
retries = 0;
while (esp8266.connect(mySSID, myPSK) < 0)
{
Serial.print("try router connect");
Serial.println(retries);
delay(5000);
}
Serial.println("router connect success");
Serial.println(mySSID);
delay(5000);
retries = 0;
while (esp8266.getAP(connectedSSID) <= 0)
{
retries += 1;
Serial.print("try IP #");
Serial.println(retries);
delay(5000);
}
Serial.println(connectedSSID);
Serial.println(esp8266.localIP());


}