how to use capacitive sensor block

Issue #439 resolved
Wenjie Wu created an issue

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)

  1. Wenjie Wu 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?

  2. John Maloney 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.

  3. Wenjie Wu 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.

  4. John Maloney 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.

  5. Log in to comment