So I feel I have exhausted all options on making a ESP32 Wroom-32 board working as a stable Music Player with external DAC Max98357 I2S. It will only play right after I either reset it or unplug it. It can play MP3 locally, streams from radios, and TTS, but only a few times before it has to be reset or just decides to randomly work. I have tried various pinouts, various boards in config and various framework versions. It will still only play a few things if at all, and when stopping it, I need to do a full reset before anything will work again. Is there something wrong with the ESP Wroom-32.
There is very little information on this, both posted here and on the net in general. Like what is a safe board to use, what is a stable config or is using ESPs as media players not really a thing?
When āplayingā the log will say that it is playing this and that URL, but there is simply no audio. Maybe its the DAC, but I have made two boards like this with the same DAC and the same ESP. Both are behaving the same. The speakers I use are both 4ohm and 3W, and gain has been both floating and tied to gnd. I just wish it could behave stable since I have a lot of usecases for this. What is peoples experience with ESP32 as Media Players, and what combinations are workig stable?
I have ordered a new type of DACs and ESP Wrover boards that may or may not be better suited for this. BTW. All connections are soldered on.
Didnāt try this out myself yet, but just a few thoughts for narrowing things down:
power supply big enough?
pins 25 and 26 are connected to the internal DAC of the esp32, you are using 26 and 27, maybe the overlap of the 26 pin sometimes creates a hickup? => try to switch 26 to 23 e.g.
can you try the same hardware setup with pure arduino code instead? I had experiences in the past where peripherals worked better with arduino code, while the esphome implementation was buggy
Yes, power-supply is ok. On a logger it uses maximum 150 mA @ 5V
I will try using other pins, and I did think about the possibility, but seems like most example-code out there is using these pins.
I am not very well versed in normal Arduino-code, and I am not sure how to set it up to work in HA. I have dumpet the bin-files and tried to flash using ESPhome-Flasher, but both modern and legacy files turned made errors and made it boot-loop. But I was able to use the same files in Web-flasher tool somehow with no problems. I was hoping that a cabled flash would maybe be better. Really not sure what I should aim for in Arduino-code. I guess being able to play streams and mp3 over internet reliable will rule out hardware issues between ESP32 and the external DAC?
Really? That actually seem to do the trick, and it makes sense since the Wroom is especially built to be low-power, which also explains the low wifi-signal it had. I have now reverted to recommended repository for the Arduino-code, because ESPHome seemed to crash in the background when using these two boards with ālatestā code. At least it is working much better now, but daring to say it was a fix is scary since I might jinx it. Now I am able to switch between Radio, Local Files and TTS for more than 30 minutes. In case it works: A big thank you for your intuition and knowledge. And also for all other suggestions. I was away all day, so didnāt have the time to test much.
If just some streams are not play may due to the sample rate.
Iām facing the same issue as it will not play anything after idle for not sure how long.
Once restart it, it can play again.
Tring to add wifi power save mode to none. See if that helps.
I am curious. What kind of bitrate and samplerate are you able to achieve from an ESP32/wDAC? Is it able to play back 24/96 streams? Maybe I have been spending a bit more money on Raspberry Pis with HD-Audio hats (fully integrated in HA via Volumio). Can I can do the same with a $5 ESP32 + DAC. I cannot imagine the quality would be the same however. The Rpi has way more horsepower. Am I wrong?
I was more curious about its ability to decode 24/96 FLAC files. This is the format I use to record my huge vinyl LP collection. With a few exceptions, I stopped using mp3s years ago.
Greetings. I am also now realizing my first experiment with esp32, using this instruction My Local Voice Assistant Device With Wake Word In Home Assistant | Smart Home Circle.
I have repeated the circuitry in full accordance with his schematic. According to the principle - if everything works for him, why to be clever and change something. I donāt have anything related to tts yet (I have core version and itās not so easy to install it all on it), but the functions of media player and beautiful colored lights work successfully. Of course, as always, with some peculiarities.
I also noticed a few times that my smart speaker would freeze up, but that wasnāt the main problem. I couldnāt run music or activate any dynamic program of blinking LEDs, as it caused crackling and interference in the sound. I tried to analyze settings, timings, power supply, to figure out what I was doing wrong. But it turned out to be a matter of circuitry, and I think it affects a lot of things in operation. I have the microphone and amplifier boards soldered with rather short wires, no more than 5 centimeters. But when I moved them and touched them with my hands, these sound distortions disappeared. I came to the point where I soldered an additional wire to the āgroundā (minus power supply) and wrapped the signal wires with it, making something like a twisted pair or shielding.
The interference is gone!
What Iām getting at. I had a thought that unstable esp32 operation may be caused by the fact that this interference not only affects the sound, but also the processor itself, leading to failures. I think you should use as short wires as possible, possibly shielded, and generally do the mounting inside the device case taking into account the effects of electromagnetic fields, which will eventually improve wifi radio reception as well.
In the near future I am planning to build a second speaker (in a different cabinet, I use factory satellite speakers from an old home theater), and I will try to take into account the experience in the circuitry. I will try to write about the results, how much it will affect the stability of operation.
Interference is no joke. I banged my head for several days teying to rid my speaker of static and crackling too.
I have been trying to build a new smart speaker that uses esp32 with an amplifier and then also share the amplifier with one of those BT audio receiverās. This way i could TTS or do announcements from HA but, anyone could pair to the speaker with their phone and use it to play music.
I can use either DAC or BT just fine but, when i put wire them both to the amp I get static and interference!!
I think a good result would be to use old ide or fdd cables, where each data wire alternates with ground. Or for example, how the cables from motherboard to monitor are arranged in laptops, where shielded twisted pair is used. I think any of us has some old and no longer needed computer hardware, tablets, TVs, etc., which can be used for homemade products. All this breadboard assembly on wires, which is used for arduino DIY, is suitable only for preliminary performance testing and can not be used in working devices. Sometimes this is a serious problem for computer and electronics manufacturers, when they have to change the shape of wires on the PCB to avoid interference and malfunction, and we used to not think about it.
Here, itās good time to think how to make a good stable working device
An important note. I have found that many radio stations from the media - radio browser cause esp-speaker to hang or reboot when trying to start a stream. This is because there are different streams mixed in there, but not all the speaker can play (e.g. aac). The same applies to local files, apparently not all mp3 bitrates are played correctly (high bitrate mp3 and flac). Some just wonāt play, some will cause speaker to crash:
WARNING speaker-1 @ 192.168.0.228: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for speaker-1 @ 192.168.0.228
WARNING Disconnected from API
INFO Successfully connected to speaker-1 @ 192.168.0.228 in 0.005s
INFO Successful handshake with speaker-1 @ 192.168.0.228 in 2.184s
[21:05:41][D][media_player:059]: 'esp_speaker' - Setting
[21:05:41][D][media_player:069]: Volume: 0.48
[21:05:41][D][light:036]: 'Light' Setting:
[21:05:41][D][light:051]: Brightness: 50%
[21:05:41][D][light:059]: Red: 100%, Green: 0%, Blue: 100%
[21:09:57][I][ota:117]: Boot seems successful, resetting boot loop counter.
[21:09:57][D][esp32.preferences:114]: Saving 1 preferences to flash...
[21:09:57][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
Now Iāve selected a few tested streams for myself, and the speaker has been working stably without hangs and crashes for the last two days, playing music and some tts during scripted events.
So it looks like the software part itself is working steady, except for the limitations of the capabilities of the esp32 board itself. Itās just something to keep in mind when working with it.
For newbies like me, or those who just havenāt looked into it, let me explain. HomeAssistant does not create an audio stream, it only passes the address of the stream from outside to the speaker, or creates a link to the media file to be played. The same applies to voice assistant messages and other tts events. They are rendering to an audio file, which is saving locally, and then a link to it is passing to the speaker and it plays it. If it can. We can only see the status, like āplayingā or āidleā. Unfortunately this is all the available feedback on the status of the speaker at the moment.
I am having the same problem and tried with different pinout. Always the result is the same: starts working but after several minutes or seconds (random) stops working. Then I have to reset it to start working again.
I connected the osciloscope and this is the āi2s_dout_pinā pin when works:
and this is when fails (it is just like a square signal):
I am using UDA1334a and same result if is not connected. I think the problem is in the output of the ESP32 board. I am using a ESP32 WROOM devkit c 38 pin.
Definitely I think the problem is in the ESPHome firmware. I tried with a ESP32-WROVER and same result: work but it stops working after a couple of minutes. However, I have tried squeezelite-ESP32 and works really well in the WROVER. I can send a mp3 by a homeassistant script for the doorbell and more else:
Send Spotify streaming
Connect by bluetooth as a common speaker does and send the streaming.
The only thing Iām missing is a homeassistant switch that activates an output pin of the WROVER board
I found how to activate a pin and it is not needed to do it from Home Assistant. Going to NVS editor (enable the tab if it is not visible) and define set_GPIO as ā33=ampā. This activates a relay that turns on the speaker. Now squeezelite-ESP32 is perfect for me!