how to use capacitive sensor block
I noticed that sensorPrims.ubl has a capacitive sensor block. Can it be used to read the value of esp32 s3 touch pin (such as gpio 13)? I put my hand on and off gpio13 and the value does not change.
If it works, we can make makeymakey using esp32, and wirelessly (with ble keyboard)
Comments (9)
-
repo owner -
repo owner - changed status to open
-
reporter I tested GPIOs 13 and 14 , and from the diagram, it seems the two pins support touch, but they appear not to work. I see that the ESP32 has ten touch pins. John, are you able to successfully use them on the ESP32?
-
repo owner The touch sensor is working for me with an ESP32, but it requires using a primitive that isn't in a library.
This script graphs touch pin value.
You'll notice that the output drops when you touch the pin.
To make use of this, you'll need to write a script to detect when the pin drops below a certain threshold. The ESP32-based Citilab ED1 board uses this technique to implement six built-in capacitive buttons. They use some extra logic to ensure against false positives. (I think the reading must stay below the threshold for several readings in a row to be considered a touch.)
We don't have an ESP32 touch library yet. If you are interested, you might create a variation of the "Touch" library for the ESP32 family. It might be called "Touch (ESP32)". It would be nice if it had a similar same "touch event" API.
-
repo owner This article may be of interest:
https://randomnerdtutorials.com/esp32-touch-pins-arduino-ide/
-
reporter The touch sensor is working for me with an ESP32, but it requires using a primitive that isn't in a library.
you may have forgotten that the sensor primitives library contains this block, and it works well in esp32 !
As for the issue of esp32-s3, it is not important to me. Currently, most users are using esp32. I will synchronize this information with everyone at the sharing meeting next week.
-
reporter Thank you for sharing this article, I will look into it
-
reporter - changed status to resolved
-
repo owner Great that it is working for you on the ESP32.
I wonder if primTouchRead actually getting compiled for the S3? The #ifdef at line 1421 of sensorPrims.cpp uses ARDUINO_ARCH_ESP32, which I believe should include the ESP32-S3.
Once I get an S3 board I can look into this in more detail.
- Log in to comment
According to this:
https://docs.espressif.com/projects/esp-idf/en/v5.0/esp32s3/hw-reference/chip-series-comparison.html
The S3 has 14 touch-enabled pins, but not every pin has touch capability. You'll need to consult a pinout for the board to find out which pins you can use for touch. In theory, at least, the touch library should work with those pins on the S3.
Let me know if you get it working!