USB-to-Serial Integration with ASI Biont: FTDI, CH340, CP2102 – Connect Any COM-Port Device to an AI Agent

Why Connect a USB-to-Serial Converter to an AI Agent?

If you work with microcontrollers (Arduino, ESP32), industrial PLCs, GPS trackers, or serial console ports, you’ve likely used a USB-to-Serial adapter based on FTDI, CH340, or CP2102 chips. These cheap dongles turn your computer’s USB port into a virtual COM port, letting you talk to devices that speak RS-232 or TTL serial. But what if you could control that serial conversation through an AI agent? Instead of writing custom scripts every time, you simply describe what you need in a chat, and the AI connects, reads data, and sends commands.

ASI Biont’s Hardware Bridge (bridge.py) is the key. You run it on your Windows, Linux, or macOS machine, point it at your COM port (e.g., COM3, /dev/ttyUSB0), and it opens a secure WebSocket connection to the cloud-based AI. From that moment, the AI can send serial commands, read responses, and automate your workflow – all through natural language. No manual coding, no dashboard panels, just a chat conversation.

How ASI Biont Connects to USB-to-Serial Devices

ASI Biont uses the Hardware Bridge method for COM port access. The bridge is a lightweight Python script (bridge.py) that you download from the ASI Biont dashboard (Devices → Create API Key → Download bridge). It uses pyserial to talk to your local COM ports and websockets to maintain a persistent link with the AI server.

Component Role
USB-to-Serial adapter Converts USB to TTL/RS-232 signals; chip driver creates a virtual COM port (COM3, /dev/ttyUSB0)
bridge.py Local agent that opens the COM port with pyserial, listens for WebSocket commands from ASI Biont, and performs atomic write+read operations
ASI Biont cloud AI agent that interprets your chat input, generates industrial_command calls, and routes them to your bridge
Your chat (Telegram / web UI) You describe what to do – “read temperature”, “send AT command”, “turn on LED” – and the AI executes it

The bridge supports configurable baud rate (9600, 115200, etc.), data bits, parity, stop bits, and flow control. AI uses the serial_write_and_read(data=hex_string) tool – an atomic operation: it writes a hex-encoded string (e.g., data="48454c500a" for HELP\n) and immediately reads the response. For robustness, the bridge on Windows handles overlapped I/O failures by calling CancelIoEx, PurgeComm, and falling back to synchronous WriteFile.

Real-World Case: Arduino + Servo Control via Telegram

The problem: I needed to remotely control a servo motor connected to an Arduino Uno. The Arduino was plugged into my Windows PC via a CH340-based USB-to-Serial cable. Every time I wanted to move the servo, I had to open the Arduino IDE Serial Monitor, type a command, and hit Send. Not scalable.

The solution with ASI Biont:

  1. Setup the hardware: Arduino Uno + servo on pin 9. Arduino sketch listens for commands like SERVO 90 or SERVO 180 and moves the servo accordingly.

  2. Configure bridge.py: On my PC, I created an API key in the ASI Biont dashboard, downloaded bridge.py, and ran:
    bash pip install pyserial requests websockets python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud=9600
    The bridge connected to the cloud and opened COM3 at 9600 baud.

  3. Chat with the AI: In the Telegram bot connected to ASI Biont, I typed:

    “Send command SERVO 90 to the Arduino on COM3”

  4. AI action: The AI generated an industrial_command with protocol serial://, command serial_write_and_read, and data "534552564f2039300a" (hex for SERVO 90\n). The bridge wrote the bytes to COM3, the Arduino moved the servo, and the bridge read back the acknowledgment OK.

  5. Automation: I later asked the AI to turn the servo to 0° every hour, and log the position. The AI wrote a schedule using execute_python with a loop (respecting the 30-second sandbox timeout by sleeping in chunks) and confirmed it worked.

Results: Complete hands-off control. I can be anywhere with Telegram access and command the servo. No code changes, no scripts to maintain.

Another Case: GPS Tracker NMEA Parsing

The problem: A u-blox NEO-6M GPS module connected to a CP2102 USB-to-Serial adapter was spitting out NMEA sentences at 9600 baud. I wanted to track coordinates and get alerts when the device moved outside a geofence.

Solution with ASI Biont:

  1. Hardware: GPS module → CP2102 → PC. Bridge.py opened /dev/ttyUSB0 at 9600 baud.

  2. Chat: “Read the GPS module and parse the $GPGGA sentence. If the latitude or longitude changes by more than 0.001 degrees compared to last reading, send me a Telegram notification with the new coordinates.”

  3. AI action: The AI used serial_write_and_read to send an empty request (just read), but since GPS sends continuous data, the bridge read the buffer. The AI then ran an execute_python script that parsed the NMEA sentence using pynmea2 (available in sandbox), compared with stored last position, and sent a message via telegram integration.

Results: Real-time geofencing without writing a single line of Python manually. The AI handled the parsing logic, state management, and notification.

How to Integrate Any Serial Device – Step by Step

  1. Plug in your USB-to-Serial adapter and install the driver (FTDI VCP, CH340 driver, or CP210x driver). Identify the COM port (Windows: Device Manager → Ports; Linux: ls /dev/ttyUSB*; macOS: ls /dev/cu.*).

  2. Download bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge).

  3. Run the bridge with your token and port:
    bash pip install pyserial requests websockets python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud=9600
    The bridge will log “Connected to ASI Biont via WebSocket” and “Listening on port COM3”.

  4. Open your chat (Telegram or web UI) and describe what you want to do. For example:

  5. “Read analog pin A0 from Arduino on COM3 and send me the value every 10 seconds.”
  6. “Send AT command to the GSM modem on /dev/ttyUSB0 and show the response.”
  7. “Control the LED on pin 13 – turn it on for 5 seconds, then off.”

  8. The AI does the rest: It generates the appropriate industrial_command with serial_write_and_read, Hex-encodes your data, and the bridge executes it. For complex logic (logging, alerts, scheduling), the AI uses execute_python to run scripts in the cloud sandbox, leveraging libraries like pynmea2, json, datetime, and telegram integration.

Why This Is a Game-Changer

Traditionally, integrating a serial device meant:
- Writing a Python or C# script
- Handling edge cases like buffer overflows, timeouts, and error recovery
- Building a UI or at least a CLI
- Maintaining the code when requirements change

With ASI Biont, you skip all that. The AI agent is your integration developer. You just describe what you need, and it writes, tests, and runs the code. Need to change the baud rate? Ask the AI. Want to add a filter to ignore empty lines? Say it. The AI adapts instantly.

Moreover, because the bridge uses a single WebSocket channel, you can run it on a low-power PC (Raspberry Pi, old laptop) and leave it 24/7. The AI can even restart the bridge if it crashes (by checking the connection status and triggering a remote restart command).

Common Pitfalls and How to Avoid Them

Pitfall Solution
Bridge can’t open COM port (permission denied on Linux) Add your user to the dialout group: sudo usermod -a -G dialout $USER, then log out and back in.
CH340 driver not recognized on Windows 11 Download the latest driver from the manufacturer (WCH.cn) or use Windows Update.
Serial data contains binary (non-printable) bytes Use hex encoding. The AI can convert any command to hex automatically.
Bridge disconnects after a few hours Check your Wi-Fi/router stability. The bridge reconnects automatically, but you can set up a cron job to restart it daily.
“written: 0” error on Windows The bridge’s fallback mechanism (CancelIoEx + PurgeComm + synchronous WriteFile) handles this, but ensure you’re using a good USB cable and no other program has the port open.

Conclusion

USB-to-Serial adapters are the universal translator of the embedded world. By connecting them to ASI Biont via the Hardware Bridge, you turn any serial device into a cloud-controllable, AI-powered asset. Whether you’re automating an Arduino robot, logging GPS data, or debugging a PLC, the AI handles the boilerplate – you just talk.

Ready to try it? Head over to asibiont.com, sign up, create an API key, download bridge.py, and start controlling your serial devices through Telegram. No coding required – just describe what you want, and the AI makes it happen.

← All posts

Comments