Hey folks! So, I've been tinkering with a compact PCB featuring an ESP32 S3 Mini, and it's been a blast! This little guy has a USB-C and battery connection, with nifty chips like a charge controller and voltage regulator. I'm diving into mechanical keyboards with some cherry switches, and guess what? I made this cool 'Vibe button' for a single key keyboard! I even used AI to vibe code it, so it sends command-enter when pressed. PCB Way did a stellar job on the assembly, and now I'm setting up the RGB LED for charging status. Let's make coding more vibey!
So, what have we been up to? Well, Iāve
been making this very compact PCB. Itās
got an ESP32 S3 Mini. Now, weāve got a
battery connection and weāve got a USBC
connection. So, this IC here, thatās the
battery charge controller. This one here
is the ESD protection chip. This chip
here is the power switch. So, Iāve moved
away from the fairly classic MOSFET plus
diode and Iāve started using this IC. I
quite like it. The reason I really like
it is because um you can basically put a
lot of capacitance on the other side of
it. So it has a slew rate limiter
circuit. That means when itās powered
up, it seems like itās not got much
capacitance to the USBC connector, but
you can put a lot of capacitance on the
other side. So itās quite handy. And we
also got this um RGB LED. Now this
really tiny IC here is the voltage
regulator. It is absolutely microscopic.
Pretty amazing. So, this is a single key
keyboard. Now, Iāve designed it to take
two different types of cherry switches.
So, this red one is a low profile
version, and this blue one is a standard
height one. Um, so unfortunately or
somewhat annoyingly, these have quite
different footprints. So, the red one
has this very large kind of thing that
goes through the PCB. Blue one has this
quite small um bit of plastic. But I
have managed to get a footprint that
works for both. So Iāve got a blue
version
and I have a red version. Now this is my
first um experiment with um mechanical
keyboards and I have discovered all
about stabilization. So if letās have a
look at the the red one first, the low
profile. So if we put the key cap onto
this works quite nicely when you push in
the middle. If you push either side,
itās really not very good. Itās uh not
very stable. And if we try it on the
blue one, you can see we have the same
problem. So, letās um letās connect
this. So, itās less bad, but itās still
not very nice to use. Itās a bit wobbly.
But what you can do is you add on these
stabilizers. So, these um these black
bits are stabilizers. They clip through
the PCB and this metal rod connects
them. So when you move one, the other
one moves. So if we take our key cap
and stick it onto this.
So now when I push on one side, the
whole button goes down. So thereās no
more wobbliness. Itās actually quite a
nice movement. So it works quite well.
Unfortunately, these stabilizers
donāt quite match up to the red button.
and theyāre just too tall. Iāve looked
around to try and find stabilizers for
red versions, but um I canāt seem to
find any. So, any ideas, please put them
in the comments. Now, obviously, itās
just a plain white button. Thatās pretty
boring. So, what Iāve done, Iāve had
these custom buttons made. So, we now
have our Vibe button. So, Iām going to
do a bit of Vibe coding. So, letās give
it a go. Weāll vibe code up the software
for our Vibe button and see if it works.
So before we get down to some vibe
coding, I just want to do a quick shout
out to PCB Way who manufactured these
PCBs and did the SMD assembly. As
always, itās a fantastic job. Check out
our link to them in the description. Get
your own PCBs made. Why not? So what is
Vibe coding? What are we even talking
about? Well, itās the new way of coding
where you donāt even look at the code.
You just let the AI do it. So what Iāve
done here is Iāve set up a platform IO
project. We have the out of the box main
function and Iāve added in this header
file that defines all of our GPIO pins.
Now, you might be saying, āSurely youāre
cheating. Havenāt you just written a
bunch of code in this hardware header
file?ā Well, actually, no. I used an AI
to write it for me. So, I tried a few
different ones. Hereās Chat GBTās
attempt. So, I gave it the net list and
the bomb, and it generated this header
file. Itās actually pretty good. So,
itās worked out the RGB LED and itās
active low. Itās got the boot key and
itās got our key press. So our GPIO pin
is 33 is connected to the cherry key.
Now the only thing it did that was quite
weird is this enable pin. It made up
this GPIO number. So I had to go with
Claude instead. So hereās Claudeās
attempt. Itās also actually really good.
So itās worked out that we need internal
pull-ups. Itās worked out that the
charging pins are active low. Itās got
the RGB pins. Itās got the how to turn
the LED on. Itās got our button key and
our boot key. Um, so thatās pretty good
as well. Itās even written us some setup
functions and some helper functions. But
in the end, I chose to go with um
Geminiās approach. So, itās given me
this nice header file. And I thought Iād
use this one. Itās quite clean. Itās
quite simple. Thereās not too much code
in here. Itās just the GPIO pins and the
mappings. So, weāve gone with that one.
So, letās actually try and make
something work. So what Iām going to do
is Iāll add in the main file to our
context and then weāll just tell the AI
what we want to do. So I want to make a
USB keyboard. Uh so weāll say when the
key is pressed and I want to send
command plus enter. So command enter is
the key combination that actually lets
us do the vibe coding. So letās send
this off and see what the agent does. So
itās going off to think.
Okay. what itās doing. It knows weāre
using platform io. Itās going to have a
look at the platform io.in file and see
what it needs to do. So, itās worked
out. Weāve got an ESP32S3.
And itās saying, āOh, thatās got native
USB hit support. Iāll help you create a
USB keyboard that sends command enter
when your key switch is pressed. So, let
me update your project to implement the
functionality.ā So, itās gone off. Itās
fixing a few things. It doesnāt need
this. It added this library and then
decided actually I donāt need it. youāve
got native support. So now itās off
updating the main.cpp. So Iām not even
going to look at the code it writes. Iām
just going to accept everything. So
letās accept that. Okay. Letās just
accept everything.
Okay. So it says itās done. So now Iām
going to check to make sure it actually
compiles. So letās see if it actually
does compile. Hopefully it will. All
right. Successful compilation. So there
we go. It tells us what itās done. So,
your USB keyboard features command enter
shortcut. Press your key to send command
enter. Got visual feedback. A blue LED
lights up briefly when you press the
key. Itās got debouncing and itās got a
status indicator. So, the green LED
flashes briefly on startup to show the
device is ready. So, letās flash it and
see what happens. Okay, so our device is
all flashed. I have this keyboard tester
here. So, letās hit the reset button.
Oh, we get the nice green flash to show
weāve initialized. Letās see if the
keyboard actually works. So, this
keyboard tester, I can just type. But
now, if I hit our button, we get command
enter being pushed. So, thatās pretty
cool. And you can see we get the little
blue LED flashing when we push the
button. So, thatās quite cool. What I
can see though is itās only momentarily
pushing command enter. So, letās fix
that. What we want to happen is when the
key is pressed, command plus enter
should be sent and held only release the
keys when the when the key is released.
See what happens. Okay, so itās going to
give us a more natural keyboard
experience. Now, whatās quite cool is
because our button is semi- workinging,
we should be able to just hit accept
using our vibe it button. So, letās try
it. Vibe it. And it works.
So itās going to check it actually
compiles. So we use our vibe bit button
again. All compiles.
Letās flash it to our device. So what
have we changed? When you press the key,
command enter is sent and held down.
While youāre holding the key, the keys
remain pressed. And when you release the
key, command entry is released. And the
blue LED should stay on while youāre
holding the key down. So letās give that
a go. Letās head over to our keyboard
tester. Letās just clear the state. And
now letās do the vibe it button. So
there we go. Thatās working. And you can
see the blue LED stays on. And command
enter remains pressed when we press. So
thatās pretty cool. Not bad at all. So
weāre not really taking advantage of our
RGB LED. Itā be quite nice to have that
showing the charging status of the
battery. So letās tell it um letās use
the RGB LED to show charging status.
Letās have red for charging and green
for fully charged key for the blue LED
for the key press indicator. So, letās
see how it handles this.
So, you can see it knows weāve got the
charging pins from our hardware
definition. So, itās going off and
modifying the code.
Okay, letās use our vibe bit button to
accept everything.
All compiles. Letās flash the firmware.
So, I can see we still have our blue
functionality, but I donāt see any LEDs
for the red and the green. So, letās
unplug.
Plug back in.
Ah, there we go. So, we have a red for
charging. So, have our blue LED. Letās
leave that charging up and see if it
eventually changes green. But meanwhile,
we could add some more functionality.
So, one thing we could do is we could
add Bluetooth support. So, Iād quite
like
to have Bluetooth support as well as
USB. What are my options? Okay, so itās
saying the ESP32S3
excellent Bluetooth support. Got several
options. Letās send it off and it will
do a bit of searching to find out what
the best way of doing is. Okay, itās
gone back with a lot of research. So we
have multiple options and I think I want
USB and B simultaneously. Um it has
picked up this library. Now I believe
this library is actually not that well
maintained and we do have out of the box
B functionality on the ESP32. So what
Iām going to say is I want um dual mode
but avoid any additional libraries. use
the built.
So, letās tell it to give us dual mode,
but use the built-in B functionality. I
donāt want to pollute my thing with too
many libraries. So, letās see what it
makes of that. Okay, so itās going to
use the built-in B functionality. So,
hopefully we should have a dual device
now. One that does both USB and
Bluetooth low energy. Letās see if this
actually works. Letās see if it actually
compiles. Itās written a lot of code.
Letās see what happens. Oh. Oh dear.
compilation errors. Letās see if it can
fix itself.
Okay, so itās trying to fix itself.
Letās see if it succeeded. Letās run the
command. So far so good. Itās linking. I
do believe itās actually built. So,
letās flash this and see what happens.
So, letās check the USB keyboard still
works. So, thatās still working.
Now, letās bring up our system settings.
So, letās see if our system settings
show any keyboards. Now, Iām not seeing
anything obvious here. Searching for
devices. Letās try um switching off and
on again. Still searching. Nothing yet.
So, do we have any instructions? Has it
told us anything to do?
So, weāve uploaded.
So, I donāt think itās pairing. So, plug
into the computer. USB C cable
recognizes keyboard. Works instantly. No
pairing require required.
Um, weāre not seeing any Bluetooth
devices showing up though. I donāt see
any nearby devices. So, letās tell it.
So, itās going off to check its
implementation. Letās see if it can make
it work. Okay. So, itās made some
changes. Letās do the upload. All right.
Then, letās have a look. Oh, Bluetooth
device via keyboard. Let us connect.
Come on. Are you connecting?
I think weāre connected.
Letās see.
Iāve got it plugged into USB right now.
So, letās disconnect
our USB connection. Iāve got a battery
connected. Is it going to work? Oh, it
doesnāt work. What a shame. So, letās
see. Is it actually connecting? I donāt
know if it is. Yeah, itās not
connecting.
Letās see if it can troubleshoot it.
Okay, so itās doing some more stuff.
Letās um letās run this. See what
happens. Accept everything.
So, it all compiles.
Letās flash the device and see if we
finally get something that works. Okay,
so weāre flashed. Going to try a
complete power cycle just to check.
So, weāre on.
Letās have a look. See if it shows up.
Not seeing anything obvious. Well,
thatās not very promising, is it? Weāre
not seeing any Bluetooth devices nearby.
So, weāre not having much joy with the
current code, but letās give it a
suggestion. Why donāt we give it a
library that I know definitely works?
Why donāt you try this library? Hereās
some sample code.
Okay, letās send it off to do that. Iām
determined this is going to work. Okay,
so itās adding the library now. Itās
going to rewrite our code and hopefully
our new code will work. Fortunately, our
USB keyboardās still working, so I can
use my Vibe key quite nicely. So, letās
see if this actually works. Letās flash
the firmware. Okay, so weāre all
flashed. Hit the reset button. Fingers
crossed. Oh, Bluetooth device. Letās
connect.
Come on. Oh. Oh, weāre connected. Weāre
connected. Letās check the old um
keyboard tester. Whereās my keyboard
tester gone? Got so many windows open.
Ah, key test. So,
thatās with the USB connected. Letās
disconnect our USB and see if our
Bluetooth works. It works.
We vibecoded our USB and Bluetooth key.
Fantastic. It actually worked quite
well. A few um missteps in the Bluetooth
setup. And I have noticed the LED. If I
plug this back in,
I should be seeing an red LED when itās
charging. So, letās just make sure
thatās working. Check that the charging
and blue charged indicator is working.
flashing red for charging, green for
really charged. Right, if this works, we
will stop because I think weāve got
something quite successful. Iām pretty
pleased with that. Weāve uh vibed up a
completely working um bit of code that
does a USB keyboard and it does a
Bluetooth keyboard. Had to give it a few
hints. So, I had to tell it what library
to use and give it some sample code, but
Iāve not actually looked at any of the
code itās generated and Iāve not had to
debug any of it or fix any of it. So,
Iām pretty amazed by that. Um, so letās
uh use our vibe bit key to apply all the
changes. So, just accept that. Okay,
letās make sure it builds. Okay, so that
built.
Oh, letās uh weāre running out of
requests. Iām Iām hitting it too hard.
The AI is getting upset. Uh, but it
built. So, letās um Oh, itās doing some
more. Itās adding some debugging for us.
Might be useful. Donāt know.
There is one thing with the S3. Uh, when
youāre using USB, the serial thing
doesnāt work out of the box, but um I
think weāll Yeah, weāll leave it there.
I could ask it to fix that, but Iām
going to flash the firmware and weāll
see how well this works. So,
letās flash the firmware and weāll see
if our LEDs actually show the right
status. Okay, so letās reset.
Okay, red flashing LED indicates battery
charging. Um, letās check that the
keyboard still works. Whereās my
keyboard tester gone? There we go.
Keyboard tester.
Yep. So, the keyboard tester still
works. Letās unplug. Make sure the USB
uh the BLE connection works. Yes, BLE
connection still works. Amazing. So, I
think we got a pretty fully functional
um bit of kit here. So, not bad. Iām
pretty pleased with that. Not bad at
all.
So, yeah, we vibe coded up a fantastic
bit of kit. Thanks for watching. I will
uh see you in the next