Audio Receiver: Watchdog Timeout | PCM5102a + ESP32
Posted: Sun Oct 26, 2025 12:00 pm
Hi everyone,
I’m trying to build a Bluetooth audio receiver that outputs a Bluetooth signal via AUX on the ESP32. Unfortunately, my ESP32 keeps crashing and I get the following error:
E (46579) task_wdt: Task watchdog got triggered. IDLE0 (CPU 0)
The issue seems related to a watchdog timeout. My code starts running, but ESP restarts as soon as i start playing music/sound. I suspect the audio processing is blocking the watchdog or consuming too much memory.
Here’s a snippet of my code (Arduino IDE):
#include <Arduino.h>
#include "BluetoothA2DPSink.h"
#define LED_PIN 15 // Status LED
/*
BCK 26
DIN 22
LCK 25
*/
BluetoothA2DPSink a2dp_sink;
// Stream callback: called when music data is received
void streamCallback(const uint8_t *data, uint32_t length) {
digitalWrite(LED_PIN, HIGH); // LED on when streaming
}
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
// Start Bluetooth A2DP sink
a2dp_sink.start("ESP32_Bluetooth");
// Set callback for incoming audio stream
a2dp_sink.set_stream_reader(streamCallback);
}
void loop() {
// If no audio for a while, turn off LED
static unsigned long lastTime = 0;
if (millis() - lastTime > 3000) { // 3 seconds timeout
digitalWrite(LED_PIN, LOW);
}
}
What I’ve already tried:
Extending the task watchdog timeout
Distributing tasks across both CPUs
Unfortunately, none of this worked.
I don't want to completely daectivate watchdog!?
My questions:
Has anyone encountered this issue and knows how to reliably fix it?
Are there best practices for Bluetooth audio on the ESP32 to avoid watchdog timeouts?
Thanks in advance for any help!
I’m trying to build a Bluetooth audio receiver that outputs a Bluetooth signal via AUX on the ESP32. Unfortunately, my ESP32 keeps crashing and I get the following error:
E (46579) task_wdt: Task watchdog got triggered. IDLE0 (CPU 0)
The issue seems related to a watchdog timeout. My code starts running, but ESP restarts as soon as i start playing music/sound. I suspect the audio processing is blocking the watchdog or consuming too much memory.
Here’s a snippet of my code (Arduino IDE):
#include <Arduino.h>
#include "BluetoothA2DPSink.h"
#define LED_PIN 15 // Status LED
/*
BCK 26
DIN 22
LCK 25
*/
BluetoothA2DPSink a2dp_sink;
// Stream callback: called when music data is received
void streamCallback(const uint8_t *data, uint32_t length) {
digitalWrite(LED_PIN, HIGH); // LED on when streaming
}
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
// Start Bluetooth A2DP sink
a2dp_sink.start("ESP32_Bluetooth");
// Set callback for incoming audio stream
a2dp_sink.set_stream_reader(streamCallback);
}
void loop() {
// If no audio for a while, turn off LED
static unsigned long lastTime = 0;
if (millis() - lastTime > 3000) { // 3 seconds timeout
digitalWrite(LED_PIN, LOW);
}
}
What I’ve already tried:
Extending the task watchdog timeout
Distributing tasks across both CPUs
Unfortunately, none of this worked.
I don't want to completely daectivate watchdog!?
My questions:
Has anyone encountered this issue and knows how to reliably fix it?
Are there best practices for Bluetooth audio on the ESP32 to avoid watchdog timeouts?
Thanks in advance for any help!