DIY Touch Control: Using TTP223 Sensors & ESP32 Touch Pins
by taste_the_code in Circuits > Sensors
623 Views, 2 Favorites, 0 Comments
DIY Touch Control: Using TTP223 Sensors & ESP32 Touch Pins
Forget the click! This guide will show you how to add a modern, sleek touch interface to your electronics projects.
We'll explore two fantastic methods: using a cheap and versatile TTP223 touch sensor module, and harnessing the built-in superpower of the ESP32 microcontroller.
Supplies
- TTP223 Capacitive Touch Sensor Module - https://s.click.aliexpress.com/e/_c43IuMar
- ESP32 Development Board (NodeMCU / DevKit V1) - https://s.click.aliexpress.com/e/_c3Zhn93N
- 5V Relay Module - https://s.click.aliexpress.com/e/_c3ounnfz
- Jumper Wires & Breadboard - https://s.click.aliexpress.com/e/_c3bd1rUX
- Professional Soldering Station - https://s.click.aliexpress.com/e/_c2IGInsB
- Fumes Extractor - https://s.click.aliexpress.com/e/_c4Kf1iKX
- Beginner Soldering Kit - https://s.click.aliexpress.com/e/_c2QlchKT
- Digital Microscope - https://s.click.aliexpress.com/e/_c2IiuTEF
- Digital Multimeter - https://s.click.aliexpress.com/e/_c3S9Zb4J
Understanding and Configuring the TTP223 Module
The TTP223 is a tiny breakout board with three pins: VCC (power), GND (ground), and OUT (signal). On the back, you'll find two small solder pads labeled A and B. These let you configure its behavior.
- Default (No Jumpers): Acts like a push button. Touch turns the output ON, release turns it OFF.
- Connect Pad B: Turns it into a toggle switch. One touch turns output ON, next touch turns it OFF.
- Connect Pad A: Changes the starting state when power is applied.
You can mix these! Use a dab of solder to bridge the pads you want.
This flexibility lets you decide if your touch button is momentary or latching right from the start.
Wiring the TTP223 to Your Microcontroller
This is as simple as connecting a button.
Power the module from your board's 3.3V or 5V pin (it works with both). Connect its ground to your board's ground.
Finally, connect the module's OUT pin to any digital input pin on your microcontroller, like GPIO 14 on an ESP32. In your code, you'll just read that digital pin to check if it's HIGH or LOW, exactly like reading a normal push button.
Modifying Sensitivity (Optional)
The sensor is quite sensitive, which is great if you want to hide it behind plastic.
If it's too sensitive, you can reduce sensitivity by soldering a small capacitor (like 10-50pF) across the A and B pads.
To increase sensitivity for hidden panels, solder a wire to the touch pad on the front and shape it into a coil or attach it to a larger metal surface inside your case.
Using the ESP32's Built-In Touch Pins
If you're using an ESP32, you can skip the external module! The ESP32 has 10 pins with special touch sensing hardware. Pins like GPIO 4 (TOUCH0), GPIO 15 (TOUCH3), and GPIO 27 (TOUCH7) can sense when you touch them.
- Wire it up: Connect a jumper wire directly from one of these pins (e.g., GPIO 4) to your touch surface, a piece of foil, a metal knob, or even the end of the wire itself.
- Key Difference: Unlike the TTP223, you must make direct contact with the metal. Touching the wire's insulation won't work.
The Arduino Code for ESP32 Touch
The code uses special touchRead() functions. Here is a simple example to get you started. This code reads three touch pins and toggles an onboard LED when any are touched.
Full code from the example is available here.
Build Your Project!
Now you have two powerful tools. Use the TTP223 for a ready-made, configurable touch button in any project. Use the ESP32's pins when you want a direct, low-part-count solution. Imagine a touch-activated lamp, a secret toggle hidden behind a bookcase, or a touch-sensitive control panel for your smart desk.
Resources & Next Steps
I hope this guide helps you add a new dimension to your projects! For a visual walkthrough of everything in this guide, including more detailed demos of the TTP223 configurations, you can check out my full video tutorial on YouTube or even consider subscribing so you do not miss the future projects.
If you're looking to purchase the components used here, like the versatile TTP223 sensors, I've compiled a list of parts. Using these special affiliate links to make your purchase supports the channel at no extra cost to you, and helps me buy new parts to create more guides like this one.
Happy making, and I can't wait to see what you build with touch control!