Need help with ESP32 Audio playback

I'm a total beginner in IoT. Infact this is my first project. I'm trying to build a digital clock using ESP32. It took me days to just setup a 7 segment display. But with great support from this community, I was finally able to setup the display and run a NTP clock on it. Now I want to go forward and play some audio. For ex., a sound effect when ESP is connected to WiFi, an alarm tone etc. But I'm having a really hard time to understand the basics of it.

I'm using PlatformIO in VSCode. I've tried many audio libraries but none them seems to work. While Xtronical is outdated, others are not available on PlatformIO. Espressif IDF & ADF are too overwhelming for a beginner like me.

Here's what I know so far:
Audio can be output in a different ways:

  1. Using internal 8-bit DACs
  2. Using external DACs for better quality
  3. Using PDM and PWM

While these details regarding what ESP32 can do are readily available on the internet, there isn't a single decent guide that shows how to implement them.

Here's what I want to achieve:

  1. Stores few basic tones in the ESP32 to play during certain trigger events, like when the device is connected to WiFi.
  2. Play songs from SDCard and/or USB.

Can someone spare some time to explain in detail how to do it? Or provide a link to a guide that explains it? I'd prefer the PDM/PWM approach because the 8-bit DAC quality is not suitable for songs and external DACs like MAX98357a are way too expensive in my region.

PS: Is it possible to salvage a DAC from any audio equipment that works with ESP32? If yes, what are they?

Why not just use DF mini MP3 Player?

  1. Does the DFMini MP3 Player module come with a built-in 16-bit DAC?
  2. I read there's some delay when playing from DFPlayer. So notification sounds must be played from internal Flash memory.

Nope. His DAC is 24 bit.

I do not know. I have never used this module. But I guess if there is a delay it will depend on the program, the speed of the memory card and probably the number of audio files. Even if there is an inevitable delay, if it is approximately constant, you will be able to predict it and start the audio file earlier - you will use it with a clock.

Where are the songs used? 8 bit is noiser than 16 or 24, obviously, but realize that a lot of legacy hardware like the Yamaha DX7 was 8 bit all the way and nobody complained about it back then.

So I'm currently trying to get PDM working on any 32-bit microcontroller that supports I2S as well. Currently for ESP32 tone functionality via PDM is supported.
Examples and library here. USB audio is not supported for ESP32 but is for ESP32-S2 and S3. However, I haven't got these to work yet.

However, as others have said, maybe a DFplayer is the best solution.

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