Skip to content

Commit

Permalink
docs,esp32: Update machine.TouchPad docs for ESP32-S2 and ESP32-S3.
Browse files Browse the repository at this point in the history
Signed-off-by: Angus Gratton <[email protected]>
  • Loading branch information
projectgus committed Nov 28, 2024
1 parent 66e699e commit 154d141
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions docs/esp32/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -751,20 +751,33 @@ APA102 (DotStar) uses a different driver as it has an additional clock pin.
Capacitive touch
----------------

Use the ``TouchPad`` class in the ``machine`` module::
ESP32, ESP32-S2 and ESP32-S3 support capacitive touch via the ``TouchPad`` class
in the ``machine`` module::

from machine import TouchPad, Pin

t = TouchPad(Pin(14))
t.read() # Returns a smaller number when touched

``TouchPad.read`` returns a value relative to the capacitive variation. Small numbers (typically in
the *tens*) are common when a pin is touched, larger numbers (above *one thousand*) when
no touch is present. However the values are *relative* and can vary depending on the board
and surrounding composition so some calibration may be required.

There are ten capacitive touch-enabled pins that can be used on the ESP32: 0, 2, 4, 12, 13
14, 15, 27, 32, 33. Trying to assign to any other pins will result in a ``ValueError``.
``TouchPad.read`` returns a value proportional to the capacitance between the
pin and the board's Ground connection. On ESP32 the number becomes smaller when
the pin (or connected touch pad) is touched, on ESP32-S2 and ESP32-S3 the number
becomes larger when the pin is touched.

In all cases, a touch causes a significant change in the return value. Note the
returned values are *relative* and can vary depending on the board and
surrounding environment so some calibration (i.e. comparison to a baseline or
rolling average) may be required.

========= ==============================================
Chip Touch-enabled pins
--------- ----------------------------------------------
ESP32 0, 2, 4, 12, 13, 14, 15, 27, 32, 33
ESP32-S2 1 to 14 inclusive
ESP32-S3 1 to 14 inclusive
========= ==============================================

Trying to assign to any other pins will result in a ``ValueError``.

Note that TouchPads can be used to wake an ESP32 from sleep::

Expand Down

0 comments on commit 154d141

Please sign in to comment.