ESP32 S3 UNO - Touch Sensor
This ESP32 S3 Uno touch sensor tutorial shows you how to connect a touch button to the ESP32 S3 Uno form board and read it with Arduino code. A touch switch works like a normal push button, but you only tap a smooth pad. That is why touch lamps and many modern devices use it for a cleaner look.
In this tutorial, you will:
- Learn the pinout of a capacitive touch sensor module
- Wire the touch sensor to the ESP32 S3 Uno
- Read the touch button state with digitalRead()
- Detect the moment the sensor is touched or released
- Print the results on the Arduino IDE Serial Monitor

Hardware Preparation
| 1 | × | ESP32 S3 Uno-form Board | |
| 1 | × | USB Cable Type-A to Type-C (for USB-A PC) | |
| 1 | × | USB Cable Type-C to Type-C (for USB-C PC) | |
| 1 | × | Touch Sensor | |
| 1 | × | Jumper Wires |
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Touch Sensor
Before you write any code, it helps to know what the module does. A touch sensor module has a small chip that feels the change when your finger comes close to the pad. It then turns that change into a clean digital signal that your board can read.
Pinout
The touch sensor module has only three pins, so wiring is quick.
| Pin | What It Does |
|---|---|
| GND | Connect to GND (0V) |
| VCC | Connect to 3.3V or 5V. With the ESP32 S3 Uno, use 3.3V |
| SIGNAL | Gives LOW when untouched and HIGH when touched. Connect it to an input pin of the ESP32 S3 Uno |

How It Works
The logic is very simple. When nothing touches the pad, the SIGNAL pin stays LOW. When you put your finger on the pad, the SIGNAL pin goes HIGH, and it stays HIGH until you lift your finger.
ESP32 S3 Uno - Touch Sensor
You connect the SIGNAL pin of the sensor to one input pin of the ESP32 S3 Uno. Then your code reads that pin. A HIGH value means someone is touching the sensor, and a LOW value means nobody is.
ESP32 S3 Uno Pinout
The image below shows the pinout of the ESP32 S3 Uno form board. Use it to find the Uno header pin D7 and its GPIO number before you connect the wires.

Wiring Diagram
Only three wires are needed. The SIGNAL pin goes to D7, which is GPIO14 on the ESP32 S3 Uno.

This image is created using Fritzing. Click to enlarge image
| Touch Sensor Pin | ESP32 S3 Uno Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SIGNAL | D7 (GPIO14) |
WARNING
The ESP32 S3 Uno pins work at 3.3V and are NOT 5V tolerant. If you power the touch sensor from 5V, its SIGNAL pin also gives 5V when touched, and this can damage GPIO14. Power the sensor from the 3.3V pin. If you must use 5V, put a voltage divider or a level shifter on the SIGNAL line.
How To Program For Touch Sensor
Reading a touch sensor takes only two steps. You set the pin as an input once, then you read it as often as you need.
Step 1: Set the pin as an input
Call pinMode() in setup(). In this example the sensor is on D7, so the code uses GPIO14.
Step 2: Read the pin state
Use the digitalRead() function to get the state of the pin. It returns HIGH or LOW.
※ NOTE THAT:
You will usually use the touch sensor in one of two ways:
- Act on the level. Do one thing while the input is HIGH and the opposite thing while it is LOW.
- Act on the change. Do something only at the moment the input goes from LOW to HIGH (or from HIGH to LOW).
Choose the way that fits your project. For example, to control an LED: if the LED should be ON only while your finger is on the pad, use the first way. If each tap should switch the LED ON or OFF, use the second way.
Touch Sensor - ESP32 S3 Uno Code
The two sketches below cover both ways of using the sensor. The first one shows the raw state, and the second one reports only the touch and release events.
Reads the value from the touch sensor and print to the Serial Monitor
This sketch sets GPIO14 as an input and reads it again and again inside loop(). Each reading, 0 or 1, is printed on its own line, so you can watch the value change as you touch the pad.
Detailed Instructions
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Copy the code above and paste it into Arduino IDE.
- Upload the code by clicking the Upload button.
- Open the Serial Monitor and set the baud rate to 9600.
- Test it by putting your finger on the sensor and then taking it away.
- Check the output on the Serial Monitor.
- Tip: Most touch modules have a small LED that lights up when touched. If the LED reacts but the Serial Monitor does not, check the SIGNAL wire.
Detects the sensor is touched or released
This sketch remembers the last reading and compares it with the new one. When the state goes from LOW to HIGH, it prints that the sensor is touched. When it goes from HIGH to LOW, it prints that the sensor is released, so you get one message per event instead of a stream of numbers.
Detailed Instructions
- Copy the code above and open it in Arduino IDE.
- Upload the code to the ESP32 S3 Uno with the Upload button.
- Touch the sensor and keep your finger on it.
- Check the Serial Monitor.
- Lift your finger off the sensor.
- Check the Serial Monitor again.
- Tip: Use this event style when one tap should start one action, such as toggling an LED or playing a sound.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
The video demo plays a song on a buzzer when you touch one of two touch sensors, and blinks two LEDs in time with the notes. It uses the code below:
FAQ
Should I power the touch sensor with 3.3V or 5V on the ESP32 S3 Uno?
Use 3.3V. The touch module works fine at 3.3V, and its SIGNAL output then matches the 3.3V logic of the ESP32 S3 Uno. At 5V, the SIGNAL pin outputs 5V when touched, which is not safe for the ESP32 S3 Uno pins.
Which pin should I use for the touch sensor?
Any normal digital pin works, because the sensor gives a simple HIGH or LOW. This tutorial uses D7 (GPIO14). In code, always write the GPIO number, not the Uno label. Avoid D0 and D1 (USB serial) and the boot strapping pins D6 (GPIO3) and D9 (GPIO46).
Can I use the ESP32 S3 Uno built-in touch pins instead of a touch module?
Yes, the ESP32 S3 Uno chip has its own capacitive touch inputs that you read with touchRead(). But you then need to pick a threshold and handle noise yourself. The touch module is easier for beginners, because it already gives a clean HIGH or LOW signal.
Is the code different from the Arduino UNO R4 version?
The logic is exactly the same. Only the pin number changes: D7 is pin 7 on the UNO R4, but on the ESP32 S3 Uno you write 14 (GPIO14) in code. In the demo sketch, tone() also works on the ESP32 S3 Uno with the esp32 core.
What if my project needs more pins than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs: GPIO15 and GPIO16 (I/O, PWM, analog), GPIO45 and GPIO35 to GPIO42 (I/O, PWM), and GPIO47/GPIO48 (output only, PWM). Solder pin headers to use them and write the GPIO number in code. For extra touch sensors, GPIO35 to GPIO42 or GPIO15/16 are good picks. Do not use GPIO47/GPIO48 for touch sensors, because they are output only. Also note two warnings. First, GPIO47/GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in Arduino IDE | USB driver missing or board not in upload mode | Install the CP210x or CH340 driver, try another USB cable, or hold BOOT while you press RESET |
| Upload fails or board does not start | Wrong board selected | Choose ESP32S3 Dev Module and the right COM port |
| Serial Monitor shows strange characters | Wrong baud rate | Set the Serial Monitor to 9600 for the first two sketches and 115200 for the demo |
| Value always 0 | SIGNAL wire on the wrong pin or loose | Connect SIGNAL to D7 (GPIO14) and check that the code uses 14 |
| Value always 0 and the module LED is off | Sensor has no power | Check VCC to 3.3V and GND to GND |
| Value changes randomly with no touch | SIGNAL pin not connected so the input floats | Push the jumper wires in firmly and check every wire |
| Sensor triggers by itself | Pad is near metal or a noisy power line | Move the sensor away from metal and power it from the 3.3V pin |
| Board resets or a pin gets hot | Sensor powered from 5V so SIGNAL outputs 5V | Power the sensor from 3.3V or add a voltage divider on SIGNAL |