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
To make my ESP32 ZX Spectrum touch keyboard work even better I needed to make every single key completely independent.
So I need 40 touch pads. The ESP32-S3 only has 14 touch pins. For the current version I’ve been using a matrix approach. Which only needs 13 touch pins - which we’ve used for 5 columns and 8 rows.

This actually works really well, but there is a problem. We detect some combinations of keys. And the ZX Spectrum relies on a lot of key combinations for BASIC - symbol shift being one of the most critical.
Also, a lot of games need to detect multiple key presses - if you can’t do this then you get some quite annoying behaviour.
So, let’s dig into how touch works.
If you hook up a touch pad to an oscilloscope you can see this pattern.

Zooming in on this, we can see this saw tooth pattern:

The way touch detection works is that the ESP32 times how long it takes to charge the pad up and down between two known voltages. The capacitance of the pad determines this. If we have a finger near or on the touch pad the capacitance increases - and thus the time increases.
So, it’s just an analog signal. This got me thinking, there are some analog multiplexer ICs that have been around forever - the 4051 series of chips. There’s a whole bunch of manufacturers of these chips, so they are dead cheap (one could say, they are cheap as chips!).

The only issue with this is that there is a quite high “on” resistance with these multiplexers.

Will touch still work when there’s a resistance in series with it? My quick initial test seems to indicate that it will - this is with a 270ohm resistor and touch seems to work perfectly.

So, I ordered some breadboard friendly versions and cooked up this contraption:

And it works! It works even better than I could possible imagine. It’s really cool.
With five of these ICs we can get 40 individual touch pads! And the BOM cost is only around $1! Amazing!

I sent this off to PCBWay - and the boards came back a week or so ago. And - it works! The new keyboard is really good. We can detect every single combination of keys and it’s really responsive. Scanning the whole keyboard takes around 20ms.
We’re pretty much ready for production now - this was the last big challenge to solve.

Related Posts
Esp32 s3 zx spectrum - In a bid to quench my nostalgia and flex my ESP32 chops, I managed to get a ZX Spectrum emulator running on my ESP32-TV board! Then, spurred on by PCBWay's new full color silk screen service, I pursuit the audacious task of recreating the ZX Spectrum's iconic keyboard. It's been quite the joyride - wrangling touch pins, shrinking screens and creating a thing of beauty on PCB. It's not quite ready for the spotlight, but keep an eye on my newsletter for more eagerly-awaited updates. It's like the Spectrum is reborn!
Crowdfunding Success - Was it worth it? - I embarked on a thrilling adventure of turning a nifty idea into a tangible product — the ESP32 Rainbow, a Sinclair Spectrum-inspired gadget that merges retro vibes with modern tech. With the brains of an ESP32-S3, capacitive touch, a built-in display, and some snazzy UV silk screen printing, it's a little marvel that got crowdfunded successfully. But, oh boy, was the journey enlightening — from grappling with pricing conundrums and the bureaucracy of certifications to the harrowing odyssey of international shipping. While it didn't line my pockets with gold, seeing people enjoy something I created is worth all the sweat and jitters. Would I do it again? Well, maybe if lightning strikes twice with another great idea.
Just Vibe It - I crafted a whimsical single key keyboard ideal for vibe coding! It's powered by a TPS2117-equipped PCB, offering slick battery-to-USB switching. Tried out low profile Cherry switches, but faced some stabilizer challenges with bigger keycaps. Check out the final fun in my GitHub repo and video!
Old school tape loading - If you're anything like me, the nostalgic screeches of ZX Spectrum games loading might bring a smile to your face. I've taken a trip down memory lane by working on my own tribute to this iconic machine—introducing the ESP32 Rainbow. It’s on Crowd Supply, where we're closing in on full funding! This blog post walks you through the journey of harnessing audial data to load games directly into my emulator—faster and more reliable than those temperamental cassette decks from our childhood.
Minimalist Microcontroller: Building a Bare-Bones Dev Board - In a thrilling DIY endeavour, I attempted to build the most minimalist ESP32 dev board possible. Diving deep into the schematic of the ESP32 S3 WROOM module, I chopped out the non-essentials and whittled our needs down to bare bones. The experiment saw me juggling USB data lines and voltage regulators, waving goodbye to an array of capacitors and connectors and boldly embracing the simplicity of direct connections. Despite a few hitches, the miniature Frankenboard came alive, proving that sometimes less is more...at least in the world of microcontrollers.
Related Videos
ESP32 - 40 Independent touch pins! - Wow! I'm absolutely thrilled with the results of this video - I've been experimenting with my ESP 320x Spectrum board and its touch Matrix keyboard. Had a bit of trouble with combined button inputs, so I took a deep dive into how touch works and discovered these old, but gold, ICs. After some testing, they turned out to be a perfect solution to my multiplexing problem! I then got a new board design shipped from PCB way - looks awesome and it didn't break the bank. Can't believe how responsive the keyboard is! Got the 'Hello World' program up and running, and even played Manic Miner. The final board's all set - can't wait to get this on sale! And keep watching because I've got some interesting plans for this expansion port!
ESP32-S3 ZX Spectrum - Full Color Silk Screen is really cool! - Super stoked to share this creation – an ESP32 ZX Spectrum emulator! Although it's still very much a proof-of-concept, it's looking pretty rad. I've got the classic games like Manic Miner, and yes, you can program in basic too! In perfect Sinclair fashion, I'm planning on selling this key piece of nostalgia for just £99. Work still needs to be done before the production phase, but rest assured, I'm meticulously working out the kinks, including tweaking the keyboard to ensure even better user experience. And on the technical side - a single ESP32S3 runs the show and we’ve multiplexed the keys exactly like the OG Spectrum. It's been great fun designing this piece of kit with the new full color silk screen printing from PCB way. Stay tuned for further updates!
Taking KiCad Silk Screen to the Next Level! - Take a peek at how my ESP 32 ZX Spectrum project is coming along! We're funded on Crowd Supply, ordering components, and adding a cool silk screen design to our PCB. Using tools like KiCad and Affinity Designer, I've jazzed up the back of the board with detailed graphics. It's been an exciting journey, making adjustments and ensuring everything works perfectly before ramping up production. If you haven't yet, head over to Crowd Supply and support the ESP 32 Rainbow project!
But does it run DOOM? ESP32 ZX Spectrum update - All right, it's time for an update on my ESP Rainbow, the ZX Spectrum emulator with stunning full-color silk screen printing. I've been testing the latest boards, and PCB Way did a fantastic job. The enhancements include upgraded firmware, a 128k ZX Spectrum emulator, and a new 2-watt speaker replacing the old 7-watt buzzer. You can enjoy great sound with PWM and even play 128k games like The Never Ending Story. I've also added a snapshot feature and ported my video player over. Hardware upgrades include new capacitors and a slick power control chip for seamless battery and USB mode switching. We're gearing up for a commercial release, hopefully by Christmas, so stay tuned. And yes, it does run Doom! [Laughter]
A Vibe Coded One-Button Mechanical Keyboard - ESP32-S3 USB+BTLE - 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!
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