ESPHome’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/esphome/esphome.io/llms.txt
Use this file to discover all available pages before exploring further.
touchscreen component bridges capacitive and resistive touch controllers to the rest of the ESPHome ecosystem — including display pages, LVGL widgets, and binary sensor virtual buttons. It handles coordinate translation, calibration, and multi-touch tracking, so your display project can respond to finger presses, drags, and releases with only a few lines of YAML.
Minimal Example
Base Touchscreen Configuration
All touchscreen platforms share these configuration variables.The ID of the display component this touchscreen is attached to. The touchscreen uses the display’s dimensions to scale coordinates.
Hardware coordinate transformation applied before scaling. All defaults are
false.swap_xy— swap the X and Y axes.mirror_x— flip the X axis.mirror_y— flip the Y axis.
Polling interval when no interrupt pin is used. Defaults to
50ms.How long to wait before considering a touch ended on controllers that don’t report release events. Default varies by platform.
Manual calibration for resistive touchscreens whose raw values do not map directly to screen pixels (e.g. XPT2046). See Calibration below.
x_min/x_max— raw values at left/right edge.y_min/y_max— raw values at top/bottom edge.
TouchPoint Argument Type
Bothon_touch and on_update receive touch point objects with these fields:
| Field | Type | Description |
|---|---|---|
id | int | Touch identifier for multi-touch tracking |
state | int | 1 = initial touch, 2 = moved, 4+ = released |
x, y | int | Current position in display pixels |
x_prev, y_prev | int | Previous position |
x_org, y_org | int | Position when touch was first detected |
x_raw, y_raw | int | Raw values (useful for calibration) |
Automation Triggers
on_touch
Fires once when an initial touch is detected. Not fired again until all touches are released.
Provides touch (single TouchPoint) and touches (list of all active points).
on_update
Fires whenever a touch position changes or a new finger lands — useful for gesture detection.
Provides touches — a list of TouchPoint objects.
Always check
touch.state in on_update — state 0 means the touch is no longer valid.on_release
Fires when all touches are released from the screen. No touch arguments are provided.
Binary Sensor Virtual Buttons
Define rectangular areas on the touchscreen asbinary_sensor entities. When a touch lands inside the area, the sensor reports ON.
Left edge of the touch zone (pixels).
Right edge of the touch zone (pixels).
Top edge of the touch zone (pixels).
Bottom edge of the touch zone (pixels).
Only activate this sensor when the specified display page is showing. Use
pages (list) if you want multiple pages.If
true, accepts raw coordinates outside the display area. Useful for resistive touchscreens that extend beyond the visible screen.Calibration
Resistive touchscreens (e.g. XPT2046) return raw ADC values that bear no relationship to pixel coordinates. You must calibrate them by touching the corners and recording the raw values. Step 1: Log raw values from each corner usingon_touch:
Popular Touchscreen Platforms
GT911
Capacitive multi-touch controller. Common in ESP32-S3 display boards. Supports up to 5 simultaneous touch points.
CST816S / CST226
Low-power capacitive controller popular in round displays. Supports swipe gesture recognition.
XPT2046
Resistive 4-wire touchscreen controller. Requires calibration but works with older, cheaper panels.
FT5x06 / FT63x6
Capacitive multi-touch I²C controller used in many 3.5” and 4” TFT displays.
TT21100
Capacitive I²C touchscreen controller used in several Espressif development boards.
EKTF2232
Touchscreen controller used in the Inkplate 6 Plus and similar e-ink display devices.