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.

../../_images/xpt2046-full.jpg

XPT2046 Touch Screen Controller

# Example configuration entry
touchscreen:
  platform: xpt2046
  id: my_touchscreen
  cs_pin: 17
  interrupt_pin: 16
  update_interval: 50ms
  threshold: 400
  calibration:
    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 (Depricated): This value is moved to the calibration values

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

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

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

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

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

  • All other options from Base Touchscreen Configuration.

See Also