1
\$\begingroup\$

After recently discovering the ESP32, I've been inspired to attempt my first electronics project. It will be a very simple wifi-enabled light.

I thought I would take advantage of the capacitative touch pins on the ESP32 and add two on-device touch buttons to increase/decrease the brightness.

Then I thought I might be able to save a pin if the buttons are able to return different capacitive values, and if my code can consistently detect these different threshold levels.

After much searching around, I have not been able to find any examples of capacitative switches used in this way, or any switch components that provide graduated capacitive values.

Is this a bad idea? Or is the capacitance range for these switches sufficient that I could be able to achieve this kind of multi-state set up?

\$\endgroup\$
6
  • \$\begingroup\$ Is this a bad idea? Why ask here when you can simply try it yourself. Maybe it is good enough for your purposes but not reliable enough to use in a mass-produced item. Someone who designs those mass produced items might say it is a bad idea while it can still be good enough for what you want. \$\endgroup\$ Commented Dec 14, 2020 at 12:46
  • \$\begingroup\$ Thanks @bimpelrekkie. Why ask here? Because I thought that is the purpose of these forums. To learn from others experience and mistakes before wasting time and money on a non-viable approach. As I had not found any examples, I thought I may be overlooking a fundamental reason why this would not work. From your comment it seems as though it is at least possible, which is useful. Thanks \$\endgroup\$ Commented Dec 14, 2020 at 12:51
  • \$\begingroup\$ Because I thought that is the purpose of these forums. It is and you're right, it is good to ask. But since I suppose it isn't much work to just try it (write a test program and see if you can get reliable readings) I suggested that. Since as far as I know there are few (if any) products that multiple capacitive response levels, it is probably not very usable / reliable. But still, it might be good enough for your purposes and you'll only find that out if you try it in a test. \$\endgroup\$ Commented Dec 14, 2020 at 13:07
  • \$\begingroup\$ thanks @Bimpelrekkie, I will give this a try. I'm only at the design stage at the moment, so will need to get the components first :) \$\endgroup\$ Commented Dec 14, 2020 at 13:13
  • \$\begingroup\$ Samsung telephones' capacitive touchscreens at least will give different responses for hovering your finger just above, and for touching the screen, so it has been done. No idea if you can do something similar with the capacitative touch pins peripheral of an ESP32, though, but, as others have said, just try it. \$\endgroup\$
    – ocrdu
    Commented Dec 14, 2020 at 14:20

1 Answer 1

2
\$\begingroup\$

Andy, welcome to the board. Capacitive touch sensing is inherently analog, that is, the sensor outputs a continuous range of values, depending on the amount of external capacitance added to the pin. To convert this to a digital result, the code sets a threshold value. Above that, it reports "touch", and below, it reports "no-touch". There's nothing to prevent you from setting two thresholds, so you get three possible digital results, like "no-touch", "light-touch", "heavy-touch".

Commenters have validly noted that this might not be reliable enough for a commercial product, but I encourage you to try it and learn from the experience.

Think about the curvature of your fingertip and how it contacts a touchswitch pad. As you press harder, the curvature flattens out against the pad, so there is more surface area in contact, which increases the capacitance compared to a light touch where only a small area of your finger contacts the pad. I'd guess the touch pad should be about the size of your fingertip. If it's too small (as for example if you are just using a wire to experiment) there might be no difference between light and heavy touches. So be sure to try an actual flat or curved pad. Use touchRead() to sense the value and print it out on the serial monitor, running in a loop, while you experiment. Have fun and gain knowledge!

\$\endgroup\$
1
  • \$\begingroup\$ @andy Also along with this great answer, that threshold value can/will change depending on ambient conditions. I know Cypress Semi. came up with an algorithm to dynamically adjust the threshold to deliver consistent touch/no-touch results. \$\endgroup\$
    – Aaron
    Commented Dec 14, 2020 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.