RS-485 Integration with ASI Biont: AI-Driven Industrial Automation via COM Port and Modbus RTU

RS-485 Integration with ASI Biont: AI-Driven Industrial Automation via COM Port and Modbus RTU

Industrial automation relies on robust, long-distance communication protocols. RS-485 is the backbone of factory floors, building management systems, and remote monitoring networks, supporting multi-drop connections up to 1200 meters. Connecting these legacy RS-485 devices—temperature sensors, PLCs, energy meters—to an AI agent unlocks predictive maintenance, real-time anomaly detection, and autonomous control without manual programming. This article explains how ASI Biont integrates with RS-485 devices through a COM port or USB-to-RS-485 adapter, using a Hardware Bridge that communicates via WebSocket. You'll learn the architecture, a step-by-step Modbus RTU example, and automation scenarios that become possible when AI meets industrial serial communication.

Why RS-485 and AI?

RS-485 is a differential serial standard defined by TIA/EIA-485, widely used in noisy industrial environments. It supports up to 32 devices on a single bus and baud rates from 9600 to 115200 bps. Devices communicate using protocols like Modbus RTU, Profibus, or simple ASCII commands. Traditionally, engineers write custom Python scripts (using pyserial) to poll sensors, parse responses, and trigger actions. This approach is time-consuming, brittle, and requires constant maintenance when devices change.

ASI Biont replaces manual scripting with natural language interaction. You describe the device and desired behavior in a chat interface; the AI agent generates and executes integration code on the fly. The agent can read registers, log telemetry, send alerts, and control actuators—all without a single line of hand-written code.

Connection Architecture: Hardware Bridge + WebSocket

ASI Biont does not run on your local machine. It is a cloud-based AI agent. To access local serial ports (COM ports on Windows, /dev/ttyUSB0 on Linux), you run a small Python application called bridge.py on your PC. Bridge connects to ASI Biont via WebSocket (the only communication channel) and exposes the serial port to the AI. When the AI needs to send a command, it uses the industrial_command tool with protocol serial:// and the command serial_write_and_read. Bridge receives the request, writes data to the port, reads the response, and sends it back to the cloud.

Key Bridge Features

  • Download: bridge.py is available only from the ASI Biont dashboard under Devices → Create API Key → Download bridge. No GitHub repository.
  • Launch: python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 115200 --rate=10
  • Dependencies: pip install pyserial requests websockets
  • Reliability: On Windows, if pyserial overlapped I/O fails (written: 0), bridge automatically applies CancelIoEx, PurgeComm, and synchronous WriteFile to ensure data is sent.
  • Data format: AI sends data as hex strings (e.g., data="48454c500a" for HELP+\n) or escape sequences (e.g., data="BLUE_ON\n"). The _parse_data_field() function converts to bytes.

Connection Steps

  1. Connect your RS-485 device to your computer via a USB-to-RS-485 adapter (e.g., FTDI-based). Note the COM port (Windows: Device Manager) or device path (Linux: ls /dev/ttyUSB*).
  2. Install Python 3.8+, then pip install pyserial requests websockets.
  3. Download bridge.py from ASI Biont dashboard.
  4. Run: python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 9600 --rate=5
  5. In ASI Biont chat, describe: "Read holding register 0 from Modbus device at address 1 on COM3, 9600 baud, 8N1." The AI will use industrial_command to send the Modbus RTU request.

Example: Modbus RTU Temperature Logger and Alert System

Consider a scenario: You have a temperature/humidity sensor (e.g., Sensirion SHT20) connected to an RS-485 Modbus RTU module (like a YL-69 with RS-485 interface). The sensor supports reading holding registers: register 0 = temperature (0.1°C), register 1 = humidity (0.1%RH). You want the AI to:
- Poll the sensor every 60 seconds
- Log data to a CSV file
- Send a Telegram alert if temperature exceeds 40°C

How the AI Does It

The user types: "Connect to COM3 at 9600 baud, Modbus RTU, device ID 1. Read holding registers 0 and 1 every 60 seconds. Log to temperature_log.csv. If temperature > 40°C, send a Telegram alert using my bot token."

The AI generates a Python script that uses pyserial (via bridge) to send Modbus frames and parse responses. But because bridge only provides atomic write+read, the AI must construct the Modbus RTU frame manually (CRC included). Alternatively, the AI can run a pymodbus script in execute_python if the Modbus device is reachable via a TCP-to-serial gateway. For direct COM port access, the AI uses industrial_command each time.

Sample chat interaction:

User: "Set up temperature monitoring on COM3, 9600 baud, Modbus device 1. Read register 0 every 30 seconds. If temp > 35, publish MQTT alert to topic 'factory/alerts'."

AI (via bridge):

industrial_command(
  protocol="serial://",
  command="serial_write_and_read",
  params={
    "port": "COM3",
    "baud": 9600,
    "data": "010300000001840a"  # Modbus RTU: device 1, read holding register 0, 1 register, CRC
  }
)

Bridge sends the hex string to COM3, reads the response (e.g., 0103020025f844), and returns it. The AI parses the response, extracts temperature (0x0025 = 37°C), logs it, and since 37 > 35, publishes an MQTT alert.

Automation scenario: The AI can also write to a coil (e.g., turn on a fan) using:

industrial_command(
  protocol="serial://",
  command="serial_write_and_read",
  params={
    "port": "COM3",
    "baud": 9600,
    "data": "01050000ff008c3a"  # write coil 0 to ON
  }
)

Alternative Connection Methods for RS-485 Devices

While direct COM port is the most common, RS-485 devices can also be accessed via:

Method Use Case ASI Biont Tool
Modbus/TCP PLC with Ethernet module industrial_command(protocol='modbus_tcp', command='read_registers', ...)
MQTT ESP32 with RS-485 shield execute_python with paho-mqtt (publish/subscribe)
SSH Raspberry Pi with USB-to-RS-485 execute_python with paramiko (run local script)

For example, if your RS-485 sensor is connected to an ESP32 that publishes data via MQTT, the AI can subscribe to the topic and analyze the data without a COM port.

Benefits: No Programming Required

Traditional integration requires:
- Understanding Modbus RTU frame structure (function codes, CRC calculation)
- Writing pyserial code with error handling
- Setting up logging and alerting infrastructure
- Debugging serial port issues

With ASI Biont, you describe the goal in natural language. The AI agent:
- Selects the correct protocol (Modbus RTU, ASCII, proprietary)
- Constructs the correct byte frames
- Handles timeouts and retries
- Logs data to cloud storage or sends to external services (Slack, Telegram, email)
- Adapts to new devices without changing infrastructure

Real-World Use Case: Energy Monitoring in a Factory

A medium-sized factory has 10 energy meters (e.g., Schneider Electric iEM3155) with RS-485 Modbus RTU. Each meter provides voltage, current, power, and energy registers. The facility manager wants to:
- Collect readings every 15 minutes
- Detect when total power exceeds 500 kW
- Send SMS alert to the maintenance team
- Generate a daily CSV report

With ASI Biont, the manager connects one meter via USB-to-RS-485, runs bridge.py, and describes the task. The AI polls each device (addresses 1-10) using a loop, aggregates data, checks thresholds, and sends alerts via Twilio (available in sandbox). The entire setup takes minutes, not days.

Conclusion

RS-485 integration with ASI Biont bridges legacy industrial hardware with modern AI capabilities. Using the Hardware Bridge (bridge.py) and WebSocket communication, you can connect any RS-485 device to the AI agent and automate monitoring, alerting, and control. No manual coding—just describe what you need in the chat. Whether you're a plant engineer, a building manager, or a hobbyist, this approach saves time and reduces complexity.

Call to Action: Try the integration yourself. Visit asibiont.com, download bridge.py from the dashboard, connect your RS-485 device, and ask the AI to start monitoring. Experience the future of industrial automation today.

← All posts

Comments