-->
Page 1 of 1

DacAudio ESP32 not working when wake from deepsleep

PostPosted: Sat Jan 16, 2021 6:53 pm
by Jason Bassett
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:

<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();

switch(wakeup_reason)
{
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() {
Serial.begin(115200);
delay(1000);
Serial.println("Booted...");

//Print the wakeup reason for ESP32
print_wakeup_reason();

esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1);
esp_deep_sleep_start();
}

void loop() {
// Nothing to do here
}

void play_audio() {
DacAudio.FillBuffer();
DacAudio.Play(&Potatoe);
Serial.println("Playing audio");
delay(10000);
}
</code>

Re: DacAudio ESP32 not working when wake from deepsleep

PostPosted: Tue Feb 16, 2021 12:31 pm
by eriksl
Arduino based questions is not what this subforum is for. Moved the post.