streaming music from an Android phone via ESP32 to AUX IN

User avatar
Posts: 301
Joined: Sat Oct 01, 2016 9:05 am

Re: streaming music from an Android phone via ESP32 to AUX IN

Postby ESP_krzychb » Sun Jul 22, 2018 1:48 pm

I am glad you made it working!

megabite wrote:One problem - if I suddenly disconnect my phone from the esp32, the esp32 gets stuck in a loop and plays a constant tone indefinitely. It's as if it's stuck outputting the final transmitted 16-bit word.
I would try i2s_stop / i2s_start
megabite wrote:Having only used the Arduino IDE so far, I am not quite sure how to switch a GPIO pin to high or low within this esp-idf example. What would that code look like?
The code is quite simple. Check blink example.

After enabling the GPIO as an output in main() I would then switch it to high or low within bt_av_hdl_a2d_evt() callback.

Posts: 18
Joined: Wed Nov 22, 2017 12:56 pm

Re: streaming music from an Android phone via ESP32 to AUX IN

Postby megabite » Sun Jul 22, 2018 7:39 pm

Thank you. I will try out that code as soon as I get home tonight.

One more thing - is there a way I can get the ESP32 to reconnect automatically to my phone when the A2DP connection is lost? And to connect to my phone on its own without me having to actively start the connection in my phone's BT settings?

Just to give you an idea what this is all for, I have a radio in my car that's slightly older and can do Bluetooth phone calls via my Android phone, but not BT music streaming. It has an AUX IN socket for a headphone jack-type connector, so I thought I would build a circuit that serves as a Bluetooth adaptor for that AUX IN connection.

So it would be ideal if my phone would just connect itself to the ESP32 whenever I get in my car and turn the key, just like my car radio connects itself to my phone automatically.


So I've played around with i2s_stop(I2S_NUM_0) and i2s_start(I2S_NUM_0), but I kind of can't work out where in my code I would have to put those two commands. I tried putting i2s_stop() at the end of app_main right before the return command, but it had no effect, I still have that annoying constant tone when the Bluetooth connection is interrupted.

Posts: 1
Joined: Tue Jan 15, 2019 12:12 pm

Re: streaming music from an Android phone via ESP32 to AUX IN

Postby ronyeapen » Tue Jan 15, 2019 12:33 pm

Hello all,
I am new to ESP32 programming. I read your comments on utilising the a2dp_sink example on the ESP32 IDF examples. I was able to successfully flash the program onto my ESP-WROOM32 board and I used the internal DAC.

But, the sound quality is terrible. There is a constant hissing/buzzing noise as the audio content is being streamed. I have tried the same code on two different ESP-WROOM32 boards, and I get the same problem.

Did anyone else have this issue? Is there something I need to do to fix this problem? Does anyone have any ideas on how I can filter the noise out? Thanks for the help in advance.

Posts: 3881
Joined: Thu Nov 26, 2015 4:08 am

Re: streaming music from an Android phone via ESP32 to AUX IN

Postby ESP_Sprite » Wed Jan 16, 2019 8:16 am

If any, don't use the internal DAC; apart from it being tied to the 3.3V power supply (which probably is noisy on a random devboard fed by a long USB cable), it's also only 8-bit. If you want sound quality, use an external I2S codec fed by a clean power supply.

Posts: 1
Joined: Mon Sep 30, 2019 9:34 pm

Re: streaming music from an Android phone via ESP32 to AUX IN

Postby ristomatti » Mon Sep 30, 2019 10:07 pm

I ran across this thread while searching for example code on transmitting analog audio from an ESP32 (preferably with minimum external components, audio quality is secondary). I did not find what I was looking for but got the idea the OP was looking a relatively easy way to solve a problem that already has ready made solutions which fill most of the requirements and can be bought cheaper than an ESP32 devboard.

Just search for "bluetooth receiver module" on AliExpress/Ebay and you can find boards with Bluetooth, microusb power input and a 3.5mm jack connector for $1-2. Although it's not the most exciting solution, I'd rather spend my energy thinking of other projects to use an ESP32, unless of course the main purpose is to learn how to do something like this.

Who is online

Users browsing this forum: Google [Bot] and 35 guests