View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

Learn how to repurpose old iPad speakers with a custom designed stereo I2S Class D amplifier, using EasyEDA for the schematic and PCB layout. Discover how to create a simple Bluetooth speaker using an ESP32 and a stereo amplifier for your DIY audio projects.

Related Content
Transcript

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


HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts