The ESP8266 using the Arduino Core reports Wi-Fi status with the WiFi.status() function. The D1M-WX1 Weather Station attempts to connect to Wi-Fi every 250 milliseconds until the “Connect” status is found. If this does not happen after 15 attempts, it prints the status to the Serial Monitor.
Normally, the LED on the ESP8266 flashes five or six times until the connection is made. The LED will be dark during the six or seven seconds it takes to post the weather data on the Internet. It will flash three times before the station goes to sleep for 10 minutes. The code is in the logonToRouter() function of the weather station sketches.
If a Wi-Fi connection can not be made, the LED will flash 16 times and the exit code will appear on the Serial Monitor. The status codes are:
0 = Idle Status – WiFi.begin() is called and remains active until the number of attempts expires (resulting in CONNECT_FAILED) or a connection is established (resulting in CONNECTED)
1 = No SSID Available – Unit is too far from the Wi-Fi access point, the SSID and/or password is incorrect, or the SSID is for a 5GHz-band access point.
2 = Scan Completed – Scanning for available networks is completed.
3 = Connected – Success.
4 = Connection Failed – The opposite of success.
5 = Connection Lost
6 = Disconnected
255 = No Shield – Used for compatibility with the Arduino WiFi Shield – not relevant to the ESP8266.