Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Jason Bassett
#90241 Hello

I have an ESP32 linked up to 1 button and an Adafruit PAM8301 audio amplifier. I have tested the playback of .wav files without any deep sleep code, all worked fine. I have now adapted my code to put the ESP32 into deep sleep and to wake up upon button press. Upon wake up, audio should play and then it should go back into a deep sleep until the next button press. It is waking up fine each time and sleeping again, but the audio is not playing. Any ideas? Thank you.

Here is my code:

#include "potatoe.h"
#include "XT_DAC_Audio.h"
RTC_DATA_ATTR XT_Wav_Class Potatoe(potatoe);
RTC_DATA_ATTR XT_DAC_Audio_Class DacAudio(25,0);

void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;

wakeup_reason = esp_sleep_get_wakeup_cause();

case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); play_audio(); break;
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;

void setup() {

//Print the wakeup reason for ESP32

esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1);

void loop() {
// Nothing to do here

void play_audio() {
Serial.println("Playing audio");