Introduction
Ever needed to connect a serial device to an AI agent but got stuck on drivers, baud rates, and parsing protocols? USB-to-Serial adapters (FTDI, CH340, CP2102) are the universal bridge between modern computers and legacy serial equipment — GPS trackers, PLCs, Arduino boards, industrial scales, and more. With ASI Biont, you can turn any serial device into a chat-controlled smart peripheral in minutes, without writing a single line of boilerplate code.
In this guide, I'll show exactly how ASI Biont connects to COM ports via its Hardware Bridge, using real-world examples and code you can copy. No magic, no fake dashboards — just a WebSocket link between the AI and your device.
What is a USB-to-Serial Adapter?
These chips convert USB signals to UART (serial) and vice versa. Common models:
- FTDI FT232 – reliable, widely used, official drivers.
- CH340 – cheap, common on Chinese Arduino clones.
- CP2102 – compact, good for ESP32 and GPS modules.
They appear on your computer as a virtual COM port (Windows), /dev/ttyUSB0 (Linux), or /dev/cu.usbserial (macOS).
How ASI Biont Connects to a Serial Device
ASI Biont does not have direct access to your PC’s COM ports. Instead, you run a lightweight Hardware Bridge (bridge.py) on your local machine. This bridge connects to ASI Biont via WebSocket (the only communication channel). When you ask the AI to read or write to a serial device, the AI sends a command through the industrial_command tool, which is routed to your bridge. The bridge then uses pyserial to talk to the hardware atomically (write + immediate read).
Key tools and libraries:
- industrial_command(protocol='serial://', command='serial_write_and_read', data='...')
- Bridge uses pyserial (pip install pyserial) and websockets.
- Data is passed as hex strings (e.g., data="48454c500a" for HELP\n) or escape sequences (BLUE_ON\n).
- On Windows, the bridge handles overlapped I/O failures with CancelIoEx + PurgeComm + synchronous WriteFile.
Note: The AI never writes infinite loops in cloud code. All serial interactions happen through the bridge’s atomic
serial_write_and_read().
Step-by-Step Integration: GPS Tracker via COM Port
Let’s take a real device: a GPS tracker (like u-blox NEO‑6M) connected via a CH340 adapter. It outputs NMEA sentences at 9600 baud.
1. Download and Run the Bridge
- Go to your ASI Biont dashboard → Devices → Create API Key → Download bridge.
- Install dependencies:
pip install pyserial requests websockets - Run:
python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 9600
(use--ports=/dev/ttyUSB0on Linux)
The bridge will connect to ASI Biont and report that COM3 is ready.
2. Tell the AI What to Do
In the chat, just describe:
“Connect to the GPS tracker on COM3 at 9600 baud. Read raw NMEA sentences for 10 seconds, parse the GGA sentence to get latitude, longitude, and altitude, and show the latest position. If the tracker hasn’t fixed, tell me.”
3. AI Generates the Command
Behind the scenes, the AI sends:
industrial_command(
protocol='serial://',
command='serial_write_and_read',
data='' // no write, just read
)
The bridge performs serial_write_and_read(data='') which sends no data but reads whatever is buffered. Then the AI parses the received NMEA.
If you needed to send a command (e.g., set update rate), the AI would use:
industrial_command(
protocol='serial://',
command='serial_write_and_read',
data='504d544b3230322c332c3230300d0a' // hex for "PMTK202,3,200\r\n"
)
4. AI Processes and Replies
The AI’s sandbox (execute_python) has pynmea2 to parse NMEA. After receiving the raw data, the AI runs a script like:
import pynmea2
for line in raw_nmea_lines:
if line.startswith('$GPGGA'):
msg = pynmea2.parse(line)
lat = msg.latitude
lon = msg.longitude
alt = msg.altitude
# send back to chat
You’ll see: Latitude: 48.8566° N, Longitude: 2.3522° E, Altitude: 35.0 m
Other Real-World Use Cases
| Device | Connection Method | What the AI Does |
|---|---|---|
| Arduino with DHT22 | Hardware Bridge (COM port) | Reads temperature/humidity, logs to CSV, alerts on high temp |
| Industrial scale (RS-232) | Hardware Bridge (COM port via FTDI) | Reads weight, checks threshold, sends to Telegram |
| ESP32 via USB serial | Hardware Bridge (CP2102) | Controls LED, reads sensor, calibrates |
| GPS tracker (NMEA) | Hardware Bridge (CH340) | Parses position, plots on map, sends location on demand |
Why Integrate with ASI Biont?
- Zero manual coding – just describe your task. The AI writes the integration code (pyserial, parsing, logic).
- Works with any serial device – protocols like NMEA, Modbus RTU, custom binary – the AI adapts.
- Chat-based control – ask “turn on the LED”, “read current weight”, “start logging GPS” – it happens.
- No dashboard complexity – everything happens in conversation. No buttons, no forms.
Conclusion
USB-to-Serial adapters open the door to countless legacy and modern devices. With ASI Biont’s Hardware Bridge and AI-driven code generation, connecting a serial gadget to an intelligent agent takes minutes. Stop wrestling with Python scripts – let the AI handle the wires.
Ready to connect your serial device? Go to asibiont.com, grab your API key, and start chatting with your hardware today.
Comments