All welcome.

I'm trying to connect nodemcu to the phone's wifi.

And nodemcu can't do it. But sometimes after several reboots she does it. Also if i use my old phone - nodemcu connects perfectly! Why?

My "new" phone: Fly FS504 Cirrus 2

My old phone: Fly IQ4504 Quad.

My code:

#include <ESP8266WiFi.h>

const char *ssid =  "Just my SSID";     

const char *pass =  "Some password";

WiFiClient client;

void setup() 

       Serial.println("Connecting to ");

       WiFi.begin(ssid, pass); 
       while (WiFi.status() != WL_CONNECTED) 
            // stack here (only with new phone)
      Serial.println("WiFi connected"); 

void loop() 

  • 1
    Does it crash? If you're on a breadboard I guess that's the reason. You could try to explicitly WiFi.disconnect() before attempting to connect, the esp8266's wifi is a bit buggy sometimes. – Sim Son Jun 11 '19 at 15:32
  • @SimSon, hmm.. Just add Wifi.disconnect() before WiFi.begin()? – CrazyProgrammist Jun 11 '19 at 15:42
  • @SimSon, thanks! It's working! I spent a lot of time for this problem. Have a nice day :) – CrazyProgrammist Jun 11 '19 at 15:46
  • glad to hear. So did my workaround "fix" your problem? If yes, I'd form it into an answer so you can close this question – Sim Son Jun 11 '19 at 16:33
  • @SimSon, yeah, do it – CrazyProgrammist Jun 12 '19 at 5:46

From my experience the esp8266's wifi is a little bit buggy sometimes. I'm not sure if it has something to do with the esp auto-connecting to known networks, but I managed to work-around this issue by explicitly WiFi.disconnect()ing from any potential network right before calling WiFi.begin().

Another thing that I noticed several times is that the esp can be easily disturbed when connected to a breadboard, in special when wifi is in use (in this case the esp might even crash). There must be some bad interferences, I guess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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