ESP32 - Guru Meditation Interrupt wdt timeout on CPU0

Hi there,

I am new to the ESP32 programming but have a lot of experience with STM MCUs. I have made some simple code to interface with Blynk to render my appartment intercom intelligent. This all works, but after some random period of time (I’ve had it be 10 minutes, sometimes its 2+ hours) I get an error where my ESP32 does not reboot even if it says it will.

Guru Meditation Error: Core  panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC       0x4008531a PS       0x00060634  A0       0x8010cc  A1       0x3fb6c  
A2       0x00000000  A3       0x0000007f A4       0x3f73c4  A5       0x00000001  
A6       0x3fce0  A7       0x00000000  A8       0x8008a7c A9       0x3fb6d  
A10      0x00000000  A11      0x3fce0  A12      0x00000000  A13      0x00000001  
A14      0x00060a0  A15      0x00000000  SAR      0x00000020  EXCCAUSE 0x00000005  
EXCVADDR 0x00000000  LBEG     0x4000ce  LEND     0x4000cf  LCOUNT   0xffff  

ELF file SHA256: 000000000000000

Backtrace:0x4008531a0x3fb6c 0x4010cb:0x3fb6f 0x401110b:0x3fb720 0x4008981e0x3fb750

ore 1 register dump:
PC       0x4000c71  PS       0x00060034  A0       0x8008a10  A1       0x3fbe0  
A2       0x3fb058  A3       0x3f14f4  A4       0x00000014  A5       0x3fc190  
A6       0x3fc1d  A7       0x00000001  A8       0x00000001  A9       0x3f14f5  
A10      0x000000a  A11      0x3fb060  A12      0x8008ac  A13      0x3fc160  
A14      0x00000008  A15      0x00000001  SAR      0x00000014  EXCCAUSE 0x00000005  
EXCVADDR 0x00000000  LBEG     0x400daa LEND     0x400da7  LCOUNT   0x00000000  

ELF file SHA256: 000000000000000

Backtrace:0x4000c71:0x3fbe00x4008a0d0x3fbe00x4008bb:0x3fbe00x4008b72:0xcffb

Rebooting...

I have ran this Backtrace in the Exception Decoder and I do not understand what is causing this. Here is the output of the decoder

Decoding 1 results
0x4008531a: _xt_user_exit at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/xtensa_vectors.S line 79

My code is really not complicated and I do not have much happening in the ISR from Blynk, the error happens when simply Idle (not even trying to send or receive info in Blynk app).

Here is the code being used (I added the Connected Timer and the Uptime Timer to help out debugging this issue, it was still happening before these existed):

#include "WiFi.h"
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
//#include <SimpleTimer.h>
#define BLYNK_PRINT Serial

int DoorbellInput = 0;
int DoorbellOutput = 19;

char auth[] = ****;

const char *SSID = *****;
const char *WiFiPassword = ****;
bool isFirstConnect = true;

const unsigned long debounceDelay = 100;
const unsigned long doorUnlockTime = 2500;
const unsigned long notificationDelay = 30000;
const unsigned long ledDelay = 50;
bool interruptON = false;
bool bellNotification = true;
bool doorState;
bool doorStateUpdated;

BlynkTimer timer;
int unlockTimer = 1;
int uptimeTimer = 2;
int connectionTimer = 3;

WidgetTerminal terminal(V1);
WidgetLED led1(V2);
WidgetRTC rtc;

BLYNK_WRITE(V1)
{
  if (String("clear") == param.asStr()) {
    terminal.clear();
  }
  else if (String("stop") == param.asStr()) {
    bellNotification = false;
    terminal.println("Stopped notifications Type resume to enable them");
  }
  else if (String("resume") == param.asStr()) {
    bellNotification = true;
    terminal.println("Enabled notifications. Type stop to disable them");
  }
  else if (String("help") == param.asStr()) {
    terminal.println("Here are the available commands:");
    terminal.println(">> clear: Clears the terminal");
    terminal.println(">> stop: Disables the push notification");
    terminal.println(">> resume: Enables the push notification");
  }
  else {
    terminal.println("Invalid command");
  }
  // Ensure everything is sent
  terminal.flush();
}

BLYNK_WRITE(V0)
{
  if(param.asInt())
  {
    doorState = true;
    Serial.println("Pressed");
  }
  else {
    doorState = false;
    Serial.println("Released");
  }
}

BLYNK_CONNECTED() {
  if(isFirstConnect)
  {
    // Synchronize time on connection
    rtc.begin();
    
    terminal.clear();  
    terminal.println(F("Blynk v" BLYNK_VERSION ": Doorbell Intercom Hack"));
    terminal.println(F("By Gabriel Gagnon"));
    terminal.println(F("-------------"));
    terminal.flush();
    isFirstConnect = false;
  }
  else
  {
    terminal.println("Connection was lost but is now restore");
    terminal.flush();
  }
}

bool Connected2Blynk = false;

void CheckConnection(){
  Connected2Blynk = Blynk.connected();
  if(!Connected2Blynk){
    Serial.println("Not connected to Blynk server"); 
    Blynk.connect(3333);  // timeout set to 10 seconds and then continue without Blynk  
  }
}
void setup() {
  Serial.begin(9600);
  // Clear the terminal content
  Blynk.begin(auth, SSID, WiFiPassword);

  pinMode(DoorbellInput, INPUT_PULLUP);
  pinMode(DoorbellOutput, INPUT);
  
  setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)
  uptimeTimer = timer.setInterval(1000*60, uptimeTick);
  connectionTimer = timer.setInterval(11000L, CheckConnection); // check if still connected every 11 seconds 
}

void loop() {
  if(Connected2Blynk)
  {
    Blynk.run();
    doorbellTask();
    unlockTask();
  }
  timer.run();
}

void unlockTask()
{
  static bool lastDoorState;
  if (doorState && !lastDoorState)
  {
    pinMode(DoorbellOutput, OUTPUT);
    unlockTimer = timer.setTimeout(1500,resetDoorUnlock);
    String unlockString = String(day()) + "/" + month() + "/" + year() + " "+ hour() + ":" + minute() + ":" + second() + " > Door Unlocked";
    terminal.println(unlockString);
    lastDoorState = true;
  }
  else if(!doorState && lastDoorState)
  {
    pinMode(DoorbellOutput, INPUT);
    timer.disable(unlockTimer);    
    String lockString = String(day()) + "/" + month() + "/" + year() + " "+ hour() + ":" + minute() + ":" + second() + " > Door Locked";
    terminal.println(lockString);
    if(timer.getNumTimers())
    {
      timer.deleteTimer(unlockTimer);
    }
    lastDoorState = false;
  }
  terminal.flush();

}

void doorbellTask()
{
  static bool last_doorbell_state = false;
  bool doorbell_state = digitalRead(DoorbellInput);
  if(doorbell_state != last_doorbell_state)
  { 
    if(!doorbell_state)
    {
      static unsigned long last_notification_time = 0;
      unsigned long notification_time = millis();
      if (notification_time - last_notification_time > notificationDelay)
      {
        if(bellNotification)
        {
          Blynk.notify("Someone is ringing!");
        }
        String doorbellString = String(day()) + "/" + month() + "/" + year() + " "+ hour() + ":" + minute() + ":" + second() + " > Doorbell rang";
        Serial.println(doorbellString);
        terminal.println(doorbellString);
        terminal.flush();
        last_notification_time = notification_time;
      }
    }
    static unsigned long last_led_time = 0;
    unsigned long led_time = millis();
    if (led_time - last_led_time > ledDelay)
    {
      if(!doorbell_state)
      {
        led1.on();
      }
      else
      {
        led1.off();
      }
      last_led_time = led_time;
    }
    last_doorbell_state = doorbell_state;
  }
}

void uptimeTick()
{
  String uptimeString = "Running for " + String(millis()/(1000.0*60.0)) + " minutes";
  terminal.println(uptimeString);
  Serial.println(uptimeString);
  terminal.flush();
}

void resetDoorUnlock()
{
  doorState = false;
  Serial.println("Door unlock timeout");
}

I would really appreciate help in debugging this. I saw people changing the board files to disable the WDT but I would prefer keeping the WDT active.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.