Skip to content

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

### What threshold should I use for touch interrupt?

Set threshold = baseline * 0.7 (for FALLING mode). Higher threshold = less sensitive. Start at 0.7 and adjust based on testing.

Can I use touch interrupt during deep sleep?

Yes. Configure touch interrupt with touch_pad_isr_register() and enable touch wake with esp_sleep_enable_touchpad_wakeup().

How many touch interrupts can I use?

All 10 touch channels can generate interrupts independently. Each can have a different threshold.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro