-
-
Notifications
You must be signed in to change notification settings - Fork 346
External DAC
The best sound quality can be achieved with an external DAC. Here is a quick overview of the most popular breakout boards that can be found. The framework uses the following default pins:
- bck_io_num = 26
- ws_io_num = 25
- data_out_num = 22
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 |
|---|---|
| BCK | BCK (GPIO26) |
| DATA | OUT (GPIO22) |
| WS | WS (GPIO25) |
| GND | GND |
| GND | GND |
| VDD | 5V |
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_COMM_FORMAT_I2S_LSB:
static const i2s_config_t i2s_config = {
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX),
.sample_rate = 41000,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB),
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = false
};
a2dp_sink.set_i2s_config(i2s_config);
| DAC | ESP32 |
|---|---|
| VIN | 5V |
| GND | GND |
| WSEL | WS (GPIO25) |
| DIN | OUT (GPIO22) |
| BCLK | BCK (GPIO26) |
I was struggling quite a big to have this one working, because it needs some additional connections:
| DAC | ESP32 |
|---|---|
| VDD | 5V |
| GND | GND |
| SD | OUT (GPIO22) |
| L/R | GND |
| WS | WS (GPIO25) |
| SCK | BCK (GPIO26) |
| FMT | GND |
| XSMT | 3V (or another GPIO PIN which is set to high) |
- DEMP - De-emphasis control for 44.1kHz sampling rate(1): Off (Low) / On (High)
- FLT - Filter select : Normal latency (Low) / Low latency (High)
- SCK - System clock input (probably SCL on your board).
- FMT - Audio format selection : I2S (Low) / Left justified (High)
- XSMT - Soft mute control(1): Soft mute (Low) / soft un-mute (High)
This is an often seen module on amazon and bangood
| DAC | ESP32 |
|---|---|
| SCK | GND |
| BCK | 26 |
| DIN | 22 |
| LCK | 25 |
| GND | GND |
| VIN | 3.3 |
There are some rare high end DACs which only support 32 bit data! The logic has been extended so that you can indicate 32 bit in the i2s_config.
static const i2s_config_t i2s_config = {
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX),
.sample_rate = 44100, // corrected by info from bluetooth
.bits_per_sample = (i2s_bits_per_sample_t) 32, /* the A2DP 16 bits will be expanded to 32 bits */
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = false
};
a2dp_sink.set_i2s_config(i2s_config);


