ESP32 WROOM32E touch interrupt issue
Posted: Fri Jan 24, 2025 10:01 pm
Having issues with touch interrupts on WROOM 32E, problem does not appear on devkit with WROOM 32D.
Using arduino ide 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 a devkit i have with WROOM 32D but the issue shows up on my new hardware with WROOM 32E.
Code used:
/*
This is an example how to use Touch Intrrerupts
The bigger the threshold, the more sensible is the touch
*/
#if CONFIG_IDF_TARGET_ESP32P4
int threshold = 0; // when 0 is used, the benchmarked value will be used
#else
int threshold = 29;
#endif
bool touch1detected = false;
bool touch2detected = false;
void gotTouch1() {
touch1detected = true;
}
void gotTouch2() {
touch2detected = true;
}
void setup() {
Serial.begin(115200);
delay(1000); // give me time to bring up serial monitor
Serial.println("ESP32 Touch Interrupt Test");
touchAttachInterrupt(T4, gotTouch1, threshold);
touchAttachInterrupt(T5, gotTouch2, threshold);
}
void loop() {
if (touch1detected) {
Serial.println("Touch 1 detected");
delay(300);
touch1detected = false;
}
if (touch2detected) {
Serial.println("Touch 2 detected");
delay(300);
touch2detected = false;
}
}
Using arduino ide 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 a devkit i have with WROOM 32D but the issue shows up on my new hardware with WROOM 32E.
Code used:
/*
This is an example how to use Touch Intrrerupts
The bigger the threshold, the more sensible is the touch
*/
#if CONFIG_IDF_TARGET_ESP32P4
int threshold = 0; // when 0 is used, the benchmarked value will be used
#else
int threshold = 29;
#endif
bool touch1detected = false;
bool touch2detected = false;
void gotTouch1() {
touch1detected = true;
}
void gotTouch2() {
touch2detected = true;
}
void setup() {
Serial.begin(115200);
delay(1000); // give me time to bring up serial monitor
Serial.println("ESP32 Touch Interrupt Test");
touchAttachInterrupt(T4, gotTouch1, threshold);
touchAttachInterrupt(T5, gotTouch2, threshold);
}
void loop() {
if (touch1detected) {
Serial.println("Touch 1 detected");
delay(300);
touch1detected = false;
}
if (touch2detected) {
Serial.println("Touch 2 detected");
delay(300);
touch2detected = false;
}
}