Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/PaulStoffregen/XPT2046_Touchscreen/llms.txt

Use this file to discover all available pages before exploring further.

The XPT2046 Touchscreen library gives Arduino, Teensy, ESP8266, and ESP32 projects a simple API to read touch coordinates and pressure from any display using the XPT2046 resistive touch controller chip. Communicate over SPI, detect touch events, read X/Y/Z coordinates, and optionally use the hardware interrupt pin for zero-SPI idle polling.

Installation

Install via Arduino Library Manager or PlatformIO in minutes

Quickstart

Wire up your display and read your first touch coordinates

API Reference

Full documentation of every class method and parameter

Examples

Working sketches for basic touch, IRQ, and ILI9341 display integration

Why XPT2046 Touchscreen?

The XPT2046 controller chip is found on many inexpensive TFT display modules (2.4″, 2.8″, 3.2″ and larger). This library provides:

Interrupt-Driven Polling

Use the T_IRQ pin to skip SPI reads entirely when the screen is idle — keeping your loop fast

Noise Filtering

Best-two-of-three averaging algorithm reduces jitter from the analog resistive surface

Rotation Support

Four rotation modes (0–3) match any TFT display orientation

Adafruit Compatible

Drop-in replacement API for Adafruit_STMPE610 — migrate existing sketches without changes

Get Started in Three Steps

1

Install the library

Open the Arduino IDE, go to Sketch → Include Library → Manage Libraries, and search for XPT2046_Touchscreen. Click Install.
2

Wire your display

Connect CS, MISO, MOSI, SCK, and optionally T_IRQ to your microcontroller. See the Wiring Guide for pin-by-pin details.
3

Read touch coordinates

Create an XPT2046_Touchscreen instance, call begin() in setup(), then use touched() and getPoint() in loop().
if (ts.touched()) {
  TS_Point p = ts.getPoint();
  Serial.printf("x=%d, y=%d, z=%d\n", p.x, p.y, p.z);
}

Build docs developers (and LLMs) love