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

Magic at Your Fingertips: Mastering the TTP223 Sensor & ESP32 Touch Capabilities

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

  1. TTP223 Capacitive Touch Sensor Module - https://s.click.aliexpress.com/e/_c43IuMar
  2. ESP32 Development Board (NodeMCU / DevKit V1) - https://s.click.aliexpress.com/e/_c3Zhn93N
  3. 5V Relay Module - https://s.click.aliexpress.com/e/_c3ounnfz
  4. Jumper Wires & Breadboard - https://s.click.aliexpress.com/e/_c3bd1rUX
  5. Professional Soldering Station - https://s.click.aliexpress.com/e/_c2IGInsB
  6. Fumes Extractor - https://s.click.aliexpress.com/e/_c4Kf1iKX
  7. Beginner Soldering Kit - https://s.click.aliexpress.com/e/_c2QlchKT
  8. Digital Microscope - https://s.click.aliexpress.com/e/_c2IiuTEF
  9. Digital Multimeter - https://s.click.aliexpress.com/e/_c3S9Zb4J


Understanding and Configuring the TTP223 Module

MVI_2816.MP4.00_00_01_26.Still002.jpg
MVI_2816.MP4.00_00_07_16.Still001.jpg

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.


  1. Default (No Jumpers): Acts like a push button. Touch turns the output ON, release turns it OFF.
  2. Connect Pad B: Turns it into a toggle switch. One touch turns output ON, next touch turns it OFF.
  3. 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

MVI_2818.MP4.00_00_48_28.Still001.jpg
MVI_2819.MP4.00_00_16_04.Still001.jpg

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)

MVI_2820.MP4.00_00_06_26.Still001.jpg
MVI_2821.MP4.00_00_37_24.Still001.jpg

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

MVI_2822.MP4.00_00_15_05.Still001.jpg
MVI_2822.MP4.00_01_36_18.Still002.jpg

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.

  1. 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.
  2. 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

2026-01-23 17-11-39.mp4.00_01_53_19.Still001.jpg

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!

MVI_2824.MP4.00_00_38_17.Still001.jpg
video.00_00_26_13.Still001.jpg

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!