I swore I had the NodeMCU running on WiFi before, but after uploading new code (not new ESP8266 firmware either) that accesses the wifi library, I got crazy output on serial monitor. Basically it was an exception and a stack dump (I needed Imodium for my NodeMCU!!) that repeated after any call to the wifi code in library.
epc1=0x401003e9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x400072f1 depc=0x00000000
I originally had the 2.2 version of ESP8266 source and library and removed it and got latest build at 2.3 for Arduino. This all done through the ‘Board Manager’ built-in to Arduino IDE. I also tried adding WiFi.disconnect(true); before calling any wifi code. The stack dump continued and I got nowhere. I tried changing boards and tried all ESP8266 varieties to no avail. Then I did a search on all exceptions and found that a workaround for a (2) exception was to add WiFi.persistent(false). I’ll be a monkey’s uncle! That did it. So, WiFi.disconnect(true) by itself did not solve the problem….persistent(false) did.
Serial.print(“Connecting to “);
That code above did the trick.