I’m building a lighting control system for a motorhome using ESP32 and MQQT. I have all the remote control stuff working well, but controlling a light you’re standing next to with a network connected device is not handy. I decided touch control for turning on and dimming the lights would be great. Each ESP32 controls 4 channels of lighting via mosfet boards.
If I initiate a single channel of touch control it works fine. But when I add more the touch channels interfere with each other and become glitchy. I tried a version of debouncing to distinguish real touches from glitches, but there’s enough noise to ultimately overcome even the most aggressive delay. I read that the touch pins freely oscillate and touching one changes the frequency. It seems likely that the touch wires are acting like antennas, sending signals to each other.
Does anyone have any useful experience in making these sensors reliable?
The code I’m using is very simple, this version has no “debounce” filter since they didn’t work well enough.
//LED1 touchValue1 = touchRead(touchPin1); // check if the touchValue is below the threshold if(touchValue1 < threshold){ if (incLed1<254){ incLed1 = incLed1+4; ledcWrite(ledChannel1, incLed1); } if (incLed1>254){ incLed1=0; } delay(30); }
After more than a bit of research, I decided the built-in touch control is inherently flaky–too flaky for what is essentially a fallback way of controlling the lights. I tried using shielded cable and larger sensor plates, and that helped, but over a long enough stretch of time the lights creep slowly up. I’m going to experiment with independant touch sensors based on the ttp233b IC.
For anyone looking to use the touch sensors on an ESP32 for something real world, this article might be helpful. For me it showed so many potential sources for error that I dismissed the utility, but someone more persistent could use this information to design a more reliable connection and perhaps fix some of the noise sources in code. https://nick.zoic.org/art/esp32-capacitive-sensors/