Notifications
Clear all

ESP32 Bluetooth " transmitter"

11 Posts
4 Users
1 Reactions
5,473 Views
BunnyKiller
(@bunnykiller)
Member
Joined: 5 years ago
Posts: 31
Topic starter  

Hey All,

Been working with the ESP32 and want to make it "transmit" audio signal from the rear speaker connect of my sound card on my computer to a Bluetooth "receiver" mounted inside the case of the "rear speaker set".

Plans are to install a 120VAC/5VDC phone charger inside the sub woofer case ( where all the power amps are for the speaker set) and have that power a Bluetooth "reciever", the output of the "reciever" will be wired directly to the audio input jack of the amp. Im trying to avoid running 20+ feet of wire from the computers sound card to the speaker set. What Im having trouble with is finding the proper code to load into the ESP32 to send a Bluetooth signal from an analog audio source ( rear output of sound card) to the receiving Bluetooth module. So far at this point I can get the computer to recognize the receive module and send a signal to it but it always wants to send the front channels only. If I turn off the computers Bluetooth and use a stand alone ESP32 unit, I think I can achieve my goal.

Do any of yall have some good leads to some easy to use code for this idea?  Much appreciated..

 

BK


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7632
 

@bunnykiller Not sure what part you have working and what part is not. I would first do a Google search, then do a GitHub search. One very important thing to do is be disciplined about trying a library, and when it doesn't do the job, DELETE it before trying the next library. Good luck.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1857
 

Hi @bunnykiller,

  Sorry, I am not the best person to advise on available libraries, but I also got confused about the description of what you are trying to do, and I wondered if a little clarification of the specification of what you are trying to do would help.

  I think I understood the first part of your message, but this part confused me.

What Im having trouble with is finding the proper code to load into the ESP32 to send a Bluetooth signal from an analog audio source ( rear output of sound card) to the receiving Bluetooth module. So far at this point I can get the computer to recognize the receive module and send a signal to it but it always wants to send the front channels only.

In particular, how/where does the 'analog audio source(rear output of sound card)' turn into a Bluetooth signal?

Does your computer have a sound card that transmits all of the front and rear channels as Bluetooth?

I couldn't find any 'authorative' descriptions of how many audio channels Bluetooth can handle, but some descriptions clearly say that Bluetooth is limited to two channel. e.g.:

https://thehometheaterdiy.com/how-many-audio-channels-does-bluetooth-support/

Whilst such descriptions can always be misleading for any number of reasons, such as new developments since they were posted, they did leave me wondering if what you were suggesting was 'possible' with standard equipment.

------------

However, I can imagine a system that consists of two parts ..

  1. A digitiser/Bluetooth 'source', that takes the audio stream of 1 or two channels, from (say) a 3.5mm jack socket of PC sound card, intended for a rear speaker connection, digitises the signal(s), and transmits it over a Bluetooth link.
  2. A Bluetooth receiver, that connects to the 'source', and converts it back to analog, and feeds it to an amplifier(s) and speaker(s). (The receiver box you describe you want to build would fit this role.)

Whether such a system exists commercially, I have no idea. Equally, I haven't tried to do it, so I have no idea if there are any practical problems to overcome.

Perhaps, if you clarified exactly which parts you have identified as the 'source' of the rear channel(s), then someone may be able to help?

-------

And as a last comment, particularly if it is necessary to have a Bluetooth source as I suggested above,  I haven't any personal experience with I2S, but a quick look at Bill's (@dronebot-workshop) excellent video and accompanying article suggested there is an entire 'infrastructure' of modules, software, etc to explore that is dediciated to audio. Perhaps, it is worth a look?

https://dronebotworkshop.com/esp32-i2s/

--------

Of course, I could have simply misunderstood your question, in which case please accept my apologies.

Best wishes, Dave


   
ReplyQuote
BunnyKiller
(@bunnykiller)
Member
Joined: 5 years ago
Posts: 31
Topic starter  

hmmm lets see...  an ESP32 requires an input signal to the ADC, preferably analog such as a sinewave or music etc. My computer has a sound card in it and it has multiple outputs such as front LR, Center LR, Side LR, Rear LR and of course sub woofer. All of the speakers are actively driven by amps built into the speaker systems such as  the Front LR, Center LR, and Rear LR, but to get them to work requires lengths of wire with RCA terminals or 3.5mm stereo jack. The Front Center and Side speaker sets are close enuf to the computer that using wire isnt a problem, but the Rear set is rather far enuf away, running wire is not the best idea. My idea was to set up an ESP32 in Bluetooth mode to send the signal from the Rear speaker output of the soundcard to another Bluetooth unit that will receive that signal to make the speakers work. I set up the Bluetooth module that is a receiver into the Rear speaker system and it works with the computers Bluetooth output BUT the computer sends the Front speaker set signal, not the rear, and I cannot get it to do anything elsewise other than turning off the computers Bluetooth and making my own Bluetooth "transmitter" and hooking it into the rear speaker output of the sound card. So, Im trying to make the rear speaker set a Bluetooth speaker set and leave the rest as normal wired from the sound card.  So, what I am looking for is code/software/script etc that will turn on the ESP32 in Bluetooth mode, retreive the Rear speaker output signal from the soundcard and send it to the purchased Bluetooth reciever that will then supply a signal to the rear speaker amp input.

Yes a system does exist, it consists of 2 modules, a Bluetooth transmitter that is plugged into a speaker out put source and the receiver which is plugged into the Aux in on an amp but the price of the system is more than I wish to spend on a device that has 2 stars rating and alot of bad reviews...  50$ spent for fuzzy sound isnt what Im after...

the video you listed was a good one but it really doesnt give much info on setting up a system like Im trying to do...

BK

This post was modified 1 year ago by BunnyKiller

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7632
 

@bunnykiller So if I understood you what you  are looking for is 

code/software/script etc that will turn on the ESP32 in Bluetooth mode, retreive the Rear speaker output signal from the soundcard and send it to the purchased Bluetooth reciever that will then supply a signal to the rear speaker amp input.

in other words an 'esp32 Bluetooth transmitter' It looks like the following LINK is what you need and this LINK might have some examples to inspire you. That first link is the library and it contains all the examples shown in the attached pic. 

FYI, see 2nd pic for hint on adding the downloaded (green button last link is Download) library to your libraries, then the examples I showed you will be available.

Screenshot 2023 05 28 at 16.04.25
Screenshot 2023 05 28 at 16.07.45

  

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1857
 

Hi @bunnykiller,

  As far as I can understand from your reply, you are trying to build a two module system along the lines I indicated.

-------

I can obviously relate to not wanting to spend $50 on a commercial system with bad reviews. I only asked the question, as it sometimes helps to look at what is already around for ideas of what might work and what fails to work, even if your own solution turns out to be completely different.

------

I also now understand you have the entire 'receiver' end, for Bluetooth to audio, plus amplifier and speaker.

I don't know much about Bluetooth, but it is apparent that Bluetooth is not a fixed standard, but instead there are a number of protocols and versions, which appear to be related to hardware changes. The extent to which these different standards are compatible with each other is unclear, but I think you will find it useful to establish what your standard your receiver is expecting, so you have some chance of matching the other unit to it.

-----

The essential task of the other unit will be performing an analogue to digital (A/D) conversion sampling on the audio from your sound card, and transmitting the result via Bluetooth protocol.

Whilst the ESP32 does have an A/D converter built in, to get a reasonable result, it is probable that you will need at least some simple analogue circuitry to provide the required signal level to match the A/D input requirements.

I am also a little cautious that the built-in A/D is good enough, given that they are only 12-bit (e.g. CD audio is digitised to 16-bit), and also the A/Ds incorporated in ESPs seem to have acquired a fair amount of criticism about their quality in the chat on the web, though this is only hearsay, and I have absolutely no hard evidence on this point. This suggests you might consider looking for  better quality A/D with accompanying software that covers the entire path from sampling the incoming audio through to transmitting using a Bluetooth protocol that your receiver can handle. Of course, such quality requirements are also quite subjective, so it is plausible that a simple and crude approach is 'good enough'.

--------

However, I think you need to be looking for a 'package' that covers both the hardware design and the software to interface to an audio output source, through sampling and transmitting the result as a Bluetooth transmission that is compatible with your Bluetooth receiver/amplifier/speaker system.  The audio input source is a PC sound card. The Bluetooth specification is to be clarified. It is presumed that the quality of the sound transmitted should be adequate for high fidelity music reproduction.

Depending on the complexity of the electronics hardware design and assembly skills, that could be a description of parts, and circuits, or it might be pre-built module(s).

--------

Sorry, as I said at the start, I do not have any solutions to hand, but I hope this discussion helps to clarify what you are looking for and maybe encourages others to contribute some suggestions. Whilst the particular requirement of it being used for the rear channel maybe relatively unusual, a solution would be generally useful for any application involving a one or two channel analogue audio source, which could be useful in a wide range of situations. (Obviously, if I find anything that looks useful in the near future, I'll make a further post.)

Best wishes and good luck in finding a solution, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7632
 

@davee Once again, we crossed in the aether. I THINK I found the library he needs, although after looking at a few examples I still don't 'get it'.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1857
 

Hi Ron @zander,  (@bunnykiller)

 I can confirm we crossed in the ether ...

It is too late for me to search through your find tonight, although just looking at the screen shot looks hopeful as a starting point.

As I said, I was trying to create some sort of requirement 'framework', in the hope others, yourself obviously being a prime example, would be able use as a basis to make suggestions. Initially, I wasn't clear what was required. I had hoped I had made a little progress in that direction, but I make no claims of success.

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7632
 

@davee I must admit that this project appears to be much more difficult than I first thought. OR I have misunderstood what is needed or did not find an adequate library. Hopefully, @bunnykiller will soon let us know.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@hzulu)
Member
Joined: 1 year ago
Posts: 16
 

@bunnykiller
in case you are not already aware of this website...

https://www.pschatzmann.ch/home/2020/09/15/sending-sound-from-an-esp32-to-a-bluetooth-sink-e-g-bluetooth-speaker/

I think it covers all solutions you need for your project on the digital/software part.

Rule of Thumb in hardware/software engineering:
From the estimated time to complete a project you need:
5% for the engineering itself
95% securing everything against any strange idea users can have
and the remaining
150% for finding and fixing bugs that you thought never could happen


   
DaveE reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7632
 

@hzulu @bunnykiller YES, that is the guy behind the library I pointed out to him.

https://github.com/pschatzmann/ESP32-A2DP

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote