XPT2046 Touch Screen Controller (Updated version)

The xpt2046 touchscreen platform allows using the touch screen controllers based on the XPT2046 chip (datasheet, AZ-Delivery) with ESPHome. Many cheap LCD displays contain this controller. The SPI is required to be set up in your configuration for this sensor to work.


XPT2046 Touch Screen Controller

# Example configuration entry
  platform: xpt2046
  id: my_touchscreen
  cs_pin: GPIOXX
  interrupt_pin: GPIOXX
  update_interval: 50ms
  threshold: 400
    x_min: 3860
    x_max: 280
    y_min: 340
    y_max: 3860

Configuration variables:

The configuration is made up of two parts: The touch screen component, and optional individual binary sensors.

Base Configuration:

  • id (Optional, ID): Set the ID of this sensor.

  • cs_pin (Optional, Pin Schema): The chip select pin. Often marked T_CS on the board.

  • interrupt_pin (Optional, Pin Schema): The touch detection pin. Often marked T_IRQ on the board. If not specified the component will use polling via SPI. This key is renamed from irq_pin

  • update_interval (Optional, Time): The interval to check the sensor. If interrupt_pin is specified the touch will be detected nearly instantaneously and this setting will be used only for the release detection. Defaults to 50ms.

  • threshold (Optional, int): The value to detect the touch or release. Defaults to 400.

  • calibration_x_min (Deprecated): This value is moved to the calibration values

  • calibration_x_max (Deprecated): This value is moved to the calibration values.

  • calibration_y_min (Deprecated): This value is moved to the calibration values.

  • calibration_y_max (Deprecated): This value is moved to the calibration values.

  • swap_x_y (Deprecated): This value is moved to the transform values as swap_xy see Base Touchscreen Configuration.

  • report_interval (Deprecated): This interval is removed in favor of the update_interval.

  • All other options from Base Touchscreen Configuration.

See Also