Hello, I’m attempting to use the built-in touch sensing of the ESP32-S3 for a simple button, but am getting no response, even with the touch threshold set very low. I am positive I have the pin mapping correct because when I set up the input as a pushbutton, then momentarily ground the wire, it works just fine. However, when configured as touch I get no response. I’ve tried touching the GPIO pin, a wire, and a copper tape pad soldered to a wire, with no luck. I’ve confirmed the GPIO number I am using supports touch per the SoC datasheet, and tried a few different inputs just in case.
I am using an ESP32-S3 and WLEDMM v0.14.1-b32.41.dev “Fried Chicken” firmware. The specific binary is WLEDMM esp32S3_8MB_B.bin.
Any help or suggestions would be greatly appreciated, thank you!
Hi #dedehai
I’m using the same ESP32-S3 with aircoookies v0.15 release: https://github.com/Aircoookie/WLED/releases/download/v0.15.0/WLED_0.15.0_ESP32-S3_4M_qspi.bin
I have one touch button configured on GPIO3 and a threshold of 50 set.
This works fine, but only after a push of the boards reset button.
It never works after initial power up - I always have to hit Reset for it to start working.
Can you suggest a fix?
I thought about setting a delay in the setup routine for the touch initialisation, and/or some sort of RC network to force a reset of the chip after a power on.
The latter would be easier for me, as I’ve not yet setup a dev environment to recompile the code.
Quite frustrating, as my custom light fixture works great apart from this one little ‘bug’…
It does look like it should be clear.
I mention trying another GPIO since #3 is part of the power up state decision made by the processor (run/flash/etc).
That may have some impact on what you’re trying to do.
Should be simple enough to try a different GPIO(s) to see if it’s a WLED problem or a chip design issue.
the S3 (and S2) do an initial calibration when activating the touch, if that pin is involved in the boot process then it may be way off, just a hunch.
what would help in that case is a boot-up delay, which is a compile parameter I added a while ago: -D WLED_BOOTUPDELAY=500 ; adds a delay (in ms)
Ah OK.
So, it appears after being off all night - powering up this morning, and the touch switch isn’t working again.
After a couple of power cycles - it’s randomly starts working.
So I think you’re right, it’s going to need a longer boot up delay.
What would be really good however - don’t know how easy this would be to implement - and that’s to put additional information and options in the GPIO button setup section.
Have a field that saves a value to PSRAM to use as a boot delay, should the need arise.
When ‘Touch’ is selected as a button type, then have two informational fields on the same line that shows the raw touch values for both NO touch and Touch - to aid calibration - this could be used in conjunction with a calibrate button to set the correct threshold maybe?
In the mean time, I guess I need to try and setup a dev environment to recompile a version with a bootupdelay. lol.
Any advice on this would be greatly received.
I’m on an M1 MacBookPro, and I’ve setup PlatformIO for other ESP32 dev projects in the past, but always seem to not get things quite right and it ends up taking a while for me to get it to work correctly.
you can use this to compile: https://wled-compile.github.io/
in the env. configuration (step4) add the delay: -D WLED_BOOTUPDELAY=500 ; adds a delay (in ms)
the other options to compile are: discord #bot or github codespace, VScode is not recommended unless you want to.
mmm - that’s s no go.
I put in a 1000ms delay - compiled - uploaded and configured.
All seemed OK - but I’ve had it power off for a couple of hours, and now switching back on, the touch is no longer working.
I know the ESP must be reading GPIO8 and changing presets based on what it’s seeing, as it keeps turning off the LEDs and I have the long press set to ALL OFF.
I’ve tried changing the threshold from very low to very high - no deal.
If I disable the touch input, then the light works as expected (but no touch obvs).
I’m running out of ideas now. Both the Pots I have set up on GPIO6 and 7 work just fine for speed and brightness, it’s just the touch input that’s not playing ball.
I have a 2"x1" piece of copper tape under a 3mm 3D printed bit of PLA for the touch switch, wired directly to GPIO8.
I’ve done this for numerous other projects without any issue, but those projects used ESPHome.
Where I can run some code to see the thresholds and insert that directly into the yaml.
I wrote the code for the S3, I can take a look at what it spits out on a low level if you can tell me exactly when it works and when not. It could be that it picks up too much noise on such a large “touch button” or it could be a hardware issue in combination with the analog inputs (may even be a core library issue), or … there are just too many variables at play. When I tested the touch code, it was very consistent but I did not have such large copper areas, which is not really what the touch inputs are designed for but should work anyway. So if you could test with a smaller copper area, or just a wire for comparison or give me step by step detail on how to reproduce it for testing I can take a look if the touch configuration code may be improved.
I have 90 leds arranged in 3x 30 led segments.
Which - using the calc at https://wled-calculator.github.io/
is just over 3.7A power consumption at full white & full brightness.
Even though it never powers on at full white, and is never at full brightness, I’ve a feeling it may have been the old 1A phone power adapter that I was using to power it up (when not programming it) - that may have been causing it to ‘crash’ at power up due to a current inrush.
I just tried it on a 3A laptop USBC PSU and it seems steady.
It’s only ever sat at 50% brightness and never full white - so that should be more like 2.2A current draw.
That said - it also failed occasionally when connected to my Mac. However, checking the specs on the DockTeck USB C to USB A adapter it was plugged into - that’s only capable of 1.6A. Without the USBC PowerDelivery external power connected.
I think your code is more than likely stable tbh.
It would be nice to add the calibrate touch button options as I mentioned though.
Thanks a million for your advice today - have a great New Year!
glad you figured it out.
on the S3, there is no calibration needed, it does autocalibrate. but I agree WLED could use some debug-info somewhere to check button inputs and such, just to know if its seeing it or not.
Thank you for your help. I should have specified that I’m using a ESP32-S3-MINI-1-N8. I can only find the 4MB qspi or 8MB osi chips in the list of supported microcontrollers. I tried a ESP32-S3-MINI-1-N4R2 chip on a different board and was able to confirm the touch button feature works as expected. Trying the 8MB qspi chip again, I compiled a custom build of the 4MB qspi version I got working, but with the “Redefine Flash Size” option set to 8MB and was able to build and flash.
Initially, touch didn’t work, but after a reset it suddenly started working, but then not on the next reset, or the next. After lots of resets and power cycles, it sometimes works but its seldom, maybe 1 in 5 resets. This behavior seems similar to @WNTLtd’s experience … after resolving your PSU issues, did you ever get reliable touch sensing?
I switched back to the 4MB chip on a different board, and reconfirmed the touch works far more reliably, so I scrutinized the differences between board designs and noticed the problematic one has the button GPIO adjacent to a LED channel on the connector, so I wondered about interference with the touch autocalibration. I moved the LED channel adjacent to the touch GPIO on the working board and the touch became less reliable, but still worked most of the time. Back on the 8MB (unreliable) board, I moved the touch GPIO to one that is far from the LED channels, and basically right at the ESP32 pad, but still can’t get touch to work reliably. Both setups use the same PSU and LED configuration. I’m out of ideas … do you have any? I know this is clearly a unique setup issue, but any tips or ideas would be much appreciated!