Time for an audio project: I took my PCBWay ESP32‑S3 board for a spin—fixed the common anode/cathode LED mix‑up, verified the IMU and battery charger, then tested an I2S PDM mic and tiny speaker with a Web Serial Audio Studio (scope, spectrogram, tuner). I also turned it into a USB UAC device in ESP‑IDF: the mic is clean, but speaker over UAC is crackly (Mac/Windows toggle oddity); direct I2S WAV playback is perfect, so the hardware passes QA.
That’s right, folks. It’s time for an
audio project. So, I’m testing out my
boards. I got these from PCB way. Check
out a link to them in the description.
So, so far we’ve tested the RGB LED that
required a small ninja fix here. So, I
put a common cathode LED when actually I
needed a common anode LED. Or was it a
common cathode, common anode, common
anode, common cathode? I can’t remember.
But either way, I got it wrong and I
fixed it. And then we also tested out
the accelerometer and gyroscope. So, we
made ourselves a digital twin of this
board and that worked really nicely. At
the same time, we tested the battery
charger, which works nicely as well. So,
we wanted to go without any wires, so we
could move the board around for our
digital twin. The battery charger worked
perfectly. So, now we’re testing the
microphone and the speaker. So, here’s
the amplifier here, and here’s the I
squared SPDM microphone just here. And
I’ve stuck this little tiny speaker on.
So, we’re ready to test these. Um, my
initial thinking was, let’s just use
this as a Bluetooth audio device.
Bluetooth Classic supports audio.
Unfortunately, the ESP32S3 doesn’t
support Bluetooth Classic. We’ve only
got Bluetooth low energy, and Bluetooth
low energy doesn’t do audio. So,
instead, what I’ve done is I’m sending
the data over the USB serial. So, it’s
amazing how much data you can actually
send over USB serial. We done a previous
video on this and we got around 7
megabits per second for this. I’m just
sending around 32.2 kilobytes pers. So
we got a sample rate of 16 kHz and we’re
doing 16 bits per sample. So not that
much data really and you can see it
works really well. So I got the AI to
code up this little web serial audio
studio for me. So we have this
oscilloscope. We got a
gain control. So we can turn that up and
down. There’s a nice spectrogram. I’m
not entirely sure this is working
properly, but it looks pretty. There’s a
1980s style bar chart, which looks
great. And there’s also this pitch
tuner. So, if we open up a a piano,
let’s see if this actually works. So,
all of this audio data is coming from
the PDM audio on the microphone over I
squareds and then over serial over USB.
So, let’s open up a piano and test this
out. So, there we go. I’ve got this
piano here. So, if I play some notes,
this pitch tuner should pick them up.
Let’s just turn the volume up high. So,
let’s do a Yep.
So, that seems to work really well. So,
our microphone’s working fantastically.
So, what about the um amplifier and the
speaker? My initial thinking was, well,
I’ll just do the same thing. I’ll send
data over serial and get that to play
through the speaker. But then I thought,
hang on a minute. We’ve got native USB
on this device. The ESP32S3 has native
USB, and I’ve seen plenty of USB
headsets and USB speakers. So, why can’t
I turn this into a USB audio device? It
turns out you can. There is code to do
that. So, it’s actually really simple.
There’s a USB UAC device. We set up some
callbacks. So, an output call back, an
input call back, there’s a mute call
back, and a volume call back. Now, the
only thing that is a slight disadvantage
with this code is I couldn’t get the
Arduino library for this to work. So,
I’ve had to switch to the ESP IDF. Now,
that’s not as bad as it may seem. There
is a plugin for VS Code, an ESP IDF
plug-in that makes this pretty easy. Um,
you end up with this ESP IDF explorer,
which has all the things for building a
project and flashing a project. So, it
actually isn’t that bad. Um, there are
some limitations with this UAC device
thing, though. Now, one of the biggest
ones is um there’s this little thing in
the configuration. So, if I scroll to
the right place, then you can see
there’s a tick box. Here we go. Support
Mac OS. So, if you tick this, it works
on a Mac, but it doesn’t work on
Windows. If you untick it, it works on
Windows, but doesn’t work on a Mac. So,
that’s a pretty big limitation. So, but
let’s try it out. We’ll use the
microphone via USB UAC. So, if I go back
to my um little web serial audio studio,
um what I’ll do actually first need to
flash it. So, let’s build this project
and then we’ll put ourselves into upload
mode and then we’ll flash the device.
So, that’s all flashed. And then we’ll
reset. And then we’ll go back to here.
And if I just uh refresh to get a new
list of microphones. Then what we should
see is USB UAC. So that’s our ESP32
device. So we can connect to that. And
again, we can turn up the volume so we
can see our audio coming through. We
have the spectrogram. And we have the
bar graph. And we have our tuner. Let’s
just check our tuner again. Okay, let’s
play some notes.
[Music]
Well, actually, those notes are coming
out of the USB device. So, our speaker
is working as well. I wasn’t going to
test that yet, but I’ve just tested it.
But let’s uh let’s switch to the to the
correct output device. So, I’ll just
bring up system settings and we’ll do
that. Okay. So, we’re back using uh my
Mac speaker. So, let’s play this thing.
So, we’re actually doing the microphone
and stuff. So,
we go. A.
So, the microphone is working nicely and
of of course you did actually hear the
speaker working, but I want to play some
actual real music through the speaker.
So, I’ll switch back to the output
device being the USB UAC. And now, let’s
find some music. So, here we go. I’ve
got my uh my songs I’ve been playing
with over on Sunno. So, let’s play our
Fix It Up Matey song.
[Music]
Oh, the screen’s gone black. The
joystick’s wobbly. It’s on the brink.
The game’s mad. It’s lost it. But I got
my solder and I got no fear. Fix it up.
Fix it up.
So, it does work. It’s very crackly.
Now, I’ve been spending ages trying to
understand what’s going on with that and
why it’s so bad, and I cannot get to the
bottom of it. So, what I have done is
I’ve gone back to one of my original I
squareds projects. So, here’s my very
old code for doing um audio testing. Um
so, let’s go into upload mode. And this
just plays a WAV file from Spiffs. So,
we’ll upload this
And then if I hit reset.
[Music]
Oh, the screen’s gone black. The buttons
don’t blink. The joystick’s wobbly. It’s
on the brink. The game’s gone mad. It’s
lost its cheer. But I got my solder and
I got no fear. Fix it up. Fix it up.
Sparks are flying.
So, you can see that plays back
perfectly. So, I’m wondering what’s
going on with the UAC stuff. The
microphone works really well, but the
speaker not working so well. And in
fact, let’s um let’s actually really
check the microphone. So, I’m still
connected to the USB UAC. Um so, let’s
uh so let’s upload the sketch again. So,
we’ll flash the device with the UAC
code. Okay. So, now we should be able to
connect to the microphone. So, the USB
UAC should connect.
Let’s uh reset that. Refresh the page.
And come on, come back to life.
There we go. USB UAC. So, we’ll connect.
So, that’s connected. We can see the
audio data coming through. Uh let’s try
recording some audio. So, start
recording. So, testing, testing, one,
two, three. This is a test of the USB
UAC microphone. And then we can open
that up in Audacity. So, it looks pretty
quiet. These microphones, they’re a very
high dynamic range. They’re quite
sensitive, but because they have such a
high dynamic range, often the audio
looks quite quiet, but we can just
amplify this.
So, there’s our audio data. There is a
DC offset. So in the serial version of
the code, I’ve actually removed that by
applying a filter, but in the US USB
UAC, I’ve left that in. Doesn’t really
affect anything. You can just do a highp
pass filter and get rid of it. But let’s
listen to this and see how well it
sounds. Start recording. So testing,
testing. One, two, three. This is a test
of the USB UAC microphone. So that’s
actually pretty good. Not bad at all.
So, the microphone works great and the
speaker works great so long as you’re
driving it directly. So, I’m going to
say this board has now passed quality
assurance. It’s time to move on to the
next phase of the project, which will be
in a follow-up video. So, thanks for
watching and I’ll see you soon.