Double Reset Detector hangs ESP core

Seems to be a lot of people having success with Blynk and ESP’s, not sure why I am having this problem, but here it is.

I made a fairly basic DHT22 based temp/humidity sensor on an ESP8266 dev board, with a SSD1306 OLEAD display, a couple of simple buttons wired to GPIO pins and a battery level sensor to the analog pin. That all went pretty well, so then I added some simple Blynk code to get the thing logging to the cloud and got immediate problems.

It was connecting fine but then immediately crashing, resetting and reconnecting… A whole lot of this:

[3079] Con2:AndroidAP
[7312] Conn2WiFi
[7312] IP=192.168.1.89,GW=192.168.1.1,SN=255.255.255.0
[7312] DNS1=192.168.1.1,DNS2=(IP unset)
[7313] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on ESP8266_GENERIC

[8463] NTP time: Sun Feb 13 08:25:02 2022
[8679] Connecting to blynk.cloud:443
[9936] Certificate OK
[9937] <[1D|00|01|00] xPUKc5khUcZ10-e5nO_kvt5x4NEVJsrd
[10054] >[00|00|01|00|C8]
[10054] Ready (ping: 1ms).
[10055] Free RAM: 16344
[10121] <[11|00|02|00]vver[00]1.0.1[00]h-beat[00]45[00]buff-in[00]256[00]dev[00]ESP8266_GENERIC[00]fw-type[00]TMPLPTJB5J6u[00]build[00]Feb 13 2022 18:23:21[00]tmpl[00]TMPLPTJB5J6u[00]
[13317] >[00|00|02|00|C8]

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (28):
epc1=0x4020509e epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000010 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffdd0 end: 3fffffc0 offset: 0190
3fffff60:  00000000 00000000 00000000 3ffef0bc  
3fffff70:  00004650 00001d26 3ffef884 3ffefe20  
3fffff80:  3fffdad0 3ffefcd0 3ffef884 402058f5  
3fffff90:  3fffdad0 00000000 3ffefe0c 40205247  
3fffffa0:  feefeffe 00000000 3ffefe0c 4020d29c  
3fffffb0:  feefeffe feefeffe 3ffe86dc 40100f61  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
⸮[3078] Con2:AndroidAP

I searched for similar problems, heard something about issues with sprintf causing issues, wrote a replacement for that, no joy.

So then I tried an ESP32-WROOM and got the same thing; connecting then crash (“Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Exception was unhandled.”) and reboot.

Then I stripped the code completely bare to just this:

#define BLYNK_TEMPLATE_ID "zzzzzzzzzzzzzzzzzzzzzz"
#define BLYNK_DEVICE_NAME "zzzzzzzzzzz "
#define BLYNK_AUTH_TOKEN "zzzzzzzzzzzzzzzzzzzzz"

#define BLYNK_DEBUG
#define BLYNK_PRINT Serial

#include <BlynkSimpleEsp32_SSL_WM.h>

char auth_token[] = BLYNK_AUTH_TOKEN;
char wifi_ssid[] = "AndroidAP";
char wifi_pass[] = "password123";

void setup() {
  Serial.begin(9600);
  Blynk.begin(auth_token, wifi_ssid, wifi_pass);
}

void loop(){
  Blynk.run();
}

Same result.

So then I got out another brand new ESP32 dev board straight out of the anti-static bag and got the same result.

Con2:AndroidAP
[2638] Conn2WiFi
[2638] IP=192.168.1.226,GW=192.168.1.1,SN=255.255.255.0
[2638] DNS1=192.168.1.1,DNS2=0.0.0.0
[2638] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on ESP32_DEV

[2781] NTP time: Sun Feb 13 05:43:06 2022
[2825] Connecting to blynk.cloud:443
[4435] Certificate OK
[4435] <[1D|00|01|00] ohuYoxPJXexEKwdXxlh5WlPHCTn5E7cG
[4737] >[00|00|01|00|C8]
[4738] Ready (ping: 301ms).
[4805] <[11|00|02|00]pver[00]1.0.1[00]h-beat[00]45[00]buff-in[00]256[00]dev[00]ESP32_DEV[00]fw-type[00]TMPLkuO0T-LF[00]build[00]Feb 13 2022 15:42:26[00]tmpl[00]TMPLkuO0T-LF[00]
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d2105  PS      : 0x00060a30  A0      : 0x800d2269  A1      : 0x3ffb1f70  
A2      : 0x3ffc1724  A3      : 0x00000000  A4      : 0x00000adb  A5      : 0x00000061  
A6      : 0x3ffc1b70  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x00000001  
A10     : 0x00000001  A11     : 0x00000000  A12     : 0x3ffc1724  A13     : 0x00000079  
A14     : 0x00000000  A15     : 0x3ffc658c  SAR     : 0x0000000a  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000010  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  

ELF file SHA256: 0000000000000000

Backtrace: 0x400d2105:0x3ffb1f70 0x400d2266:0x3ffb1f90 0x400d6274:0x3ffb1fb0 0x40089872:0x3ffb1fd0

Rebooting...

Along the way I completely removed and reinstalled my entire Arduino IDE installation and all libraries twice.

Eventually after working out which way round to read the ESP Exception Decoder (backtrace heh) I ended up here:

0x400d23bd: DoubleResetDetector::loop() at C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector\src/ESP_DoubleResetDetector.h line 210
:  (inlined by) BlynkWifi::run() at C:\Users\User\Documents\Arduino\libraries\Blynk_WiFiManager\src/BlynkSimpleEsp32_WM.h line 692

So I commented out the line that calls the very tight DRD loop that just sits there calling millis() and the problem immediately went away.

I got exactly the same result when I went back to the ESP8266 board; comment out the DRD loop call and it works. Same thing if I enabled “#define USING_MRD true” it would hang at the MRD loop call and commenting out that call would fix the problem.

So. Absolute bare bones Blynk code, an ESP8266 board and two ESP32 boards all giving the same result. The DRD/MRD hangs the CPU.

I have no idea how nobody else seems to be having the same problem, perhaps they are just giving up, but I thought I would share my results.

Maybe I should be using the “Edgent” thing or some other library/version combination? If there is already some info on how to fix this somewhere I sure couldn’t find it. I’m pretty new to using Blynk, but not to cpp. Thoughts anyone?

1 Like

This is a library that war written by @khoih for Blynk Legacy. I don’t know if it works for Blynk IoT, but it has really been replaced by the Edgent functionality anyway.
So, I’d delete this and the Blynk_WiFiManager library and swap this:

for one of the Blynk 1.0.1 library files and re-compile.

Pete.

Thanks Pete,

^ This is good advice.

For any other newbies following along the “Blynk Wifi Manager” lib that comes up in the Arduino IDE Library Manager when you search and that will have #incldues conveniently added when you select it from the menu, is not actually part of the current Blynk build. These files have a “_WM” suffix and are probably not what you want to be using. There are a bunch of similarly named files in the Arduino\Libraries\Blynk\src\ directory and you should pick the one that fits your project and just manually type out an #include line for it.

As glaringly obvious as this seems in hindsight, selecting “Blynk” from the library menu just adds #include <Blynk.h> which simply provides a one line warning “Please include a board-specific header file, instead of Blynk.h (see examples)”.

Perhaps some more information would be helpful here.The first few examples seem to use BlynkSimpleEthernet.h. It’s not unreasonable at this point for a new user to just search for the wifi equivalent in the library manager and not realise the significance of the _WM suffix.

…and yes, there are a bunch of great examples in the Blynk\examples\Boards_WiFi\ directory if you look for them :slight_smile:

Thanks again for your help Pete.

1 Like