Skip to Content

TDA7379 Class AB Audio Amplifier with ESP32

TDA7379 Class AB Audio Amplifier with ESP32

The TDA7379 (or CD7379) is a class AB audio power amplifier designed for medium to high power sound applications. It is commonly used in car audio systems and compact amplifier modules.

The IC is capable of delivering up to around 2 × 38 W into 4 ohm speakers and integrates protection features such as thermal shutdown, short-circuit protection, and standby control.

In this tutorial you will learn how to use the TDA7379 to build a Internet radio, a Bluetooth and a MP3 player.

Required Parts

For this project we will need a PCM5102 DAC module, a TDA7379 Amplifier Board, an ESP32 and a pair of passive speakers.

You can use other speakers than the ones listed. Just make sure that their power rating is around 40 Watts or higher. You also will need a heatsink for the TDA7379!

As a microcontroller, I used an ESP32 lite but most other ESP32 boards will be fine as well. However, for best performance an ESP32-S3 board with PSRAM is recommended.

To play MP3 files from an SD Card you will furthermore need an SD Card and an SD Card reader module.

Finally, a breadboard and some cables will be handy for testing the circuit before soldering everything together.

TDA7379 Amplifier Module

PCM5102 DAC

2 x Speaker 8 Ohm 50 Watts

Heatsink 100x40x20mm

Micro SD Card Reader

Micro SD Card 8GB

ESP32 lite Lolin32

ESP32 lite

USB data cable

USB Data Cable

Dupont wire set

Dupont Wire Set

Half_breadboard56a

Breadboard

Makerguides is a participant in affiliate advertising programs designed to provide a means for sites to earn advertising fees by linking to Amazon, AliExpress, Elecrow, and other sites. As an Affiliate we may earn from qualifying purchases.

Technical Features of the TDA7379 Amplifier Module

A typical TDA7379 amplifier module is built around a the TDA7379 IC, which is a class AB audio amplifier. A frequent alternative is the CD7379 IC, which is pin compatible but cheaper. However, the TDA7379 may offer more consistent quality and better documentation. You will find both ICs in modules labelled “TDA7379 module”.

The typical TDA7379 module integrates all required external components for the IC such as coupling capacitors, bootstrap capacitors, and filtering elements. The picture below show the front and back of the TDA7379 Amplifier Module:

Front and Back of TDA7379 Amplifier Module
Front and Back of TDA7379 Amplifier Module

Note that some boards also integrate a small preamplifier stage based on a AD828 operational amplifier to boost weak audio signals before amplification. You can recognize these boards by the additional IC (marked in yellow):

TDA7379 Amplifier Module with AD828 pre-amplifier IC
TDA7379 Amplifier Module with AD828 pre-amplifier IC

The TDA7379 amplifier module is designed to operate from a DC supply in the range of 9 V to 15 V. The TDA7379 IC supports multiple output configurations. In quad-channel mode, the module can drive four independent speakers. But the TDA7379 module is pre-configured in bridge mode and delivers up to 2 × 38 W into 4 ohm speakers.

Audio Performance and Signal Handling

The module accepts low-level analog audio signals from sources such as DACs, microcontrollers, or audio players. The input stage includes coupling capacitors to block DC components and reduce noise.

The amplifier is designed to maintain low total harmonic distortion at nominal output levels. Typical designs target values around or below 1% THD at rated power.

Protection and Control Features

The TDA7379 includes several built-in protection mechanisms. Thermal shutdown protects the IC from overheating during high power operation. Short-circuit protection prevents damage when the output is accidentally connected to ground or supply voltage.

Pinout

The following picture shows the pinout of the TDA7379 Amplifier Module. The large IC at the top of the board is the TDA7379 IC.

Pinout of the TDA7379 Amplifier Module
Pinout of the TDA7379 Amplifier Module

Some modules come with connectors but the one I used only had solder pads. As mentioned before, you need to attach a heatsink to the TDA7379 IC! You can test it at low volume or for a very short time without a heatsink but the TDA7379 gets hot quickly.

Technical Specification

The following table summarizes the technical specification of the TDA7379 audio amplifier:

ParameterTypical Value
Amplifier TypeClass AB
Supply Voltage9 V to 15 V DC
Output Configuration2 bridge channels
Output Power (4 Ω, bridge)2 × 38 W
Load Impedance4 Ω to 8 Ω
Frequency Response20 Hz to 20 kHz
Total Harmonic Distortion0.1% to 1%
Quiescent Current< 100 mA
Control PinsStandby and Mute
Protection FeaturesThermal, short-circuit, overload
Package TypeMultiwatt (heatsink required)

For more detailed technical information see the datasheet for the TDA7379 linked below:

Architecture of the TDA7379 Audio System

The TDA7379 amplifier expects a line level audio input. You could generate this directly from the ESP32 using its internal digital-analog-converters (DACs). See the Playing Sound with PAM8403 and ESP32 tutorial. But the audio quality would not be very good due to the low resolution (8 bits) of the internal DAC.

We therefore use the PCM5102 as an external DAC that has a much higher resolution. For details about the PCM5102 see the Playing Audio with ESP32 and PCM5102A tutorial. The picture below shows the architecture of our audio system with the ESP32 microcontroller, the PCM5102 DAC and the TDA7379 amplifier:

Architecture of the TDA7379 Audio System
Architecture of the TDA7379 Audio System

The ESP32 generates a digital audio signal and transmits it via the I2S protocol digitally to the PCM5102 DAC. The PCM5102 converts the digital audio into a line level, analog signal for the left and right channel. The TDA7379 amplifies the analog signal to drive two speakers with up to 38 Watts.

Connecting the TDA7379 with PCM5102 and ESP32

In this section we are connecting the TDA7379 Amplifier to an PCM5102 DAC and the ESP32 microcontroller. The PCM5102 converts a digital audio to an analog audio signal that then can be fed into the TDA7379 Amplifier. The picture below shows the complete wiring diagram:

Connecting TDA7379 to PCM5102 and ESP32
Connecting TDA7379 to PCM5102 and ESP32

We start by connecting the ESP32 to the PCM5102 via the I2S interface. You could configure different pins (see the code in later sections) but here I am using LCK=32, BCK=25 and DIN=33. The following table shows the complete connections between the ESP32 and the PCM5102 :

PCM5102A ESP32
VIN3V3
GNDG
LRCK32
BCK25
DIN33
SCKG

If you have soldered the SCK bridge on the PCM5102 you actually won’t need the SCK to ground connection but it doesn’t do any harm. I strongly recommend that you read the Playing Audio with ESP32 and PCM5102A tutorial, if you haven’t configured or used the PCM5102 before. There are other bridges that need to be soldered to ensure that the PCM5102 works correctly!

Next we connect the TDA7379 Amplifier via line out to the PCM5102. The following table shows the connections you need to make:

TDA7379PCM5102
LLROUT
GNDAGND
RROUT

Note that the labelling of the pins of the PCM5102 board is a bit confusing. The left channel output on the PCM5102 should be labelled “ROUT” but actually reads “LROUT”.

Finally, you need to connect a DC power supply that can deliver between 9V up to 15V and 3A to the VCC pins (+,-). You cannot power the TDA7379 from the ESP32 3.3V or 5V pin!

Polarity of Speakers

The right and left loudspeakers are connected to the R+, R-, L+ and L- pins of the TDA7379.

Connecting speakers to TDA7379

Make sure that you match the polarity of the output pins with the polarity of the speaker pins. Typically the speaker pins are marked with “+” and “-” signs or have differently shaped pins (thinner for minus).

If there are no markings, you can connect a 1.5V AA battery and if the membrane moves outwards, the plus pole of the battery indicates the plus pole of the speaker. Loudspeaker polarity is defined so that a positive voltage produces forward cone motion.

Connecting SD Card Reader

If you want to play MP3 files you need to connect an SD Card reader that stores the audio files on an SD Card. The wiring diagram below shows you how to connect an additional SD Card reader:

Connecting TDA7379 to PCM5102 and ESP32 with SD Card Reader
Connecting TDA7379 to PCM5102 and ESP32 with SD Card Reader

The SD Card Reader communicates via SPI and the default SPI pins of the ESP32 for SPI are CS=5, MOSI=23, CLK=18 and MISO=19. The table below summarizes the connections you need to make between the SD Card Reader and the ESP32:

SD Card ReaderESP32
3V33V
GNDG
CS/SS5
MOSI23
CLK/SCK18
MISO19

If you are not sure which pins are the default SPI pins of your ESP32 have a look at the Find I2C and SPI default pins tutorial. And for more information on the SD Card Reader see the SD Card Module with ESP32 tutorial.

Installing Libraries

We are going to use arduino-audio-tools library by Phil Schatzmann to build our Internet, Bluetooth and MP3 player. To install this library go to the arduino-audio-tools repo, click on the green “<> Code” button and then “Download ZIP” to download the library as a ZIP file as shown below:

Then open a Sketch, go to Sketch -> Include Library -> Add .ZIP Library … to install the downloaded ZIP library (arduino-audio-tools-main.zip):

For some of the code examples we need two more libraries by Phil Schatzmann; namely the arduino-libhelix library and the ESP32-A2DP library. You can install them in the same way. Click on the link to go to the github repo, click on the green “<> Code” button to download the libraries (arduino-libhelix-main.zip, ESP32-A2DP-main.zip) and then install them.

Finally, if this is the first time you program an ESP32 board from your Arduino IDE, you will need to install the ESP32 core as well. For details see the Install ESP32 core in Arduino IDE tutorial.

In the next three sections I will show you the code to build a Bluetooth Player, an Internet Radio and a MP3 Player using the arduino-tools-library.

Code for a Bluetooth Player

This first code example configures an ESP32 to operate as a Bluetooth A2DP audio sink that receives stereo audio streams from a paired device such as a smartphone and outputs the digital audio data via the I2S peripheral.

/*
www.makerguides.com

Libraries:
- ESP32 Core 3.3.7
- [arduino-audio-tools](https://github.com/pschatzmann/arduino-audio-tools) 
  Version: 1.2.2
- [arduino-libhelix](https://github.com/pschatzmann/arduino-libhelix)
  Version: 0.9.2
- [ESP32-A2DP](https://github.com/pschatzmann/ESP32-A2DP)
  Version: 1.8.8
*/

#include "AudioTools.h"
#include "BluetoothA2DPSink.h"

#define DIN_PIN 33   // serial data
#define LRCK_PIN 32  // word select
#define BCLK_PIN 25  // serial clock

I2SStream i2s;
BluetoothA2DPSink a2dp_sink(i2s);

void setup() {
  auto config = i2s.defaultConfig();
  config.pin_bck = BCLK_PIN;
  config.pin_ws = LRCK_PIN;
  config.pin_data = DIN_PIN;  
  i2s.begin(config);

  a2dp_sink.start("MyMusic");
}

void loop() { }

The code initializes an I2SStream interface with the assigned bit clock, word select, and serial data pins, which are connected to a PCM5102 digital-to-analog converter. The PCM5102 converts the incoming I2S digital audio signal into an analog stereo signal, which is then amplified by the TPA3110-based XH-A232 amplifier module to drive two connected speakers.

During setup, the ESP32 initializes the I2S driver with the specified pin configuration and starts the Bluetooth A2DP sink with the device name “MyMusic”, making the ESP32 discoverable as a Bluetooth audio receiver.

Once paired and connected, audio streamed over Bluetooth is routed directly through the I2S interface to the DAC and subsequently amplified for playback. The main loop remains empty because audio handling and Bluetooth communication are managed internally by the underlying libraries and run asynchronously in the background.

Code for an Internet Radio

This code example uses an ESP32 as a Wi-Fi internet radio receiver that streams an online MP3 audio feed, decodes it in real time, and again outputs the audio signal via I2S to the PCM5102A DAC. The analog signal generated by the DAC is then amplified by the TDA7379 to drive the connected speakers.

/*
www.makerguides.com

Libraries:
- ESP32 Core 3.3.7
- [arduino-audio-tools](https://github.com/pschatzmann/arduino-audio-tools) 
  Version: 1.2.2
- [arduino-libhelix](https://github.com/pschatzmann/arduino-libhelix)
  Version: 0.9.2
*/

#include <Arduino.h>
#include <WiFi.h>
#include <Wire.h>
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
#include "AudioTools/Communication/HTTP/ICYStream.h"

// PCM5102A
#define DIN_PIN 33   // serial data
#define LRCK_PIN 32  // word select
#define BCLK_PIN 25  // serial clock
#define VOLUME 0.3   // Volume [0,1]

const char* ssid = "ssid";
const char* password = "pwd";
const char* url = "https://jazz.stream.laut.fm/jazz";

ICYStream icystream;
I2SStream i2s;
VolumeStream volume(i2s);
EncodedAudioStream mp3decode(&volume, new MP3DecoderHelix());
StreamCopy copier(mp3decode, icystream);

void callbackMetadata(MetaDataType type, const char* str, int len) {
  Serial.printf("%s: %s\n", toStr(type), str);
}

void setup() {
  Serial.begin(115200);
  AudioLogger::instance().begin(Serial, AudioLogger::Warning);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }

  auto config = i2s.defaultConfig(TX_MODE);
  config.pin_bck = BCLK_PIN;
  config.pin_ws = LRCK_PIN;
  config.pin_data = DIN_PIN;

  i2s.begin(config);
  volume.begin(config);
  volume.setVolume(VOLUME);
  mp3decode.begin();
  icystream.begin(url);
  icystream.setMetadataCallback(callbackMetadata);
}

void loop() {
  copier.copy();
}

During setup, the ESP32 connects to a specified Wi-Fi network using the provided SSID and password. You will need to replace the strings “ssid” and “pwd” with the credentials of your Wi-Fi network.

Once the wireless connection is established, the code initializes the I2S peripheral in transmit mode and assigns the bit clock, word select, and serial data pins to match the PCM5102A hardware interface. A VolumeStream object is layered on top of the I2S stream to apply digital volume scaling before the audio data is sent to the DAC.

The program opens an HTTP connection to the specified streaming URL using an ICYStream, which supports ICY metadata commonly used by internet radio stations. The incoming MP3-encoded audio data is passed to an EncodedAudioStream configured with the Helix MP3 decoder, which performs real-time decoding of the compressed audio frames into raw PCM samples. These decoded samples are then forwarded through the volume control stage and ultimately transmitted over I2S to the DAC.

A metadata callback function is registered to receive and print stream metadata such as the current track title to the serial monitor. In the main loop, the StreamCopy object continuously transfers data from the network stream through the decoder and audio processing chain, ensuring uninterrupted playback as long as the stream remains available.

In the following a list of URLs for some other internet radio stations you can try out:

"https://jazz.stream.laut.fm/jazz"
"http://vis.media-ice.musicradio.com/CapitalMP3";
"http://stream.srg-ssr.ch/m/rsj/mp3_128"
"http://stream.live.vc.bbcmedia.co.uk/bbc_world_service"
"http://icecast.omroep.nl/radio1-bb-mp3"
"http://stream-02-eu.relaxingjazz.com/stream/1/"

Adding a Volume Control Knob

It would be nice to have a volume knob to control the loudness of the radio. We can do this easily by adding a potentiometer to the circuit. The picture below shows you the wiring:

Connecting Potentiometer as Volume controller to ESP32
Connecting Potentiometer as Volume controller to ESP32

Connect pin 3 to 3V, pin 1 to Ground the the middle pin, the swiper of the potentiometer to GPIO 35 of the ESP32. For convenience below a table with the required connections:

Potentiometer ESP32
1G
235
33V

Before I show you the extended code, you will need to install the TickTwo library. Just open the LIBRARY MANAGER, type “TickTwo” in the search bar, and click on the INSTALL button for the “TickTwo by Stefan Staub” library:

And here is the code for the internet radio with volume control. It is largely the same code as before. New is the updateVolume() function that is called every 100msec, which updates the volume based on the potentiometer position:

/*
www.makerguides.com

Libraries:
- ESP32 Core 3.3.6
- [arduino-audio-tools](https://github.com/pschatzmann/arduino-audio-tools) 
  Version: 1.2.2
- [arduino-libhelix](https://github.com/pschatzmann/arduino-libhelix)
  Version: 0.9.2
- [TickTwo](https://github.com/sstaub/TickTwo)
  Version: 4.4.0  
*/

#include <Arduino.h>
#include <WiFi.h>
#include <Wire.h>
#include "TickTwo.h"
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
#include "AudioTools/Communication/HTTP/ICYStream.h"

#define DIN_PIN 33   // serial data
#define LRCK_PIN 32  // word select
#define BCLK_PIN 25  // serial clock
#define POT_PIN 35   // Poti for Volume

const char* ssid = "ssid";
const char* password = "pwd";
const char* url = "https://jazz.stream.laut.fm/jazz";

ICYStream icystream;
I2SStream i2s;
VolumeStream volume(i2s);
EncodedAudioStream mp3decode(&volume, new MP3DecoderHelix());
StreamCopy copier(mp3decode, icystream);

void callbackMetadata(MetaDataType type, const char* str, int len) {
  Serial.printf("%s: %s\n", toStr(type), str);
}

void updateVolume() {
  static float oldVol = -1;
  long pot = analogRead(POT_PIN);
  float vol = map(pot, 0, 4095, 0, 100) / 100.0;

  if (fabs(vol - oldVol) >= 0.02) {
    oldVol = vol;
    volume.setVolume(vol);
  }
}

TickTwo timer(updateVolume, 100);

void setup() {
  Serial.begin(115200);
  AudioLogger::instance().begin(Serial, AudioLogger::Warning);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }

  auto config = i2s.defaultConfig(TX_MODE);
  config.pin_bck = BCLK_PIN;
  config.pin_ws = LRCK_PIN;
  config.pin_data = DIN_PIN;

  i2s.begin(config);
  volume.begin(config);
  volume.setVolume(0.1);
  mp3decode.begin();
  icystream.begin(url);
  icystream.setMetadataCallback(callbackMetadata);

  pinMode(POT_PIN, INPUT);  
  timer.start();  
}

void loop() {
  timer.update();
  copier.copy();
}

If you want to add a button to switch between stations, for instance, have a look at the next code example.

Code for an MP3 Player

This last program uses the ESP32 as a standalone MP3 audio player that reads audio files from an SD card, decodes them in real time, and outputs the resulting PCM signal via the I2S interface to the PCM5102A DAC. The analog output of the DAC is then amplified by the TDA7379 and send to the speakers.

/*
www.makerguides.com

Libraries:
- ESP32 Core 3.3.7
- [arduino-audio-tools](https://github.com/pschatzmann/arduino-audio-tools) 
  Version: 1.2.2
- [arduino-libhelix](https://github.com/pschatzmann/arduino-libhelix)
  Version: 0.9.2
*/

#include "AudioTools.h"
#include "AudioTools/Disk/AudioSourceSD.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"

// PCM5102A
#define DIN_PIN 33   // serial data
#define LRCK_PIN 32  // word select
#define BCLK_PIN 25  // serial clock
#define VOLUME 0.5   // Volume

#define PATH "/"
#define EXT "mp3"

AudioSourceSD source(PATH, EXT);
I2SStream i2s;
MP3DecoderHelix decoder;
AudioPlayer player(source, i2s, decoder);

void printMetaData(MetaDataType type, const char* str, int len){
  Serial.printf("%s: %s\n", toStr(type), str);
}

void setup() {
  Serial.begin(115200);
  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);

  auto config = i2s.defaultConfig(TX_MODE);
  config.pin_bck = BCLK_PIN;
  config.pin_ws = LRCK_PIN;
  config.pin_data = DIN_PIN;  
  i2s.begin(config);

  player.setMetadataCallback(printMetaData);
  player.setVolume(VOLUME);
  player.begin();
}

void loop() {
  player.copy();
}

An AudioSourceSD object is initialized to access MP3 files stored on the SD card in the root directory. The source is configured to select files with the “mp3” extension, allowing the system to iterate through compatible audio files available on the card. The AudioPlayer object combines the SD card source, an I2S output stream, and the Helix MP3 decoder into a single playback pipeline.

During setup, the ESP32 initializes serial communication for debugging and configures the I2S peripheral in transmit mode with explicitly assigned bit clock, word select, and serial data pins connected to the PCM5102A. The audio player is configured with a metadata callback function to print information such as track title or artist to the serial monitor when available. A digital volume level is also set before playback begins.

In the main loop, the player.copy() function continuously processes the audio stream. The player reads MP3 data from the SD card, decodes it using the Helix decoder into raw PCM samples, and sends the processed audio through the I2S interface to the DAC for playback. This loop-driven streaming mechanism ensures continuous audio output as long as valid MP3 files are available on the SD card.

Adding Next Button and Volume Control Knob

A typical MP3 player has functions to control the volume and which tracks are played, for instance. We can easily add this functionality. The wiring diagram below shows you how to add a potentiometer as a volume controller and a button to skip to the next track:

Connecting Potentiometer and Button to ESP32
Connecting Potentiometer and Button to ESP32

The following table list the connections you need to make. When connecting the button make sure that you connect the right poles.

Potentiometer ButtonESP32
14
12G
235
33V

We will use the EasyButton library to read the button status. To install it open the LIBRARY MANAGER, search for the “EasyButton by Evert Arias” library and press INSTALL:

The code below is the code for the MP3 player with the added functions updateVolume() and onNextTrack(), which are used to control the volume and skip to the next track:

/*
www.makerguides.com

Libraries:
- ESP32 Core 3.3.7
- [arduino-audio-tools](https://github.com/pschatzmann/arduino-audio-tools) 
  Version: 1.2.2
- [arduino-libhelix](https://github.com/pschatzmann/arduino-libhelix)
  Version: 0.9.2
- [TickTwo](https://github.com/sstaub/TickTwo)
  Version: 4.4.0    
- [EasyButton](https://github.com/evert-arias/EasyButton)
  Version: 2.0.3      
*/

#include "TickTwo.h"
#include "EasyButton.h"
#include "AudioTools.h"
#include "AudioTools/Disk/AudioSourceSD.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"

#define DIN_PIN 33   // serial data
#define LRCK_PIN 32  // word select
#define BCLK_PIN 25  // serial clock
#define POT_PIN 35   // Poti for Volume

#define PATH "/"
#define EXT "mp3"

EasyButton nextBtn(4);

AudioSourceSD source(PATH, EXT);
I2SStream i2s;
MP3DecoderHelix decoder;
AudioPlayer player(source, i2s, decoder);

void printMetaData(MetaDataType type, const char* str, int len) {
  Serial.printf("%s: %s\n", toStr(type), str);
}

void updateVolume() {
  static float oldVol = -1;
  long pot = analogRead(POT_PIN);
  float vol = map(pot, 0, 4095, 0, 100) / 100.0;

  if (fabs(vol - oldVol) >= 0.02) {
    oldVol = vol;
    player.setVolume(vol);
  }
}

void onNextTrack() {
  Serial.println("Next track");
  player.next();
}


TickTwo timer(updateVolume, 100);

void setup() {
  Serial.begin(115200);
  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);

  auto config = i2s.defaultConfig(TX_MODE);
  config.pin_bck = BCLK_PIN;
  config.pin_ws = LRCK_PIN;
  config.pin_data = DIN_PIN;
  i2s.begin(config);

  player.setMetadataCallback(printMetaData);
  player.setVolume(0.1);
  player.begin();

  pinMode(POT_PIN, INPUT);
  timer.start();

  nextBtn.begin();
  nextBtn.onPressed(onNextTrack);
}

void loop() {
  timer.update();
  nextBtn.read();
  player.copy();
}

You could easily add additional buttons in the same way for a previous track and pause function, for instance. However the wiring gets quite complex at this stage and you are better off soldering the connections. The photo below shows my wiring on a breadboard with just one button and the potentiometer:

TDA7379 Class AB Audio Amplifier with ESP32

Conclusions

In this project, I showed you how to play audio with an ESP32 and the TDA7379 amplifier. Remember that TDA7379 is a Class AB amplifier and requires a heatsink! However, the advantage of the Class AB type is that the sound quality is really good.

You learned how to stream internet radio, play MP3 files from an SD Card and play audio via Bluetooth. For more code examples see the examples folder of the arduino-tools-library.

If you want to add more functionality such as a volume controller and buttons to skip tracks, see our Playing Audio with ESP32 and PCM5102A tutorial. Similarly, if you need more background on the SD Card Reader module used here, have a look at the SD Card Module with ESP32 tutorial.

For other amplifiers with different speaker output wattages and power supply requirements see the following tutorials:

TutorialOutput WattagePower Supply
TDA7379 Class AB Audio Amplifier with ESP322 × 38 W9 .. 15 V
High-Power ESP32 Audio with TPA3116D2 and PCM51022 x 50 W4.5 .. 26 V
Audio with PAM8403, PCM5102 and ESP322 x 3 W2.5 .. 5.5 V
Stereo Amplifier with TPA31110 XH-A232, PCM5102 and ESP322 x 30 W8 .. 26 V
Playing Audio with ESP32 and MAX983571 x 3 W3.3 .. 5V
Playing Audio with ESP32 and PCM5102Aline level3.3 .. 5 V
Playing Sound with PAM8403 and ESP322 x 3 W2.5 .. 5.5 V
Audio with YDA138-E Amplifier, PCM5102 and ESP322 x 20 W9 .. 13.5 V

Feel free to leave any questions in the comment section.

Happy Tinkering ; )