1
votes

I'm trying to simply connect my NodeMCU ESP8226 to my WiFi. I'm running the following code:

#include <WiFi.h>
// WiFi Settings 
char ssid[] = "wifinetwork";
char pass[] = "admin";

void setup(){
  Serial.begin(115200);
  WiFi.disconnect();

  Serial.println("================= S T AR T I N G ==============");
  WiFi.begin(ssid,pass);

  while(!(WiFi.status() == WL_CONNECTED)){
    Serial.print("...");

  }
  Serial.println("==== I AM CONNECTED TO THE WIFI ==== ");
  Serial.println("Your IP is: ");
  Serial.println(WiFi.localIP());
}

void loop(){


}

When I run this, I'm promted with the following:

ets Jan  8 2013,rst cause:4, boot mode:(1,0)

wdt reset

Now, I've tried adding delays pretty much everywhere, installing drivers again and restarting my PC, unplugging, replugging, nothing fixes this. My NodeMCU is connected directly to my USB Port, which apperently shouldn't be an issue.

Can anyone help me out?

1

1 Answers

1
votes

You should also see a lot of "..." on the console.

This code

while(!(WiFi.status() == WL_CONNECTED)){
  Serial.print("...");
}

is the culprit. In this loop you're completely hogging the CPU and no other components (e.g. WiFi stack) have a chance to run. That's why the watchdog barks and kills it (wdt reset).