Using one of the RobotDyn boards with onboard WiFi and a Generic ESP8266 module.

I can load the sketch, but when WiFi.status() is called to see if WiFi enabled, the sketch hangs, rebooting the board after ten seconds are so.

void setup() {
  Serial.begin( 115200 );
  Serial.println( "begin - wifi status: " );
  // program hangs here - - - - - - - 
  int status = WiFi.status();
  Serial.println( status );

I think it might be a problem with the code you are using, prior to version 2.2.0 of the "ESP Core" the first block of code worked, since only the second version works.

It seems that you can get around it by rather than doing this:

 WiFi.begin(ssid, password); // connect to the network
 while (WiFi.status() != WL_CONNECTED) 

You should do this:

if (WiFi.status() != WL_CONNECTED) 
     WiFi.begin(ssid, password); // connect to the network
     delay (500);

Does that look it might be a likely cause?

Sources 1 2

  • No. I wish to know if WiFi available, so issues int status = WiFi.status();. The sketch hangs on this line. (Have added this to question for clarity.) – cc young Feb 1 '17 at 4:22

Think I found the cause!

I previously had

#include <WiFi.h>

but now using

#include <ESP2866WiFi.h>

This seems to work

I was unaware of the two library sets. Since I use both Arduino MiniPro and versions of NodeMCU, am now going through the libraries and determining what breaks.

IMHO, in regard to libraries, NodeMCU Lua libraries are far, far better than Arduino's C++ libraries.

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.