Skip to content

External DAC

Phil Schatzmann edited this page Mar 20, 2024 · 92 revisions

The best sound quality can be achieved with an external digital to analog converter. Here is a quick overview of the most popular I2S DAC breakout boards that can be found.

I2S Devices

I2S Pins

The default pins are defined for each microcontroller architecture in the AudioConfig.h.

The framework uses the following default pins for I2S for the ESP32:

  • PIN_I2S_BCK = 14
  • PIN_I2S_WS = 15
  • PIN_I2S_DATA_OUT = 22

Please double check the actual settings in AudioConfig.h for your Processor. There you can also modify the pins and other settings that will apply to all your sketches. You can also configure I2S in your individual sketch. The available settings are processor specific, so consult the documentation.

Recommendation: I recommend to to define the pins and other settings in your sketch!

  auto config = i2sStream.defaultConfig(TX_MODE);
  config.pin_bck = 14;
  config.pin_ws = 15;
  config.pin_data = 22;
  i2sStream.begin(config);

Use TX_MODE if you want to transmit (write) audio data from the processor to the external DAC. With RXTX_MODE you can receive and transmit at the same time if you have a audio codec chip that supports this function (see chapter Audio Boards). If you don't specify anything RXTX_MODE is used.

Pcm5102-Dac-Decoder

This DAC is very easy to use: Just connect the 3 I2S pins and the power and everything works as expected, w/o changing the configuration!

DAC ESP32 RP2040
BCK BCK (GPIO14) GPIO26
DATA OUT (GPIO22) GPIO28
WS WS (GPIO15) GPIO27
GND GND GND
GND GND GND
VDD 5V VBUS

I2S 3W Class D Amplifier Breakout - MAX98357A

This module provides an I2S DAC with a mono amplifier and you just need to connect a speaker.

  auto config = i2sStream.defaultConfig(TX_MODE);
  config.i2s_format = I2S_STD_FORMAT;
  i2sStream.begin(config);

DAC ESP32 RP2040
VIN 5V (or 3.3V) VBUS
GND GND GND
LRC WS (GPIO14) GPIO26
BCLK BCK (GPIO15) GPIO27
DIN OUT (GPIO22) GPIO28

Adafuit / I2S 3W Class D Amplifier Breakout - MAX98357A

It seems that most DACs from Adafruit have a different byte order then what the ESP32 expects and therefore you need to indicate the communication format as I2S_LSB:

  auto config = i2sStream.defaultConfig(TX_MODE);
  config.i2s_format = I2S_LSB_FORMAT;
  i2sStream.begin(config);

DAC ESP32 RP2040
VIN 5V (or 3.3V) VBUS
GND GND GND
LRC WS (GPIO14) GPIO26
BCLK BCK (GPIO15) GPIO27
DIN OUT (GPIO22) GPIO28

Adafuit / UDA1334A Breakout Board

It seems that most DACs from Adafruit have a different byte order then what the ESP32 expects and therefore you need to indicate the communication format as I2S_LSB:

  auto config = i2sStream.defaultConfig(TX_MODE);
  config.i2s_format = I2S_LSB_FORMAT;
  i2sStream.begin(config);

DAC ESP32 RP2040
VIN 5V VBUS
GND GND GND
WSEL WS (GPIO14) GPIO26
DIN OUT (GPIO22) GPIO28
BCLK BCK (GPIO15) GPIO27

24-bit PCM5102 PCM5102A Stereo DAC Digital-to-analog Converter PLL Voice Module pHAT

I was struggling quite a big to have this one working, because it needs some additional connections:

DAC ESP32 RP2040
VCC 5V VBUS
GND GND GND
BCK BCK GPIO14 GPIO26
DIN OUT GPIO22 GPIO28
LCK WS GPIO15 GPIO27
FMT GND GND
XMT 3V (**) 3V3
  • ** - or another GPIO PIN which is set to high
  • DMP - De-emphasis control for 44.1kHz sampling rate(1): Off (Low) / On (High)
  • FLT - Filter select : Normal latency (Low) / Low latency (High)
  • SCL - System clock input (probably SCL on your board).
  • FMT - Audio format selection : I2S (Low) / Left justified (High)
  • XMT - Soft mute control(1): Soft mute (Low) / soft un-mute (High)

HiLetgo PCM5102 I2S IIS Lossless Digital Audio DAC Decoder

This DAC is very easy to use: Just connect the 3 I2S pins and the power and everything works as expected, w/o changing the configuration! SCK to ground seems to reduce noise.

DAC ESP32 RP2040
SCK GND GND
BCK BCK (GPIO14) GPIO26
DIN OUT (GPIO22) GPIO27
LCK WS (GPIO15) GPIO28
GND GND GND
VIN 5V VBUS

Solder Bridges:

  • H1L: FLT - Filter select : Normal latency (Low) / Low latency (High)
  • H2L: DEMP - De-emphasis control for 44.1kHz sampling rate: Off (Low) / On (High)
  • H3L: XSMT - Soft mute control: Soft mute (Low) / soft un-mute (High)
  • H4L: FMT - Audio format selection : I2S (Low) / Left justified (High)

Normally it's working w/o any soldering! However if you encounter any issues I suggest that you try with FLT:Low, DEMP: Low, XSMT: High, FMT: Low

Audio Boards

See the next chapter

Clone this wiki locally