Arduino: lost wifi cause a reboot

Created on 1 Feb 2018  路  4Comments  路  Source: esp8266/Arduino

Basic Infos

Hardware

Hardware: ?ESP-12?
Core Version: ?2.1.0-rc2?

Description

Problem description
I have the below code to detect lost wifi connection then re-connect (with the existing ssid and pw). and I trigger the lost-wifi by shutting down my router, but when the wifi is lost, it cause 8266 to reboot.

Settings in IDE

Module: ?ESP9266MOD-12E/F
Flash Size: ?4MB?
CPU Frequency: ?80Mhz?
Flash Mode: ?qio?
Flash Frequency: ?80Mhz?
Upload Using: ?OTA / SERIAL?
Reset Method: ?ck / nodemcu?

Sketch

#include <ESP8266WiFi.h> 

void setup() {
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(ssid, pass);
}

void loop() {
   if (WiFi.status() == WL_CONNECTED) {
       ....
   }else{
     WiFi.begin(ssid, pass);
   }

}

Debug Messages

messages here

All 4 comments

you do realize your flooding WiFi.begin? im not sure if theres a check inside until its finished, but, your still running it millions of times, it just aint right :P

There is a function that will do that job better, place it at end of setup():
WiFi.setAutoReconnect (true);

and a handler :)

thanks for the autoreconnect tip, it seems reset on lost connection while exchanging data with a website...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dariopb picture dariopb  路  3Comments

gosewski picture gosewski  路  3Comments

tttapa picture tttapa  路  3Comments

hoacvxd picture hoacvxd  路  3Comments

Marcelphilippeandrade picture Marcelphilippeandrade  路  3Comments