Industrial IoT Unleashed: How to Integrate Modbus RTU (RS-485) Devices with the ASI Biont AI Agent

Introduction

Industrial equipment speaks Modbus RTU over RS-485—a battle-tested serial protocol that connects PLCs, VFDs, sensors, and actuators in factories, water treatment plants, and energy systems. The challenge? Extracting actionable intelligence from these silent data streams typically requires custom middleware, SCADA specialists, and weeks of development. ASI Biont changes that completely: you describe your device in natural language, and the AI agent writes the integration code, connects via a Hardware Bridge, and starts controlling your Modbus RTU network from a chat interface. This article walks through a real-world integration of a Modbus RTU temperature controller and a relay module, with wiring diagrams, Python code, and step-by-step instructions.

What Is Modbus RTU and Why Connect It to an AI Agent?

Modbus RTU (Remote Terminal Unit) is a master-slave serial protocol that runs on RS-485 physical layer, supporting up to 247 devices on a single twisted-pair cable. It is ubiquitous in industrial automation because of its simplicity, reliability, and low cost. Each device has a unique ID (1–247), and the master sends function codes to read coils, discrete inputs, holding registers, or input registers, and to write to coils or registers.

Connecting Modbus RTU to an AI agent like ASI Biont unlocks:
- Real-time monitoring – read temperature, pressure, flow, or vibration data on demand.
- Predictive maintenance – detect anomalies before they cause downtime.
- Automated control – switch relays, adjust setpoints, or start pumps based on conditions.
- Natural language interface – ask "What is the current temperature on sensor 3?" and get an answer in seconds.

Connection Method: Hardware Bridge + pymodbus

ASI Biont does not have direct access to your local COM ports—it runs in the cloud. The secure bridge is a Python application (bridge.py) that you run on your PC (Windows, Linux, macOS). It connects to ASI Biont via WebSocket and exposes your COM ports to the AI agent. The AI then uses the industrial_command tool with serial_write_and_read to send Modbus RTU frames as hex strings.

For Modbus RTU specifically, the AI agent can also use execute_python to run a script that uses pymodbus library (available in the sandbox) and communicates through the bridge. This approach is cleaner because pymodbus handles CRC calculation, frame formatting, and error checking automatically.

Wiring Diagram: RS-485 to USB Converter

To connect your PC to a Modbus RTU network, you need a USB-to-RS-485 converter (e.g., FTDI-based USB-RS485-WE). Wiring:

Converter Pin RS-485 Bus Notes
A (D+) A (D+) Twisted pair
B (D-) B (D-) Twisted pair
GND GND Common ground
VCC (optional) VCC Only if device needs 5V power

Terminate the bus with 120 Ω resistors at both ends if the cable exceeds 100 meters.

Step 1: Connect the Hardware Bridge

  1. Download bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge).
  2. Install dependencies: pip install pyserial requests websockets.
  3. Run the bridge:
python bridge.py --token=YOUR_API_TOKEN --ports=COM3 --baud 9600

Replace COM3 with your actual port (e.g., /dev/ttyUSB0 on Linux). The bridge stays connected to the cloud, waiting for commands.

Step 2: Describe Your Device to the AI Agent

In the ASI Biont chat, tell the agent:

"Connect to a Modbus RTU temperature controller on COM3 at 9600 baud, 8 data bits, no parity, 1 stop bit. The controller has slave ID 1. Read holding register 0x100 (temperature in tenths of Celsius) every 10 seconds. If temperature exceeds 50°C, write 1 to coil 0 to turn on a cooling fan."

The AI agent will generate and execute a Python script using pymodbus. Here is what it produces:

import asyncio
from pymodbus.client import AsyncModbusSerialClient

async def monitor_temperature():
    client = AsyncModbusSerialClient(
        port='COM3',
        baudrate=9600,
        bytesize=8,
        parity='N',
        stopbits=1,
        timeout=3
    )
    await client.connect()
    if not client.connected:
        print("Failed to connect")
        return

    try:
        while True:
            # Read holding register 0x100 (temperature)
            result = await client.read_holding_registers(0x100, 1, slave=1)
            if result.isError():
                print(f"Read error: {result}")
            else:
                temp_celsius = result.registers[0] / 10.0
                print(f"Temperature: {temp_celsius}°C")
                if temp_celsius > 50.0:
                    # Write coil 0 to ON (cooling fan)
                    await client.write_coil(0, True, slave=1)
                    print("Fan ON")
                else:
                    await client.write_coil(0, False, slave=1)
                    print("Fan OFF")
            await asyncio.sleep(10)
    finally:
        client.close()

asyncio.run(monitor_temperature())

Note: The sandbox timeout is 30 seconds, so a while True loop is only suitable for quick demos. For production, use a scheduled task or event-driven approach.

Step 3: Real-Time Chat Commands

Once the script runs, you can ask the AI agent:
- "What is the current temperature?"
- "Turn on the fan manually."
- "Set the threshold to 45°C."

The AI agent can modify the script on the fly, re-upload it, and execute it—all from the chat.

Real-World Scenario: Water Treatment Plant

A water treatment facility near Munich uses a Modbus RTU network with 12 sensors (pH, turbidity, chlorine, flow) and 4 actuators (valves, pumps). The operator describes:

"Connect to the Modbus RTU network on /dev/ttyUSB0 at 19200 baud. Read pH (register 0x200, slave 2), chlorine (register 0x201, slave 2), and flow (register 0x300, slave 3). If chlorine drops below 0.5 mg/L, write 1 to coil 5 on slave 4 to open the dosing valve. Log all data to a CSV file every minute."

The AI agent generates a pymodbus script that runs on the bridge-connected PC, writes data to a local CSV, and sends alerts via Telegram if thresholds are breached. The entire integration takes less than 5 minutes from the chat.

Why This Matters: Zero-Code Industrial Automation

Traditional Modbus RTU integration requires:
- Understanding of Modbus function codes and CRC calculation.
- Writing a custom Python or C# application.
- Debugging serial communication issues.
- Setting up logging and alerting manually.

With ASI Biont, you simply describe what you need. The AI agent has deep knowledge of pymodbus, pyserial, and the Modbus protocol specification (Modbus.org, 2023). It automatically handles byte ordering, CRC, and error recovery. You get a working solution in seconds, not weeks.

Going Further: Multi-Protocol Automation

ASI Biont is not limited to Modbus RTU. The same Hardware Bridge can serve multiple protocols simultaneously. In one session, you can:
- Read a Modbus RTU temperature sensor.
- SSH into a Raspberry Pi to check CPU temperature.
- MQTT publish a command to an ESP32 relay board.
- HTTP GET a smart plug status.

The AI agent orchestrates all protocols through a single chat interface.

Conclusion

Modbus RTU (RS-485) devices are the workhorses of industrial automation—reliable, proven, and everywhere. Integrating them with an AI agent like ASI Biont transforms them from dumb sensors into intelligent, conversational assets. With the Hardware Bridge, a few lines of Python (generated by AI), and natural language commands, you can monitor, control, and automate your entire Modbus RTU network without writing a single line of boilerplate code.

Try the integration yourself: Go to asibiont.com, create an API key, download the bridge, and tell the AI agent to connect to your Modbus RTU device. The future of industrial automation is a chat away.

← All posts

Comments