Simple ESP32 project that uses a 🟢built-in touch pin (GPIO 2) to detect touch and lights an 🔴external LED (on GPIO 5) when the touch value drops below a defined threshold.
- Uses ESP32's native
touchRead()API (no external sensor needed) - LED turns ON when touch is detected (value ≤ threshold)
- Real-time monitoring via Serial at 115200 baud
- Adjustable sensitivity via
TOUCH_THRESHOLDvariable
- ESP-WROOM-32 development board
- Red LED light
- 1 Female-Male Jumper Wire
- 2 Female-Female Jumper wires (To connect from the ESP-WROOM-32 to the LED)
- USB-A to USB-C Cable 1m(Data Transferring Cable)
- Touch electrode: bare wire connected directly to GPIO 2 (P2)
- LED circuit:
- LED anode ➡️ GPIO 5 🔴
- LED cathode ➡️ GND 🟤
Note: Tune
TOUCH_THRESHOLDto match your setup. I used 350 for this project
Touch input
- Connect a jumper wire(female-male) directly to GPIO 2. This wire acts as the touch-sensitive electrode, no extra components needed. Touching the end of the wire with your finger decreases the touchRead value.
LED (with current-limiting resistor)
- Connect the LED anode (longer leg) ➡️ 🔴GPIO 5. Connect the LED cathode (shorter leg) ➡️ 🟤GND (any GND pin on the ESP32). This is a sourcing configuration (ESP32 HIGH = LED on)
- Upload the touch sensor sketch using Arduino IDE
- Open Serial Monitor (115200 baud)
- Touch the wire ➡️ LED lights up and you’ll see "TOUCH DETECTED" and an indication that the LED light has powered ON on the Serial Monitor
- Untouched: 60–120
- Touched: 20–60 (varies by board & finger contact)
The video link below will redirect you to the "Simple Electronics Tutorials" YouTube page


