ESP32 dimmer works for 30 seconds then crashes — Guru Meditation Error

Hello, I have a problem with my ESP32 and the AC dimmer module.

The setup works perfectly for about 30 seconds after boot — the lamp dims smoothly and I can control it over WiFi. But then the ESP32 crashes and reboots. Every single time, always around 30 seconds.

The serial monitor shows this error:

Guru Meditation Error: Core 0 panic'ed (Cache disabled but cache memory region accessed)

Here is my code:

#include <WiFi.h>
#include <RBDdimmer.h>

#define outputPin 25
#define zerocross 26

dimmerLamp dimmer(outputPin, zerocross);

const char* ssid = "MyNetwork";
const char* password = "MyPassword";

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  Serial.println("WiFi connected");
  dimmer.begin(NORMAL_MODE, ON);
}

void loop() {
  dimmer.setPower(50);
  delay(100);
}

If I comment out the WiFi.begin() line the dimmer works indefinitely with no crash. So the problem is clearly related to WiFi being active together with the dimmer.

I am using:

  • ESP32 DevKit v1 (dual core)
  • RBDdimmer library (latest from Library Manager)
  • Arduino IDE 2.3.2
  • rbdimmer 1CH 4A module

It makes no sense for me why WiFi would cause the dimmer to crash. Any ideas?

Pretty sure this is a pin conflict issue. The ESP32 WiFi uses some GPIOs internally and if your ZC or DIM pin overlaps with one of those it can cause weird crashes.

Try moving your ZC pin to GPIO 4 or GPIO 13 — those are usually safe from WiFi conflicts. IIRC GPIO 26 might be used by the ADC2 which gets disabled when WiFi is active.

AFAIK the Guru Meditation errors on ESP32 are almost always pin-related.

Root cause: this is not a pin conflict. It’s an IRAM issue.

The RBDdimmer library (the Arduino/AVR version) was not designed for ESP32. Its interrupt service routines are stored in flash memory, not in IRAM.

Here’s what happens:

  1. ESP32 WiFi stack runs on Core 0
  2. WiFi periodically disables the flash cache to perform SPI flash operations (storing credentials, OTA, etc.)
  3. During that brief window, if a zero-cross interrupt fires, the CPU tries to execute the ISR from flash
  4. Flash is inaccessible → Cache disabled but cache memory region accessed → Guru Meditation → crash

This is why it works without WiFi — without WiFi the flash cache is never disabled, so the ISR always executes fine. The ~30 second delay is how long it takes for the WiFi stack to trigger its first cache-disabling operation.

The fix is not changing pins. The fix is switching to the correct library.

Replace RBDdimmer with rbdimmerESP32:

  1. Install via Library Manager: search rbdimmerESP32
  2. Change your include:
// OLD (crashes with WiFi):
// #include <RBDdimmer.h>

// NEW (IRAM_ATTR on all ISRs):
#include <rbdimmerESP32.h>
  1. The API is slightly different — check the examples bundled with the library

The rbdimmerESP32 library has IRAM_ATTR on all interrupt handlers, which places them in internal RAM instead of flash. This means the ISR is always accessible regardless of cache state.

See: GitHub - robotdyn-dimmer/rbdimmerESP32: Universal AC Dimmer Library for ESP32 (Arduino and ESP-IDF) · GitHub

Ah good point, I stand corrected. The IRAM thing makes way more sense — I was thinking of a different issue I had with ADC2 pins.

TIL that the flash cache gets disabled during WiFi operations. That explains a lot of mysterious ESP32 crashes I’ve seen in other projects too.

Thank you Kai and rbdimmer team — the IRAM explanation makes perfect sense now. I was going crazy trying different pins and delays thinking it was a timing issue.

I installed rbdimmerESP32 from Library Manager and updated my code. The constructor is a bit different but the examples in the library made it easy to adapt.

Running now for over 2 hours with WiFi active — zero crashes. The Guru Meditation error is completely gone.

[SOLVED] UPDATE: I have been running the new library for 3 days now with WiFi and MQTT both active — rock solid, no crashes at all.

For anyone finding this thread later, here is the summary:

Problem: ESP32 + RBDdimmer library + WiFi = Guru Meditation crash after ~30 seconds

Root cause: RBDdimmer ISR functions are in flash memory, not IRAM. When WiFi disables the flash cache the ISR becomes inaccessible → crash.

Solution: Replace RBDdimmer with rbdimmerESP32 library:

  • Library Manager: search rbdimmerESP32
  • Change include to #include <rbdimmerESP32.h>
  • Check example sketches for the updated API

Thank you to esp_vet for the precise diagnosis and rbdimmer support for the migration guide. And Felix — no worries, the ADC2 thing is actually good to know about too.