Having issues with touch interrupts on WROOM 32E, problem does not appear on devkit with WROOM 32D.
Using arduino ide v2.3.4 for programing, using the provided example for touch interrupt with pins T4 and T5.
Both touch pins are working and trigger interrupt when touched. However when one pin is touched twice in a row and then the other pin is touched, there is an incorrect triggering of the first pin as well. For example if pins touched are T4, T4, and then T5 (with appropriate delay) the output will be:
ESP32 Touch Interrupt Test
Touch 1 detected
Touch 1 detected
Touch 1 detected
Touch 2 detected
This problem did not occur on older esp32 modules including devkits i have with WROOM 32 and WROOM 32D modules but the issue shows up on my new custom hardware with WROOM 32E. I have tried out several boards with WROOM 32E including two brand new devkits purchased from amazon with WROOM 32E modules and the problem persists.
I also tried using the iram_attr on the interrupts and tried declaring all involved variables as volatile, static and also static volatile just to see if it had any effect and nothing changed. Baseline touchread value is approximately 50 on my board and with pin touched it is approx 15 so threshold is set to 30. Confirmed it is not a cross triggering problem as the touchread value for each pin does not vary significantly when the other pin is touched.
Not sure what is going on here as it should not be possible to flag both touch1detected and touch2detected within 300ms unless i'm missing something?
Code used:
int threshold = 30;
unsigned long lastTouch1Time = 0;
unsigned long lastTouch2Time = 0;
bool touch1detected = false;
bool touch2detected = false;
void gotTouch1() {
if (millis() - lastTouch1Time > 300) {
touch1detected = true;
lastTouch1Time = millis();
}
}
void gotTouch2() {
if (millis() - lastTouch2Time > 300) {
touch2detected = true;
lastTouch2Time = millis();
}
}
void setup() {
Serial.begin(115200);
delay(2000); // Stabilization delay
Serial.println("ESP32 Touch Interrupt Test");
touchAttachInterrupt(T4, gotTouch1, threshold);
touchAttachInterrupt(T5, gotTouch2, threshold);
}
void loop() {
if (touch1detected) {
Serial.println("Touch 1 detected");
touch1detected = false;
}
if (touch2detected) {
Serial.println("Touch 2 detected");
touch2detected = false;
}
}
ESP32 WROOM32E touch interrupt problem
-
- Posts: 4
- Joined: Fri Jan 24, 2025 9:40 pm
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 10 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.