Build Your Own Custom Bluetooth Speaker with ESP32 & A2DP | DIY Audio Project

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
When I took apart the old broken iPad1 I ended up with a nice LCD screen for my magic mirror and I also ended up with a couple speakers. I want to complete the salvage operation and turn these two speakers into something useful. For most of my audio projects, I've been using the MAX98357 breakout board from Adafruit. This is a great little I2S Class D amplifier however, it only supports one channel. So if you want to have stereo output you need two boards. This is fine, but it's a bit of a faff wiring it all up. It's not a massive hardship, but let's make our lives easier. But first I'd like to thank PCBWay for sponsoring this video, PCBWay offer PCB Production, CNC and 3D Printing, PCB Assembly and much much more. They are great to deal with and offer excellent quality, service and value for money. Check out the link in the description. Looking at the Adafruit board I think there's room for two ICs and the nice thing about I2S is that it's designed for stereo signals so we won't need any extra pins. This should mean that whatever we design can be made to be pin-compatible with the Adafruit board. If we look at the datasheet we can see that it's actually a very simple IC to wire up. We just need a couple of bypass capacitors for each IC and we need a resistor on one of the ICs so that it knows it is on the right stereo channel. We can also take a look at the Adafrui schematic to see what they have done. Interestingly they've added an additional LC filter to the output. Checking with some other breakout boards we can see that they omit the LC filter. Checking back in the datasheet we can see that the output filter should not be needed. To save a few components, I'll omit them from my design and rely on the speakers acting as a filter. Let's jump into EasyEDA. We'll start off with a 7 pin header and make sure we match the Adarfuit board exactly. We need VCC, GND, SD, GAIN, DIN, BCLK and LRCLK. With the header in place, we can now wire up the first IC for the left channel. We'll pull in the IC and hook up the pins. It's not a difficult schematic to wire up. For the NC pins on the IC I'm connecting them all to GND - this should help with thermal dissipation as I'm planning on making quite a large ground plane. With the power and ground connections done, we can just hook up the nets for the signal lines. And then we hook up the positive and negative outputs to the speaker. To save space I'm going to use some quite small screw headers with a pitch of 0.1 of an inch. The last thing we need is the two decoupling capacitors. And that's our left channel completed - as I said before it really is a simple schematic. We can just make a copy of this for the right channel. The only real difference between the left and the right schematic is the resistor that we place in series on the SD input. Let's have a look at the datasheet to see how to calculate the value for this. I'm going to use the approach given in figure 5. So we'll need to pick a value for R that gives a voltage between 0.77v and 1.4v when the GPIO is outputting 3.3v. There's an internal pull-down resistor of 100kohms with a tolerance of plus or minus 8%. I've calculated that a 200Kohm resistor with a 1% tolerance should work for us. In the worst-case scenario, where have a 202KOhm value for R and 92Kohm value pull-down resistor, we'll have a voltage of just over 1V. And when have 198kohms for R and 108kohms for the internal pull-down resistor, we'll have a voltage of around 1.16 volts. This puts us pretty much in the middle of the voltage range of 0.77V to 1.4V for right channel mode. We'll add this resistor into the schematic for our right channel and feed the SD signal through it. We just need to make sure our output is properly wired up and we're done with the right channel. As I've said, this is a really nice and simple schematic to wire up. We're now ready to do the PCB layout. I'll start off with a rough layout of where the components should go, placing them in approximately the right locations and orienting them so that the pins and signals are nicely lined up. Since this is a breakout board, labelling is pretty important, so I'll also do that now to make sure the text fits in nicely. I'll neaten up the layout and once we've got everything in roughly the correct position we can add the board outline along with some mounting holes. I'll also copy the pin labels to the bottom of the board - this is really handy and I wish more dev boards would do this. The last thing we'll do before starting the wiring up is label the output pins. Once again I'll duplicate these on the bottom of the board as well We're now ready to start wiring things up. I'll turn off the silk layers for this stage as they are getting in the way. I'll start off with the signal wires. We'll do the left channel first. I've turned off the VCC and GND nets to make it easier to see what I'm doing. For the right channel, I don't think there's any choice but to use the bottom of the board for some of the traces. I'm just going to tweak some of the positions to make sure the silkscreen is still readable and adjust some of the wires. For the power, I'll use quite thick tracks the amplifiers can draw a fair amount of current when the gain is set to maximum. I'm going to use 40mil width traces which should be more than sufficient. To get power to the left channel I'll use a thick trace on the bottom of the board. I'll also use thick traces for most of the wires to the speaker output. I can't use thick traces all the way as the pins are too close together. We'll add copper pours to the top and bottom of the board for GND and stitch them together with some vias. The thermal pads on the ICs are connected to these ground planes so this will provide a nice route for any heat to escape. After Looking at the ground plane on the bottom layer I've decided to reroute the signal traces for the right channel so we get a better ground plane under the left IC. With that done I'll redo the copper areas and we're pretty much done. Just some final tweaks on the silkscreen layer to tidy things up. And we need to add a label to the board with a revision number. That's it all done - I've exported the Gerber file and we can jump onto PCBWay to get the board ordered. We'll use the PCB Instant Quote option and upload our Gerber file. Everything should be set up for us - I'm going to get these boards assembled so we'll complete the SMT assembly section and proceed to our shopping cart. Here we upload the BOM file and the pick and place file which we can export using the fabrication menu in EasyEDA. PCBWay will now source our components and give us complete cost for our 5 boards. One of the nice things with PCBWay is that you have a lot of options when it comes to components. You are not limited to a restricted parts library, they will source the components for you and you can even supply your own components if you want to. Within a day we have an email from PCBWay with the costs for our parts. Once we've approved the costs the order goes into production and we can track the progress online. Now, if you've watched the most recent mailbag video, you'll know that the boards have arrived! They look really good. I've soldered one of them up and we're ready to test. I've got a couple of speakers that I salvaged from my old iPad1 which I took apart for the magic mirror project. I'm also using version 2 of my audio PCB so this is a double test. Let's hope I've got the wiring set up properly... It works really nicely. The bare speakers don't sound great so I thought I'd try 3D printing some speaker enclosures. Turns out I don't know anything about designing speakers and it sounds pretty much the same as before. There are a couple of things that I'd like to improve. I was a bit aggressive in making the board as small as possible and the screw terminals are hanging off the edge of the board and they are also pretty close to the amplifier chips and only just fit in the space. You also can't see the labels for the screw terminals they are visible on the bottom of the board - but that's not much use when the boards are plugged into a breadboard. I'll fix these two issues and then publish version 2 on PCBWay for other people to order. So, now we've got a stereo amplifier and some speakers - what can we do with them? I'm going to make a really simple Bluetooth speaker. The ESP32 supports Bluetooth A2DP which makes this very easy. There's also a really nice library from pschatzmann on GitHub that makes this a breeze. All we need to do is tells it the I2S configuration and the pins to use and it will do all the heavy lifting. Once it's up and running we can pair it with our new audio device and start playing sound. It's pretty cool! I'm really happy with both my speaker salvage and my new audio boards. I hope you enjoyed watching the process. Thanks for watching And I'll see you in the next video!
Info
Channel: atomic14
Views: 35,025
Rating: undefined out of 5
Keywords: bluetooth speakers, esp32 a2dp, esp32 a2dp sink example, esp32 a2dp sink volume, pcbway assembly, pcbway tutorial, smt assembly, a2dp, bluetooth, audio
Id: 2ZdfMJNfCWg
Channel Id: undefined
Length: 9min 42sec (582 seconds)
Published: Thu Jun 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.