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: 56
- Joined: Sat Jan 18, 2025 2:31 pm
Re: ESP32 WROOM32E touch interrupt problem
ESP32 Board has 10 built-in capacitive touch pins, which generate an electrical signal when someone touches these pins. These ESP32 touch pins are normally used to wake up the board from deep sleep mode.
You can test with some other pins. Since you observed this issue only with WROOM-32E, you can verify the raw touch values in the loop instead of relying on interrupts. Here is a sample code:
https://www.theengineeringprojects.com/ ... ensor.html
You can test with some other pins. Since you observed this issue only with WROOM-32E, you can verify the raw touch values in the loop instead of relying on interrupts. Here is a sample code:
https://www.theengineeringprojects.com/ ... ensor.html
-
- Posts: 6
- Joined: Fri Jan 24, 2025 9:40 pm
Re: ESP32 WROOM32E touch interrupt problem
I am well aware that the esp32 has 10 capacitive touch pins, i have checked the touch read values on all the relevant pins and they function appropriately. The problem is related to the touch interrupt function which i require to work for my application i can not simply use the touchread function instead. The fact that the exact same code works properly on older modules should make it obvious that there is either a hardware issue with the new modules or perhaps an issue with compatibility of the arduino ide board packages with the newer wroom 32e modules.
If someone with access to a wroom 32e module could try this out and confirm that they either do or do not encounter this problem it would be very helpful.
I am going to try to get espressif ide working and try and see if i have the same problem.
If someone with access to a wroom 32e module could try this out and confirm that they either do or do not encounter this problem it would be very helpful.
I am going to try to get espressif ide working and try and see if i have the same problem.
-
- Posts: 6
- Joined: Fri Jan 24, 2025 9:40 pm
Re: ESP32 WROOM32E touch interrupt problem
Was able to get the touch pad interrupt example in the esp ide working on a devkit with WROOM 32E and confirmed that the interrupt issue is not present when programmed in esp ide.
I assume this means there is something wrong the esp32 boards packages in the arduino ide? where would be the best place for me to post this to get help fixing it?
I assume this means there is something wrong the esp32 boards packages in the arduino ide? where would be the best place for me to post this to get help fixing it?
Who is online
Users browsing this forum: No registered users and 66 guests