I am stumped. I have a few Wemos D1 Mini boards that were working on the local WiFi yesterday, yet today none of them will connect. More puzzling is that I can flash Tasmota on them and they all connect to the WiFi, but none with this code that was working yesterday. Any tips would be appreciated.

void setup_wifi() {
  // We start by connecting to a WiFi network
  Serial.print("Connecting to ");

  //Connect to WiFi network so we can reach the MQTT broker and publish messages to topics.
  WiFi.begin(wifi_ssid, wifi_password);

  while (WiFi.status() != WL_CONNECTED) {

  Serial.print(F("WiFi connected, "));
  Serial.print(F("IP address: "));
  • did you update the esp8266 boards package?
    – Juraj
    Commented May 22, 2019 at 18:16
  • Thanks for the response. No updates- I just turned on my PC to continue on my project from the previous day, and none of the Wemos devices will connect to the WiFi. But I can flash them with Tasmota and they connect to WiFi, so it's not a hardware issue. Commented May 22, 2019 at 18:27
  • I think it problem with your wifi master or with your slaves. But if few slaves can't connect to master wifi it can't be problem with your slaves. That restart your computer. It can be problem with avrdude or Arduino IDE. Commented May 22, 2019 at 18:53
  • and what version of the arduino esp8266 package you use? does it use the same SDK version as the Tasmota firmware?
    – Juraj
    Commented May 22, 2019 at 19:10
  • It looks like Version 2.2.2 of the WiFiesp library. But I've changed nothing. The sketch flashed and worked yesterday, but not today. Commented May 22, 2019 at 19:43

3 Answers 3


Fixed. My router is ancient and does not support WPA. As of ESP8266WiFi library Version 2.5.0, WPA is is the preferred mode. The solution is to get a better router, or add WiFi.enableInsecureWEP(); before calling WiFi.begin().

WiFi.begin(wifi_ssid, wifi_password);

Solved. (sort of). This is a working workaround.

I have determined that if I use ESP8266WiFi library Version 2.5.0 or later, all I get from WiFi.status() is WL_NO_SSID_AVAIL.

By reverting to ESP8266WiFi library Version 2.4.2, I can get a connection with the same sketch.

(Juraj's comments pushed me in the direction of trying older library versions.)


Assuming that it's not something silly and accidental like the password or ssid being changed in your code, there are two things you may be running in to:

  1. The WiFi.begin() function is technically not needed more than once. Values written with it are stored in a separate part of flash memory that is not overwritten by any sketch uploads. Since it's stored persistently, it may start connecting before your connection code is called. This causes a race condition that triggers a bug in the library that is, to my knowledge, still present, and can break the WiFi subsystem. If this has happened, the reason that the other firmware might work is if it fixes the error or somehow uses a different method. You can work around this by waiting a few seconds and then trying to connect if it's not currently connected. Try this fix: https://github.com/kentaylor/EraseEsp8266Flash to see if that's the problem. Alternatively, you can try some of the options in the first link of my next item to see if those work for this purpose.

  2. Remember how I said that the functions persist data in flash? That has a limited write count, and no, that partition has no wear-leveling. After so many writes (and, since begin() is called in setup, it does so every time the device starts or wakes!) it will fail to hold the correct values. The endurance can be quite poor on some cheaper flash devices (and cheaper boards). But, if you want to keep using begin() to set up the WiFi (rather than set it once the normal way and then make sure begin() isn't called again by your code), delete the stored parameters (Does the ESP8266 somehow remember wifi access data?) and then turn off persistence (esp8266 advertising AP even when flashed with custom firmware). I also suggest running the following code fragment to turn off persistence and then stop turning it off (since THAT change persists too!):

    if (WiFi.getPersistent()) { WiFi.persistent(false); }

This latter case is known to break Arduino projects, but NOT nodeMCU Lua ones. If the Tazmota firmware uses a different method, it could also ignore this issue but your code might experience it. To test this, try running the code on a different board (can be the same type, just so long as it's not the same one).

  • the SDK doesn't write the same configuration value to flash
    – Juraj
    Commented May 26, 2019 at 15:37
  • Did they fix that, or was this always the case? I was under the impression that it did this at least at one point.
    – user47164
    Commented May 26, 2019 at 22:05
  • Thanks for the useful information. Is the "Erase Flash: All Flash Contents" in the Arduino IDE different from Kent Taylor's program? I've tried the same sketch on a few Wemos D1 Minis and a couple of NodeMCU boards. When using ESP8266WiFi library Version 2.4.2, they all compile, upload to the ESP, and connect to the WiFi. When using ESP8266WiFi library Version 2.5.0 or later, none of them connect to the WiFi. I strongly suspect my Router, even though I rebooted and later reset it to the original setup. Time for a new router. Commented May 27, 2019 at 3:44
  • @RDragonrydr, AT firmware reference Appendix 'A' Notice
    – Juraj
    Commented May 27, 2019 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.