The Problem That Won’t Go Away
You’ve got a warehouse scale that speaks RS-232. Or a CNC machine that spits out status codes over COM1. Or a barcode scanner that’s been sitting in a corner because nobody has time to write a custom Python script to log its data. Serial ports are everywhere in industrial and laboratory environments—yet they remain stubbornly analog in a digital world.
Most automation platforms force you to either learn a proprietary scripting language or wait weeks for a developer to add support for your specific device. That’s where ASI Biont changes the game. Instead of a rigid dashboard, you get an AI agent that writes the integration code for you, on the fly, based on a simple chat conversation.
How ASI Biont Connects to COM/RS-232 Devices
ASI Biont does not run on your local machine. It lives in the cloud (Railway). To talk to a serial port on your PC, it uses a lightweight Hardware Bridge – a single Python script (bridge.py) that you download from the ASI Biont dashboard. The bridge opens a WebSocket connection to the cloud AI and listens for commands. When you tell the AI to read from COM3 at 9600 baud, the AI sends an industrial_command with protocol serial://, the bridge receives it, writes the hex-encoded data to the port via pyserial, reads the response, and sends it back. The whole round trip takes milliseconds.
| Component | Role |
|---|---|
| ASI Biont Cloud | AI agent that interprets your request and generates commands |
| Hardware Bridge | Local Python script that owns the COM port and communicates via WebSocket |
| pyserial | Underlying library for serial read/write on Windows/Linux/macOS |
| Your Device | Any RS-232/RS-485 equipment (scale, printer, PLC, sensor) |
Real-World Use Case: Industrial Scale Logging
Scenario: A food processing plant needs to log weight from a Mettler Toledo scale every 10 seconds and send a Telegram alert if the weight deviates by more than 5%.
Step 1 – Setup:
- Download bridge.py from the ASI Biont dashboard (Devices → Create API Key).
- Install dependencies: pip install pyserial requests websockets.
- Connect the scale to COM3, configure it to 9600 baud, 8N1.
- Run the bridge: python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud=9600.
Step 2 – Chat with the AI:
User: "Connect to the scale on COM3. Every 10 seconds send the command 'WEIGHT\r\n' in hex. Parse the response, extract the numeric weight. If the weight is outside 1000±50 grams, send a Telegram message to chat ID 123456 using the bot token bot123:ABC. Log all readings to a CSV file named scale_log.csv on my local machine."
Step 3 – AI does the work:
Within seconds, the AI writes and executes a Python script (via execute_python in the sandbox) that:
1. Subscribes to a 10-second timer.
2. Sends the hex command 5745494748540d0a ("WEIGHT\r\n") via industrial_command(protocol='serial://', command='serial_write_and_read', data='5745494748540d0a').
3. Parses the returned string (e.g., +001234 g) to extract 1234.
4. Compares against the threshold.
5. If out of range, calls the Telegram API using requests.
6. Appends the reading to a local CSV file (the bridge saves files to a specified folder).
Result: The scale is now monitored 24/7. No custom GUI. No waiting for IT. The AI wrote the entire integration in seconds.
Another Scenario: CNC Machine Status via RS-232
Device: Haas CNC controller with RS-232 output.
Goal: Read the machine status every minute, log it, and restart the spindle if an alarm code appears.
Chat example:
User: "Connect to CNC on COM5 at 115200 baud. Send command '?\r' every 60 seconds. Parse the response for alarm codes starting with 'ALM'. If alarm code is ALM-123, send command 'M03 S1000\r' to restart the spindle. Log all responses to a local file cnc_status.txt."
The AI writes the timer loop, uses serial_write_and_read with the hex equivalent of each command, parses the ASCII responses, and conditionally sends restart commands. The entire logic is handled by the AI agent – you just describe what you want.
Why This Matters
- No coding required: You describe the task in plain English. The AI generates the Python code, tests it, and runs it.
- Works with any serial device: Scales, printers, PLCs, GPS trackers, barcode scanners, medical instruments – if it speaks RS-232/485, you can integrate it.
- No vendor lock-in: ASI Biont doesn’t have pre-built device drivers. It connects to anything via
execute_python– the AI writes the driver on the fly. - Real-time alerts & actions: Combine serial reads with Telegram, email, Slack, or even control other equipment via Modbus or HTTP.
Pitfalls to Avoid (Real Experience)
- Baud rate mismatch: Double-check your device’s documentation. A wrong baud rate produces garbage. The bridge logs raw bytes – inspect them first.
- Hex vs ASCII: The bridge expects hex strings. Use an online converter (e.g.,
HELP→48454c50). The AI can do this conversion automatically if you describe the command in plain text. - Windows overlapped I/O: On Windows, pyserial can fail with "written: 0". The bridge automatically falls back to
CancelIoEx+PurgeComm+ synchronousWriteFile. If you see errors, updatebridge.pyto the latest version from the dashboard. - Timeout handling: Some devices take time to respond. Set the read timeout in the bridge (default 2 seconds). For slow devices, increase it via
--timeout=5.
Conclusion
Integrating a COM/RS-232 device with an AI agent is no longer a weekend project for a developer. With ASI Biont, you just describe your equipment and your goal – the AI handles the serial protocol, the data parsing, the alerts, and the logging. Whether it’s a laboratory balance, a factory CNC, or a legacy printer, you can bring it online in minutes.
Ready to give your serial devices a voice? Head over to asibiont.com, create an API key, download the bridge, and start chatting with your equipment today.
Comments