-->
Page 1 of 1

ESP01 won't connect to WiFi every once in a while.

PostPosted: Sun Apr 16, 2017 10:35 am
by real2
Hi, I'm facing a wired problem.
My ESP8266 01 is normally able to connect to my home WiFi network and communicate with other devices.
The problem is that every once on a while, after some debugging and resetting, it gets stuck in the connection loop. (Which waits for it to connect)
When that happens, even resetting the module won't help.
The only solution I found to this is flashing the AT firmware using some flasher.exe and then flashing my code again using the Arduino IDE.

I'm pretty new to all this, so I think that the problem might be something I'm doing wrong.
This is my code:
Code: Select allvoid setup() {

    Serial.begin(9600);
    delay(10);

    // Initialize switch pin
    pinMode(switchPin, OUTPUT);
    digitalWrite(switchPin, LOW);
   
    // Connect to WiFi
    Serial.print("Connecting to ");
    Serial.println(ssid);

    Serial.print(WiFi.begin(ssid, password));
   
    while (WiFi.status() != WL_CONNECTED) {
        // Sometimes it gets stuck here.
        Serial.print(WiFi.status());
        delay(connectionStatusDelay);
    }
    Serial.println();
    Serial.println("WiFi connected");
   


Thanks in advance!

Re: ESP01 won't connect to WiFi every once in a while.

PostPosted: Mon Apr 17, 2017 12:38 am
by Otto Haldi
// Router Connection
const char ssid[] = "SSID"; // mon réseau SSID
const char pass[] = "pass"; // mon mot de passe
WiFiServer server(4050); // Port Forwarding

void setup() {

// Start WiFi network
int progress=0;
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.disconnect(); // Help to get a faster connecion!
WiFi.softAPdisconnect();
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
progress++;
if(progress==10)progress=0;
Serial.print(".");
}
// your code...