Introduction
Serial ports (RS-232 / RS-485) are the backbone of industrial automation. From weighing scales and barcode scanners to CNC machines and GPS receivers, millions of devices still communicate over COM ports. But managing them manually — writing custom scripts, polling data, parsing responses — is tedious and error-prone. What if you could offload all that to an AI agent?
ASI Biont is an AI agent that connects to virtually any device via chat. Instead of building a dashboard or writing glue code from scratch, you simply describe what you need: "Read temperature from COM3 every 10 seconds and alert me if it exceeds 80°C." The AI understands your intent, writes the integration code, and executes it — all within seconds.
In this article, I'll show you exactly how to connect a COM/RS-232 device (e.g., an Arduino or an industrial scale) to ASI Biont using the Hardware Bridge — the only secure channel for local serial access. You'll see real code, wiring diagrams, and three practical automation scenarios.
Why Connect a COM Device to an AI Agent?
COM ports are low-level, deterministic, and widely used. However, they lack built-in networking, AI, or cloud capabilities. By bridging a COM device to ASI Biont, you gain:
- Remote monitoring — check sensor values from anywhere via chat.
- Automated alerts — AI triggers notifications when thresholds are breached.
- Command execution — send commands to the device through natural language.
- Logging and analytics — AI stores data, detects trends, and generates reports.
According to a 2025 survey by Industrial IoT Consortium, over 60% of manufacturing sites still rely on RS-232 for legacy equipment. Integrating these devices with AI agents reduces manual oversight by up to 80% (source: internal ASI Biont user data, 2026).
How ASI Biont Connects to COM Ports
ASI Biont runs in the cloud — it cannot directly access your computer's COM ports. Instead, it uses a Hardware Bridge: a lightweight Python script (bridge.py) that you run locally. The bridge connects to ASI Biont via WebSocket (the only communication channel). When you send a command in chat, the AI routes it through industrial_command() with the serial:// protocol. The bridge receives the command, writes to the COM port via pyserial, reads the response, and sends it back.
Key characteristics:
- Data is always exchanged in hex format (e.g., data="48454c500a" for HELP\n).
- The bridge performs atomic write+read operations (serial_write_and_read).
- On Windows, if a write fails (written: 0), the bridge automatically applies CancelIoEx, PurgeComm, and synchronous WriteFile to recover.
- You specify the port (e.g., COM3) and baud rate (e.g., 115200).
Step-by-Step Integration: Arduino Temperature Sensor
Let's walk through a real scenario. You have an Arduino Uno with a DHT22 temperature/humidity sensor connected to a PC via USB (which appears as COM3 at 115200 baud). You want ASI Biont to read temperature every 10 seconds and send you a Telegram message if it exceeds 30°C.
1. Prepare the Arduino
Connect DHT22 to Arduino:
- DHT22 VCC → Arduino 5V
- DHT22 GND → Arduino GND
- DHT22 DATA → Arduino pin 2
Upload this sketch:
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("FAIL");
} else {
Serial.print("TEMP:");
Serial.print(t, 1);
Serial.print(",HUM:");
Serial.println(h, 1);
}
delay(10000);
}
2. Download and Run bridge.py
From the ASI Biont dashboard (Devices → Create API Key → Download bridge), get bridge.py. Install dependencies:
pip install pyserial requests websockets
Run the bridge:
python bridge.py --token=YOUR_API_KEY --ports=COM3 --baud=115200
The bridge will connect to ASI Biont via WebSocket and expose COM3.
3. Connect in Chat
Open the ASI Biont chat and type:
Connect to COM3 at 115200 baud via bridge. The Arduino sends "TEMP:xx.x,HUM:xx.x" every 10 seconds. Read the temperature every 10 seconds, log it, and send me a Telegram alert if temperature exceeds 30°C.
AI will respond by calling industrial_command() with:
industrial_command(
protocol='serial',
command='serial_write_and_read',
params={
'data': '524541440a', // hex for "READ\n"
'port': 'COM3',
'baud': 115200
}
)
Then AI will write a Python script (using execute_python) that:
- Reads the response every 10 seconds.
- Parses TEMP and HUM.
- Stores values in a local list.
- If temp > 30, sends a Telegram message via requests to your bot.
Here's the script AI generates (simplified):
import requests
import re
# Placeholder for data from bridge
response = "TEMP:28.5,HUM:55.2" # This would come from serial_write_and_read
match = re.search(r"TEMP:([\d.]+),HUM:([\d.]+)", response)
if match:
temp = float(match.group(1))
hum = float(match.group(2))
print(f"Temperature: {temp}°C, Humidity: {hum}%")
if temp > 30:
requests.post("https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage",
json={"chat_id": "<CHAT_ID>", "text": f"Alert: Temperature {temp}°C exceeded 30°C!"})
No manual coding — AI writes and runs everything.
Scenario 2: Industrial Scale with Print Commands
You have a Mettler Toledo scale connected via RS-232 (COM1, 9600 baud). You want AI to:
- Send the "P" (print) command to get weight.
- Log weight to a PostgreSQL database.
- Generate a daily report.
In chat:
Connect to COM1 at 9600 baud. Send "P" to the scale, parse the weight from the response (format:
+0123.4 g), log to PostgreSQL tableweightswith timestamp, and at midnight generate a CSV report.
AI will:
- Use serial_write_and_read(data="500d0a") (hex for "P\r\n").
- Parse weight with regex.
- Insert into PostgreSQL using psycopg2.
- Schedule a daily report via datetime + openpyxl or csv.
Scenario 3: CNC Machine Monitoring
A Fanuc CNC controller outputs status via RS-232 (COM2, 115200). You want AI to:
- Poll STATUS command every 5 seconds.
- Detect "ALARM" in the response.
- Send SMS via Twilio when alarm occurs.
In chat:
Monitor COM2 at 115200. Send "STATUS\r" every 5 seconds. If response contains "ALARM", send SMS to +1234567890 via Twilio.
AI writes:
import requests
# ... serial_write_and_read in loop (AI handles timing via execute_python)
response = "MACHINE: OK, STATUS: RUNNING" # example
if "ALARM" in response:
requests.post("https://api.twilio.com/...", data={"From": "+1987654321", "To": "+1234567890", "Body": f"CNC Alarm: {response}"})
Wiring Diagrams
For RS-232, you typically need a DB9 connector:
| Pin | Signal | Direction |
|---|---|---|
| 2 | RX | Receive |
| 3 | TX | Transmit |
| 5 | GND | Ground |
Connect device TX to PC RX, device RX to PC TX, and GND to GND. For Arduino, use a MAX232 or a USB-to-TTL adapter set to RS-232 levels.
Why This Matters
Traditional integration requires:
- Writing a custom Python script with pyserial.
- Handling errors, timeouts, and platform quirks.
- Setting up a server to run the script 24/7.
- Manually parsing and storing data.
With ASI Biont, you skip all that. The AI agent:
- Understands natural language descriptions.
- Chooses the right library (pyserial for COM, pymodbus for Modbus, paho-mqtt for MQTT).
- Writes production-ready code.
- Executes it in a sandbox (for cloud protocols) or via bridge (for local COM).
You only need to run bridge.py — the AI does the rest.
Conclusion
COM ports aren't dead — they're the quiet workhorses of industrial automation. By connecting them to ASI Biont, you unlock AI-powered monitoring, alerting, and control without writing a single line of boilerplate code. Whether it's an Arduino sensor, a Mettler scale, or a Fanuc CNC, the process is the same: describe what you need in chat, and the AI handles the integration.
Ready to automate your serial devices? Try it yourself at asibiont.com — download the bridge, connect your COM device, and start chatting with your hardware today.
Comments