Getting a reset error on a WEMOS D1 As a learning effort, I am trying some sample code on my WEMOS D1, which is basically an Arduino compatible board with a built-in ESP8266 (Wi-Fi module).

This is the output of my Serial Monitor:

1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
Initializing Wifi...
Start printMacAddress
 ets Jan  8 2013,rst cause:4, boot mode:(1,4)

wdt reset


It stops there and I see no more messages. Below is the code I am trying (from https://www.arduino.cc/en/Guide/ArduinoWiFiShield):

#include &lt;SPI.h&gt;    
#include &lt;WiFi.h&gt;    

void setup() {    
  // initialize serial and wait for the port to open:    
  Serial.begin(115200);    
  // attempt to connect using WEP encryption:    
  while(!Serial) ;    
    Serial.println("Initializing Wifi...");    
    printMacAddress();    
    // scan for existing networks:    
    Serial.println("Scanning available networks...");    
    listNetworks();    
}    

void loop() {    
  delay(10000);    
  // scan for existing networks:    
  Serial.println("Scanning available networks...");    
  listNetworks();    
}    

void printMacAddress() {    
  Serial.print("Start printMacAddress");    
  // the MAC address of your Wifi shield    
  byte mac[6];                        
  // print your MAC address:    
  WiFi.macAddress(mac);    
  Serial.print("MAC: ");    
  Serial.print(mac[5],HEX);    
  Serial.print(":");    
  Serial.print(mac[4],HEX);    
  Serial.print(":");    
  Serial.print(mac[3],HEX);    
  Serial.print(":");    
  Serial.print(mac[2],HEX);    
  Serial.print(":");    
  Serial.print(mac[1],HEX);    
  Serial.print(":");    
  Serial.println(mac[0],HEX);    
}    

void listNetworks() {    
  // scan for nearby networks:    
  Serial.println("** Scan Networks **");    
  byte numSsid = WiFi.scanNetworks();    
  // print the list of networks seen:    
  Serial.print("number of available networks:");    
  Serial.println(numSsid);    
  // print the network number and name for each network found:    
  for (int thisNet = 0; thisNet&lt;numSsid; thisNet++) {    
    Serial.print(thisNet);    
    Serial.print(") ");    
    Serial.print(WiFi.SSID(thisNet));    
    Serial.print("\tSignal: ");    
    Serial.print(WiFi.RSSI(thisNet));    
    Serial.print(" dBm");    
    Serial.print("\tEncryption: ");    
    Serial.println(WiFi.encryptionType(thisNet));    
  }    
}


I am not a hundred percent sure, but I think this started happening when I connected D8 (Digital Pin 8) to a relay.  I later read that it has a specific use (to flash firmware I think). The error message appears to point to something called a "WatchDog Timer", but I am not even sure what to eat that with. :-)

There are no error messages in the IDE and it even uploads fine. So why is this happening and how do I fix it?

TIA!
If Watchdog timer is the cause of reset that means there is at least one place in your code that runs too long without allowing subsystems to do the background tasks. It might be possible the part of your code causing the problem is:

while(!Serial) ;


Instead that loop use:

while(!Serial)
  delay(100);


so the background tasks will get the chance to be exectuted during the while loop.

EDIT:
In fact you can completely remove that while loop as it is not necessary. There is a possibility !Serial is always true so the loop never ends. And I suggest you using 74880 instead of 115200 so you can see the debug messages sent automatically by ESP8266.
END OF EDIT

However, if that is not the part of the code that causes the problem (and I think it is not) then the problem might be for loop where you list networks. You can check if that is the problem by adding a small delay inside the loop as follows:

for (int thisNet = 0; thisNet&lt;numSsid; thisNet++) {
  delay(1);    
  Serial.print(thisNet);    
  Serial.print(") ");    
  Serial.print(WiFi.SSID(thisNet));    
  Serial.print("\tSignal: ");    
  Serial.print(WiFi.RSSI(thisNet));    
  Serial.print(" dBm");    
  Serial.print("\tEncryption: ");    
  Serial.println(WiFi.encryptionType(thisNet));    
}


If the problem will still exist then you can add a few more delay(1); statements through the code.

Instead of delay you may use yield(); which is the same as delay(0);.