Capacitive Touch Sensing
Your ESP32 hides a superpower that a plain Arduino Uno does not have: several of its pins can feel your finger through a wire, a piece of foil, or even a piece of fruit — no button, no switch, no moving parts required. In this lesson you will learn exactly how that works, how to read a touch pin, how to turn raw numbers into a reliable "touched / not touched" decision, and how to build real touch buttons.
The Big Idea & Your Learning Goals
Big idea: A touch pin is really a tiny "electricity storage" measuring circuit. When your finger comes close, it changes how much electricity the pad can store. The ESP32 measures that change and reports it as a plain number. Your finger makes the number go down. That is the whole trick.
By the end of this lesson you will be able to:
- Explain what capacitance is in everyday words and why your body changes it.
- Name the ESP32 touch channels T0–T9 and the GPIO each one lives on.
- Read raw values with
touchRead()and watch them drop when you touch. - Choose and calibrate a threshold that works for your wire length and the room's humidity.
- Build touch buttons out of foil, fruit, or pencil graphite.
- Debounce a touch and build a touch-toggled LED.
- Understand how a touch can wake the ESP32 from deep sleep.
- Troubleshoot unstable readings like a pro.
What Is Capacitance? (Plain English)
Capacitance is a measure of how much electric charge something can hold for a given push of voltage. Think of it as the "size of an electric bucket". A big bucket holds a lot of water before it fills; a component with big capacitance holds a lot of charge before its voltage rises.
Two pieces of metal separated by a gap form a capacitor. The bigger the metal, or the closer the two pieces, the more charge they can store — the bigger the bucket.
Here is the key fact for this whole lesson: your body is mostly salty water, and salty water conducts electricity. When your finger comes near the pad, your body acts like a second, huge metal plate connected to the ground of the world. That makes the pad's bucket suddenly much bigger.
touchRead() number gets smaller.