ESP32 Touch Interrupt Not Firing
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 Touch Interrupt Not Firing. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 touch interrupt configured with touchAttachInterrupt does not trigger.
Quick Fix
Wrong
touchAttachInterrupt(4, onTouch, 40); // Threshold too low
Interrupt never fires or fires continuously from noise.
Right
volatile bool touched = false;
void IRAM_ATTR onTouch() {
touched = true;
}
int baseline = touchRead(4);
int threshold = baseline * 0.7;
touchAttachInterrupt(4, onTouch, threshold);
void loop() {
if (touched) {
touched = false;
Serial.println("Touch detected");
}
}
Touch detected (fired when finger touches the pad)
Prevention
Calculate threshold dynamically from baseline. Set threshold to 70-80% of idle value. Keep ISR minimal (set volatile flag). Debounce in loop(). Use RTC interrupt for wake-from-sleep.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro