Hi guys,
I’m looking for an sample configuration using the new esphome I2S Media Player with internal DAC. Does anyone have the pinouts and wiring required?
Thanks
Hi guys,
I’m looking for an sample configuration using the new esphome I2S Media Player with internal DAC. Does anyone have the pinouts and wiring required?
Thanks
for the “classic” esp32
DAC1 (GPIO25)
DAC2 (GPIO26)
as written on: ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials
-snip-
media_player:
- platform: i2s_audio
name: ESPHome I2S Media Player
dac_type: internal
mode: stereo
output:
- platform: esp32_dac
pin: GPIO26
id: left
- platform: esp32_dac
pin: GPIO25
id: right
Working - BUT the 8 bit DACs are very noisy
Thank you.
Thats really helpful
I need a bit of help. I want to the below but with ESPHome, any idea what I would need to add so it will work? The thing is instead of compiling the wav file I just want to play a media file. I connected the speaker but all i get is a little static.
I added this to the yaml, so I just want to know what to do
media_player:
- platform: i2s_audio
name: ESPHome I2S Media Player
dac_type: internal
mode: stereo
output:
- platform: esp32_dac
pin: GPIO25
id: right
Hi, you can leave out the output, the media_player works for internal dac_type without it.
The only thing is that it makes a lot of crackling noise. I tested it on multiple esp32’s. When I use an external I2S DAC there is no noise.
Anybody have the same issues with the internal DAC?
I have the same problem as yours… Static sound, but using the external dac (UDA1334ATS) on the sound board.
Have you found a solution to it ?
I am trying to use the SPK2 HAT, which should be able to leverage the I2S internal DAC (Speaker is GPIO26)
However attempts to setup the output of the DAC results in an error for being ambiguous.
i2s_audio:
# Audio for Speaker
- id: spk_adc
i2s_lrclk_pin: GPIO0
media_player:
- platform: i2s_audio
id: media_out
name: ${device_friendly_name}
i2s_audio_id: spk_adc
dac_type: internal
mode: stereo
output:
# Digital to Analog Convertor --- Used because SPK2 HAT is directly connected to the speaker wire
- platform: esp32_dac
pin: GPIO26
id: right
If I comment out the esp32_dac the code compiles but I am unable to get audio from the speaker. This is very odd because the speaker works using the external DAC. I am going to see if I can get the microphone and speaker to leverage the same i2s_lrclk_pin successfully as an alternative.
I know this is a one and a half year old topic, but I have a LM386 myself as well. Did you get any sound out of this? Can you post your complete configuration?
Can you provide more example?
I’m using:
i2s_audio:
i2s_lrclk_pin: GPIO22
i2s_bclk_pin: GPIO23
media_player:
- platform: i2s_audio
name: ESPHome I2S Media Player
dac_type: internal
mode: stereo
And connect GND/gpio25 to headphone jack,
But there is no sound when playing any wav file.
Not sure what is wrong.
Hey guys, this is my project using UDA1334:
Did you guys ever managed to ger rid of popping before audio played?
Issue is described here:
But I cant figure out how to set constant bitrate over ESPHome.
Its not too annoying, however would be great to solve it.
Created bug report:
Your help is much appreciated.
Hi,
For all those who ran into the issue with std::ios_base& std::right(std::ios_base&)
or std::ios_base& std::left(std::ios_base&)
respectively, this can be avoided by assigning your DAC outputs different IDs, e.g. id: rdac
instead of id: right
.
I suspect that if vv_rockhound’s snippet ever produced the promised outcome, the framework or conflicting source code has since changed.
Unfortunately, resolving this compiler error did not lead to successfully outputting sound using i2s and internal DAC using either the speaker or the media_player component (while using an external DAC did work both ways). Instead, only crackling is emmited for a fraction of a second.
Any help is appreciated…
Hmm - ESP32 have only two DAC outputs and
dac_type: internal
mode: stereo
needs both of them for i2s audio.
Looking at ESP32 DAC — ESPHome, it seems that
output:
- platform: esp32_dac
pin: GPIO26
id: left
- platform: esp32_dac
pin: GPIO25
id: right
serves the purpose of outputting more or less static analog voltages instead of sound using the same HW resources and thereby conflicting with the above. It is a shame, this is not caught upon compilng.
I will try rebuilding without the DAC pins in the output section.
OK. I finally got sound out of the ESP32s internal DACs using the media_player component. The quality is somewhat lame but I had low expectations anyway.
I believe the crackling improved when I attempted to separate the microphone i2s from the speaker i2s:
i2s_audio:
- id: i2sout
i2s_lrclk_pin: GPIO0 # internal DAC supports only I2S0; LRCLK is mandatory
- id: i2sin
i2s_lrclk_pin: GPIO23 #INMP441 WS
i2s_bclk_pin: GPIO21 #INMP441 SCK
microphone:
- platform: i2s_audio
id: mic
i2s_din_pin: GPIO22 #INMP441 SD
adc_type: external
pdm: false
channel: right # L/R pin pulled low
bits_per_sample: 32bit
#use_apll: true
i2s_audio_id: i2sin
media_player:
- platform: i2s_audio
dac_type: internal
mode: stereo
id: mp
i2s_audio_id: i2sout
But I might be wrong. Sound pops upon starting and stopping playback.
Playback stutters extremely while streaming from the microphone.
I can only play media from local DLNA servers (http).
TTS (or other media from HA) (https) is not played. Could be an auth issue.
I could not get the speaker component to work, it seems to have a bug:
src/main.cpp: In function 'void setup()':
src/main.cpp:311:56: error: no matching function for call to 'esphome::i2s_audio::I2SAudioSpeaker::set_internal_dac_mode(i2s_channel_fmt_t)'
spk->set_internal_dac_mode(::I2S_CHANNEL_FMT_ALL_LEFT);
^
In file included from src/esphome.h:25,
from src/main.cpp:3:
src/esphome/components/i2s_audio/speaker/i2s_audio_speaker.h:35:8: note: candidate: 'void esphome::i2s_audio::I2SAudioSpeaker::set_internal_dac_mode(i2s_dac_mode_t)'
void set_internal_dac_mode(i2s_dac_mode_t mode) { this->internal_dac_mode_ = mode; }
^~~~~~~~~~~~~~~~~~~~~
src/esphome/components/i2s_audio/speaker/i2s_audio_speaker.h:35:8: note: no known conversion for argument 1 from 'i2s_channel_fmt_t' to 'i2s_dac_mode_t'
*** [.pioenvs/test/src/main.cpp.o] Error 1
Hope this is useful for someone else, too.