The Last Thing I Expected: My Touch Screen Called Me
Last week, a 3.5-inch TFT display with an XPT2046 resistive touch controller started sending me Telegram alerts. It sounds like science fiction, but it's just an AI agent named ASI Biont doing what it does best: turning raw sensor data into action.
FT6206 and XPT2046 are two of the most common touch controllers in hobby displays. The FT6206 (capacitive, I2C) is found in 2.8/3.2 inch TFT modules. The XPT2046 (resistive, SPI) powers 3.5/4 inch panels. Both simply report X/Y coordinates. They have no idea what a 'swipe' or a 'tap' means. That's where ASI Biont comes in.
Why Bother Connecting a Touch Screen to an AI Agent?
Because a touch screen is the most intuitive human-to-machine interface. Instead of a physical button, you can draw zones on the glass: tap left for 'lights off', tap right for 'next track', swipe up to 'open the door'. ASI Biont can interpret those coordinates and trigger automations via MQTT, HTTP, or even a Telegram bot.
The problem: touch controllers don't natively speak MQTT or Modbus. You need a bridge. And writing a custom driver for every display is a nightmare. But with ASI Biont, the AI writes the bridge for you.
The Hardware Bridge
In my test I used:
- Raspberry Pi 4 (any SBC works)
- 3.5 inch TFT with XPT2046 (SPI interface)
- A few jumper wires: T_CLK, T_CS, T_DIN, T_DOUT, T_IRQ
On the Pi, the device shows up as /dev/spidev0.0. I used the spidev Python library to read raw touch data. Here's the core read function:
import spidev, time
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 1_000_000
def read_touch():
raw = spi.xfer2([0x90, 0x00, 0x00]) # XPT2046 read X
x = ((raw[1] & 0x3F) << 8) | raw[2]
return x
For the FT6206 on an ESP32, the MicroPython code is even simpler:
import machine
from umqtt.simple import MQTTClient
import ft6206
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21))
touch = ft6206.FT6206(i2c)
client = MQTTClient('esp32', '192.168.1.100')
client.connect()
while True:
if touch.touched():
client.publish('sensors/touch', f'{touch.x()},{touch.y()}')
time.sleep_ms(50)
The FT6206 library I used is Adafruit's port to MicroPython (available on GitHub). The XPT2046 coding was based on the datasheet by XPT, plus the spidev docs.
How ASI Biont Connects
ASI Biont doesn't care if your device speaks I2C, SPI, Modbus, or MQTT. It has two ways to talk to a touch screen:
-
Direct via MQTT — the touch host (ESP32 or Pi) publishes
sensors/touchto a broker. ASI Biont's built-in MQTT connector subscribes to that topic. All configuration happens in the chat dialog: you typesubscribe to sensors/touch over MQTT at 192.168.1.100:1883, and the agent sets it up. -
Via execute_python — for non-standard cases, you can ask ASI Biont to run an arbitrary Python script. The AI writes the script based on your description. This is the universal fallback that supports literally any device.
Real-World Example: Touch-to-Telegram
I set up a 'doorbell' scenario. The bottom half of the screen was a big green button. When someone taps it, the Pi publishes X/Y coordinates to MQTT. ASI Biont's script then sends a Telegram message to my phone.
After wiring everything, I opened the ASI Biont chat and typed:
Listen to MQTT topic sensors/touch. If a tap is in the lower half (y > 2000), send me a Telegram message saying 'Someone is at the door'.
Within seconds, ASI Biont replied with a generated Python script and ran it in its sandbox. Here's the automatic script (paraphrased):
import paho.mqtt.client as mqtt
import requests
def on_message(client, userdata, msg):
x, y = msg.payload.decode().split(',')
if int(y) > 2000:
requests.post(
'https://api.telegram.org/bot<TOKEN>/sendMessage',
data={'chat_id': '<CHAT_ID>',
'text': 'Someone is at the door'})
client = mqtt.Client()
client.on_message = on_message
client.connect('192.168.1.100', 1883)
client.subscribe('sensors/touch')
client.loop_start()
time.sleep(30) # sandbox execution limit
client.loop_stop()
Note that ASI Biont respects the 30-second execute_python timeout, so the script won't block forever. For persistent subscriptions, the MQTT connector is the right tool.
The 'Universal Device' Escape Hatch
The best part: none of this required waiting for a 'driver update'. ASI Biont connects to any device through execute_python. The user simply describes the device: its port, I2C address, baud rate, or API endpoint, and the AI writes the integration code under the hood. It uses pyserial for COM ports, paramiko for SSH, paho-mqtt for MQTT, pymodbus for Modbus, aiohttp for HTTP, and opcua-asyncio for OPC-UA. For a touch screen, it will pull in spidev or ft6206 automatically.
I didn't need a GUI dashboard, a plugin, or a custom firmware. I typed a sentence, and the AI did the rest.
Pitfalls I Hit
- Miswired SPI — the XPT2046 is sensitive to pin order. Double-check T_DIN vs T_DOUT; datasheets sometimes label them from different perspectives.
- Ghost touches — when the display is powered but not touched, the XPT2046 can report random values. Add a
touch_detected(penirq) check before reading coordinates. - I2C address conflicts with other sensors. The FT6206 usually sits at
0x38, but some modules use0x38or0x39; scan the bus first. - Sandbox timeout — don't put
while Trueinsideexecute_python. Use the MQTT connector for long-running jobs.
Is It Worth It?
Absolutely. The combination turns a $10 display into an AI-controlled control panel. With ASI Biont, the integration time went from a full day of reading datasheets to roughly two minutes. The AI wrote the data-reading code, the MQTT client, and the Telegram bot logic. I just described what I wanted, in plain English.
Try it yourself: describe your touch screen setup in the ASI Biont chat at asibiont.com and see the agent write the integration for you in seconds.
Comments