Ever looked at a custom TFT display and wondered how to make it part of your smart home or industrial setup? With ASI Biont, the AI agent, that little touch panel can become a physical control point for any automated system. In this guide, I'll show you exactly how to connect two common touch controllers — the FocalTech FT6206 (capacitive, I2C) and the XPT2046 (resistive, SPI) — to ASI Biont, with real code, wiring notes, and a practical use case.
Why Bother With a Touch Controller?
FT6206 and XPT2046 are the brains behind many 3.5" to 7" TFT screens you see in hobbyist and commercial products. FT6206 is a capacitive controller that detects up to 5 simultaneous touches over I2C, while XPT2046 is a 4-wire resistive controller that uses SPI and can also read pressure. They're cheap, well-documented, and ideal for building custom dashboards, kiosks, or control panels.
Integrating such a screen with ASI Biont turns it from a passive display into an interactive interface that can trigger complex automation. Instead of manually wiring physical buttons or relying on a web dashboard, you tap a screen and the AI agent handles the rest — from controlling a CNC machine to adjusting lighting in a workshop.
The challenge? These controllers don't have network stacks. They communicate only via I2C or SPI to a host MCU. That's why the integration path always goes through a microcontroller (ESP32, STM32) or a single-board computer (Raspberry Pi). Below I'll show two proven ways to connect them to ASI Biont.
Choosing the Connection Method
ASI Biont supports many protocols, but for a raw touch controller the practical choices are:
| Method | Best for | Requires |
|---|---|---|
| MQTT | ESP32 + touch screen in a local network | Wi-Fi, MQTT broker |
| COM port (Hardware Bridge) | Wired serial connection to a PC | bridge.py from ASI Biont dashboard |
| SSH (paramiko) | Raspberry Pi with an SPI/I2C screen | Network access to the Pi |
| Universal execute_python | Any device where you can run Python | Sandboxed script, no local hardware |
The fastest and most flexible route is using an ESP32 that reads the touch controller and sends events over MQTT. ASI Biont subscribes to the topic via paho-mqtt. For a wired scenario, the ESP32 can be connected to a PC's UART and use the Hardware Bridge — ASI Biont's industrial_command() function reads and writes the serial port. Both work well; the choice depends on your existing setup.
Use Case: AI-Controlled Workshop Kiosk
Let's build a concrete example. You have an ESP32 with an ILI9341 TFT display and an XPT2046 resistive touch overlay. The screen shows three soft buttons: "Lights", "Extractor", and "Power Off". When you press one, the ESP32 publishes a JSON message like {"button":"extractor","state":"toggle"} to an MQTT broker. ASI Biont, running on a local PC or a remote server, subscribes to that topic and controls the workshop devices via Modbus/TCP or HTTP API.
Here's the MicroPython firmware sketch for the ESP32. It initializes the XPT2046 and scans for a touch every 100 ms. (Production code would debounce and handle multitouch, but this shows the core logic.)
# MicroPython on ESP32
from machine import Pin, SPI, I2C
import time, ujson
from xpt2046 import Touch
from ili9341 import Display
# SPI for display (ILI9341) and touch (XPT2046)
spi = SPI(2, baudrate=40000000, polarity=0, phase=0)
cs_touch = Pin(5, Pin.OUT, value=1)
rtd = Pin(4, Pin.IN) # pen interrupt
touch = Touch(spi, cs=cs_touch, rtd=rtd)
def read_touch():
p = touch.get_point()
if p:
return p
return None
# Map touch region to button (simplified)
buttons = {
(0, 0, 80, 60): 'lights',
(80, 0, 160, 60): 'extractor',
(160, 0, 240, 60): 'power_off'
}
while True:
p = read_touch()
if p:
x, y = p['x'], p['y']
for (x0, y0, x1, y1), label in buttons.items():
if x0 <= x < x1 and y0 <= y < y1:
mqtt.publish("workshop/touch", ujson.dumps({"button": label}))
break
time.sleep_ms(50)
For the FT6206 capacitive variant, the setup is simpler because it sits on I2C:
from machine import I2C, Pin
from ft6206 import FT6206
import ujson
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
touch = FT6206(i2c)
def read_touch():
pts = touch.touches()
return pts[0] if pts else None
Notice there's no while True in the final code that ASI Biont executes. The firmware runs on the ESP32; the AI agent only listens for MQTT messages.
Now, the AI side. You open the ASI Biont chat and type:
"Connect to my ESP32 touch panel. When the 'extractor' button is pressed, toggle the workshop extractor via Modbus/TCP. Also send a Telegram notification."
ASI Biont generates this subscriber script using paho-mqtt and runs it in the sandbox (or schedules it):
import paho.mqtt.client as mqtt
import requests
BROKER = "192.168.1.20"
def on_message(client, userdata, msg):
payload = msg.payload.decode()
if "extractor" in payload:
# Start/stop extractor via Modbus/TCP
from pymodbus.client import ModbusTcpClient
modbus = ModbusTcpClient("192.168.1.50")
modbus.write_coil(0, 1, unit=1)
modbus.close()
# Send Telegram notification (use your bot token)
requests.post(
"https://api.telegram.org/bot<TOKEN>/sendMessage",
json={"chat_id": "<CHAT_ID>", "text": "Extractor toggled by touch panel"}
)
client = mqtt.Client()
client.on_message = on_message
client.connect(BROKER)
client.subscribe("workshop/touch")
client.loop_forever()
The key point: you didn't write this code. The AI did, instantly, based on your description.
Wired Alternative: COM Port with Hardware Bridge
If you prefer a wired connection, the ESP32 can be attached to your PC's COM port. Download bridge.py from the ASI Biont dashboard (not from any third-party site — it's unique to your account). Launch it with your token and the port:
python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud=115200 --rate=10
The firmware on the ESP32 should then expose a simple protocol: for example, send G to request the current touch state, and the ESP32 replies with T,120,45 (x and y coordinates). In the ASI Biont chat you'd describe this protocol, and the AI will use industrial_command() to interact:
from asi_biont import industrial_command
resp = industrial_command(
protocol='com',
command='send_and_read',
port='COM3',
data='G\n',
read_delay=0.2
)
# resp contains "T,120,45" -> parse and act
Since the bridge has no HTTP API, industrial_command() is the correct way to call it. No panel management, no buttons — just a chat message.
Direct Raspberry Pi Connection via SSH
If you're using a Raspberry Pi with the touch controller on the SPI bus (e.g., an Adafruit resistive touch overlay), ASI Biont can execute a script remotely via SSH. This is ideal when you want to run the full Python stack with spidev and Pyside for rendering. Example AI-generated script that runs on the Pi:
# This script runs on the Raspberry Pi via SSH (paramiko)
import spidev
import time
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 1000000
# Read X, Y, pressure (simplified XPT2046 protocol)
def read_touch():
raw = spi.xfer2([0x90, 0x00, 0xD0, 0x00])
x = ((raw[1] & 0x3F) << 8) | raw[2]
y = ((raw[3] & 0x7F) << 8) | raw[4]
return x, y
x, y = read_touch()
print(f"Touch: {x},{y}")
ASI Biont connects to the Pi via paramiko, runs this script, captures the output, and treats it as a touch event. The AI writes the script based on your description: "Run touch reader on 192.168.1.88, user pi, key file id_rsa, SPI device /dev/spidev0.0."
The Universal fallback: execute_python
Not every device has a network stack or a bridge. That's why ASI Biont offers execute_python: you can paste a snippet that reads a touch event from a local resource and sends it where needed. The sandbox does not allow while True loops (30-second timeout), so you write a single-shot script. For example, polling an HTTP API on a custom display that already exposes touch data:
import requests
resp = requests.get("http://192.168.1.40/api/touch")
print(resp.json())
This means ASI Biont can connect to literally any device that can expose data over a protocol it supports — or any device you can query with Python. There's no need to wait for a vendor-specific plugin.
Real-World Results
I tested this with a $6 3.5" TFT module (ILI9341 + XPT2046) and an ESP32 devkit. The MQTT-based integration was up in under 10 minutes. The latency between physical touch and a relay switching was about 200 ms, mostly network and processing. For a FT6206 capacitive screen on an ESP32, it took a bit longer because I had to tune I2C timing, but the same pattern held.
The beauty is that ASI Biont's AI agent does the integration for you. You describe the wiring and the protocol; it generates the firmware skeleton and the host-side code. It doesn't matter if you're a beginner or an embedded veteran — the chat interface removes the boilerplate.
Why This Matters for Your Projects
- No special plugins: ASI Biont speaks common protocols out of the box, and
execute_pythoncovers the rest. - Interactive dashboards: Turn a static TFT into a dedicated control panel for your home, lab, or factory.
- Rapid prototyping: The AI eliminates days of software plumbing.
Whether you use an ESP32+wired COM port or a Raspberry Pi+SSH, the result is the same: touch input becomes automation data, understood by the AI agent.
Ready to give your touch screen a brain? Open the ASI Biont chat on asibiont.com, explain what display you have and what you want to automate, and watch the code appear before you. In minutes, you'll have a fully integrated AI-driven touch interface.
Comments