So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By scott.sanchez1975
#78106 Hello everybody,
I have some troubles with my ESP8266. I use NodeMCU ESP8266 v2 with SDK version: 2.2.1(cfd48f3). I also use Arduino IDE with ESP8266 libraries (latest). My problem is wdr reset. I don't have any idea why it happens, so maybe you can help me.

So, my code is here:
Code: Select all#include <ESP8266WiFi.h>

extern "C" {
  #include "user_interface.h"
  #include "wpa2_enterprise.h"
  #include "c_types.h"
  #include "cert.h"
}

static const char* ssid = "xxx";
char identity[] = "xxx";

void setup(){
  delay(2000);
  Serial.begin(115200);
  Serial.printf("Connecting to %s\n", ssid);

  if (!wifi_set_opmode(STATION_MODE)) {
    Serial.print("STATION_MODE isn't set");
  }

  struct station_config wifi_config;
  memset(&wifi_config, 0, sizeof(wifi_config));
  strcpy((char*)wifi_config.ssid, ssid);

  wifi_station_set_config(&wifi_config);
  wifi_station_clear_cert_key();
  wifi_station_clear_enterprise_ca_cert();
  wifi_station_clear_enterprise_username();
  wifi_station_set_wpa2_enterprise_auth(1);
  wifi_station_set_enterprise_identity((uint8*)identity, strlen(identity));
  wifi_station_set_enterprise_cert_key((uint8*)user_cert, sizeof(user_cert), (uint8*)user_key, sizeof(user_key), (uint8*)user_key_pass, sizeof(user_key_pass));
 
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  Serial.println("");
  Serial.println("WiFi connected"); 
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  delay(1000);
  WiFi.forceSleepBegin();

}

void loop()
{
}


And when the ESP8266 is connected to the internet, I try to set my ESP to sleeping mode (disconnect from WiFi etc. for saving power. And then, in the last line of code (WiFi.forceSleepBegin();) there is a situation...
I got such a response from ESP in serial monitor:
Code: Select allWiFi connected
IP address:
xxx.xx.xx.xx

Exception (3):
epc1=0x4010011d epc2=0x00000000 epc3=0x00000000 excvaddr=0x40071128 depc=0x00000000

ctx: cont
sp: 3ffffc10 end: 3fffffd0 offset: 01a0

>>>stack>>>
3ffffdb0:  ffffffff 00000000 3ffeb2e1 00000008 
3ffffdc0:  40231106 3ffeea68 3ffeea68 3fff120c 
3ffffdd0:  3ffef56c 0000003c 4010106b 3ffeea68 
3ffffde0:  00000000 40231aec 00000000 00000006 
3ffffdf0:  013b17ac 00ffffff 4c3b17ac 3fff14b4 
3ffffe00:  40243d48 00000000 00000000 402096e1 
3ffffe10:  3fff0c28 000001bd 000001bd 4010020c 
3ffffe20:  3fff120c 3ffef56c 3ffefdc8 401006dc 
3ffffe30:  00000000 3fff15d4 3ffefdc8 4010658c 
3ffffe40:  4021e580 3ffefdc8 3fff15d4 4021e598 
3ffffe50:  00000000 00000000 4021c235 3fff120c 
3ffffe60:  4021c35d 3fff120c 00000008 3fff1224 
3ffffe70:  40244130 3fff120c 0000049c 00000000 
3ffffe80:  40239d8c 3fff120c 00000000 00000001 
3ffffe90:  3ffe9509 3ffefdc8 3ffef56c 00000000 
3ffffea0:  4021d124 00000000 00000000 00000000 
3ffffeb0:  40238c61 3ffe9509 00000000 00000000 
3ffffec0:  40238de7 00000000 00000000 40238d9b 
3ffffed0:  3fffdad0 00000001 00000001 3fff1c14 
3ffffee0:  40238eaa 00000000 00000000 00000001 
3ffffef0:  40202650 3fff0c04 3ffe952c 3fff0c04 
3fffff00:  40238c1a 00000000 3fff0aa8 3fff0bb0 
3fffff10:  3fffdad0 3fff0aa8 00000000 4020269d 
3fffff20:  3ffe8550 3fff0aa8 3fff0af0 402025bc 
3fffff30:  702d7776 75646f72 6f697463 0000006e 
3fffff40:  00000000 00000000 00000000 00000000 
3fffff50:  00000000 00000000 00000000 00000000 
3fffff60:  00000000 00000000 00000000 00000000 
3fffff70:  00000000 00000000 00000000 00000000 
3fffff80:  00000000 00000000 00000000 00000000 
3fffff90:  00000000 00000000 00000000 00000000 
3fffffa0:  40203340 4c3b17ac feefeffe feefeffe 
3fffffb0:  feefeffe 00000000 3fff0ba8 40203050 
3fffffc0:  feefeffe feefeffe 3ffe952c 40100739 
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


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

wdt reset


Any solutions? I read that people with similar issue just use yield() or delay(0) and it solved their troubles...
Can anybody help me? I will be really grateful.
Best regards,
Scott.
User avatar
By scott.sanchez1975
#78165
schufti wrote:what is the esp expected to do after you send wifi to sleep?
An empty loop for the rest of its battery life seems a little senseless ...


I don't know. I use USB wire to charge ESP connected to my notebook (about 5V). Empty loop doesn't work. I have no ideas...