embeddediotesp8266arduino-esp8266esp8266wifi

ESP8266 watchdog reset when using WiFi


I'm trying to use WiFi on a ESP8266EX based board (XTVTX WEMOS D1 Mini Pro).

The sketch is really simple.

#include <ESP8266WiFi.h>

void setup() {
  Serial.begin(9600);

  WiFi.begin("<ssid>", "<password>");
}

void loop() {
  if ( WiFi.status() == WL_CONNECTED)
  {
    Serial.println("Connected");
  }
  else 
  {
    Serial.println("Not Connected");
  }

  yield();
}

The board keeps rebooting for a watchdog reset (source: https://arduino-esp8266.readthedocs.io/en/latest/boards.html#rst-cause).

After a few seconds a fatal exception is raised (28 = LoadProhibitedCause - source: https://arduino-esp8266.readthedocs.io/en/latest/exception_causes.html#exception-causes-exccause).

Here it is the log that shows the issue.

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v00044b80
~ld
sp 0x3fffe9d0 
epc1=0x40204d1a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x04000102, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28): 
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
[...]

My setup:

Every other sketch which does not involve the use of WiFi is working without issues.

This sketch works fine on the AzDelivery ESP8266MOD 12-F board which is very similar.

The board is new and I've seen the WiFi working for a few seconds before entering in the boot loop.

Other people with the same behavior were using #include <WiFi.h> instead of #include <ESP8266WiFi.h>, so this is not my case.

I can't understand what is the problem. Has anyone faced this problem before and found a solution?

Thank you for your time.


Solution

  • As suggested by @Juraj (see comments below the question) the problem is the power consumption of this board.

    I've modified the sketch in this way:

    #include <ESP8266WiFi.h>
    
    void setup() {
      Serial.begin(9600);
    
      // >>>>>
      // set the maximum tx power (Values range from 0 to 20.5 [dBm] inclusive)
      WiFi.setOutputPower(19.25);
      // <<<<<
    
      WiFi.begin("<ssid>", "<password>");
    }
    
    void loop() {
      if ( WiFi.status() == WL_CONNECTED)
      {
        Serial.println("Connected");
      }
      else 
      {
        Serial.println("Not Connected");
      }
    
      yield();
    }
    

    When values higher than 19.25 are set, the board resets every time a connection with the AP is established.

    See the documentation here https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/generic-class.html#setoutputpower.

    Thanks to @Juraj for the quick support!