touchPad on Pin 2 (ESP32)
I have downloaded the actual version of Micropython for the ESP32 and i wanted to use Pin 2 as a touchPin. I can decelerate it as a touchpin like this touchPad = TouchPad(Pin(2))
But I cannot read from that: touchPad.read()
Than I get an error: ValueError: Touch pad error
Have anyone an idea?
esp32: Fix stuck TouchPad readings on ESP32-S3, use version specifiers in code.
Summary
- Updates the
machine.TouchPaddriver to use hardware version specifiers instead of chip names. This should make adding future SoCs easier. - Fixes #13178, by updating the fix applied in #8955.
- Update the docs for ESP32-S3 and ESP32-S3 TouchPad differences.
The new order of initialisation matches more closely the order in Espressif's example code, i.e.
https://github.com/espressif/esp-idf/blob/v5.2.2/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/tp_read_main.c#L86
This work was funded through GitHub Sponsors.
Testing
- Tested on ESP32, ESP32-S2 and ESP32-S3 using the example code from the linked issue. Plus a similar example which initialised multiple channels.
- Unfortunately I had no working boards with PCB touch pads, so used dupont wires hanging off dev board connections... Works well enough.
The only buggy case of stuck max readings that I was able to reproduce was on ESP32-S3, and never reproduced once the fix was applied.
The hardware FSM did seem to get stuck once on ESP32-S3 in a different way (was reading correctly and then stopped updating and didn't start again). However I think this was due to my poor quality touch pad inputs (had moved the wires a lot and it would have changed capacitance by a huge factor).
Trade-offs and Alternatives
- The Espressif touch sensor V2 hardware in S2 and S3 has a lot of features (denoise, background averaging, etc) which MicroPython is not using. It'd be good to support this, although it'd be a lot of work for someone and also may break code that relies on the current "raw" readings.