RS-485 Integration with ASI Biont: Bringing Industrial Sensors Under AI Control

Introduction

If you work in industrial automation, you’ve probably faced the same headache: an old Modbus RTU temperature sensor on an RS-485 bus, a PLC that logs data to a file, and no easy way to make that data talk to a modern AI agent. You want real-time alerts, predictive maintenance, or just a simple Telegram bot that tells you when a bearing is overheating. But integrating legacy RS-485 gear with cloud AI usually means writing custom Python scripts, setting up brokers, and wrestling with serial protocols.

That’s exactly why I started using ASI Biont for my RS-485 projects. Instead of spending hours coding a data pipeline, I just describe my setup in a chat – “connect to COM3 at 9600 baud, read Modbus holding registers 0-10 every 30 seconds, and send me a message if any value exceeds 80°C.” The AI agent writes the integration code, runs it, and hands me the result. No dashboard, no “add device” button – just a conversation.

Why RS-485 and Why an AI Agent?

RS-485 is the backbone of industrial communication: it’s differential, noise-immune, supports multi-drop networks up to 1200 meters, and is used in Modbus RTU, BACnet MS/TP, and many proprietary protocols. But its very reliability makes it a pain to integrate with cloud services:

Challenge Traditional Solution ASI Biont Solution
Serial communication Write pyserial script, handle timeouts AI generates pyserial code via execute_python
Modbus framing Implement CRC, function codes manually AI uses pymodbus, handles protocol automatically
Remote access VPN, port forwarding, or dedicated gateway Hardware Bridge + long polling, no public IP needed
Data analysis Write separate analytics engine AI analyzes data in sandbox, triggers alerts

ASI Biont connects to RS-485 devices through its Hardware Bridge – a small Python script (bridge.py) you run on a local PC or Raspberry Pi. The bridge opens a COM port (RS-232/RS-485 via USB adapter), sets baud rate, parity, and other parameters, then polls the ASI Biont cloud via HTTP long polling for commands. When you tell the AI “read register 0x0001 from Modbus slave ID 1”, the AI sends an industrial_command with protocol serial://, the bridge forwards it to the COM port, and the response comes back. No need to expose your serial port to the internet.

How the Integration Works: Step by Step

1. Hardware Setup

For this example, I used:
- USB-to-RS-485 adapter (FTDI-based, common on AliExpress / Amazon)
- Modbus RTU temperature sensor (e.g., a simple PT100 transmitter with Modbus output, slave ID 1, baud 9600, 8N1)
- Windows laptop (but Linux/macOS work identically)

Connect the adapter to the sensor’s A/B terminals. Verify communication first with a simple terminal (PuTTY, screen, or minicom).

2. Install and Run Hardware Bridge

Download bridge.py from ASI Biont’s official GitHub repository (link in the docs). Install the single dependency:

pip install pyserial

Launch the bridge with your token and COM port:

python bridge.py --token=YOUR_ASI_BIONT_TOKEN --ports=COM3 --default-baud=9600

You should see a message like Bridge connected. Waiting for commands.... The bridge now listens for serial commands from the AI agent.

3. Tell the AI What to Do

Open the chat with ASI Biont (web or Telegram). Describe your task naturally:

“Connect to COM3 at 9600 baud, 8 data bits, no parity, 1 stop bit. Poll Modbus slave ID 1, read holding registers 0 and 1 (temperature and humidity). Log the values every 10 seconds. If temperature exceeds 80°C, send me a Telegram alert.”

The AI will generate a Python script using pymodbus and pyserial (via the bridge), execute it in the sandbox (execute_python), and start polling. The bridge relays the serial frames.

4. What the AI Actually Does

Here’s a simplified version of the code the AI would generate and run (the actual script is more robust, with error handling and logging):

import pymodbus.client as ModbusClient
import time
from pymodbus import pymodbus_apply_serial_config

# Connect via the bridge (the bridge handles COM port access)
client = ModbusClient.ModbusSerialClient(
    port='COM3',  # passed via industrial_command
    baudrate=9600,
    bytesize=8,
    parity='N',
    stopbits=1,
    timeout=1
)

client.connect()

while True:
    try:
        result = client.read_holding_registers(address=0, count=2, slave=1)
        if not result.isError():
            temp = result.registers[0] / 10.0  # scale factor example
            hum = result.registers[1] / 10.0
            print(f"Temp: {temp}°C, Hum: {hum}%")
            if temp > 80:
                # Send alert via Telegram (using requests or aiohttp)
                print("ALERT: Temperature exceeds 80°C!")
        time.sleep(10)
    except Exception as e:
        print(f"Error: {e}")
        time.sleep(5)

Important: The sandbox has a 30-second timeout for execute_python, so the AI will not run an infinite loop. Instead, it uses the industrial_command tool to poll periodically – the AI schedules a command every 10 seconds, and each command triggers a single read. That’s the correct pattern for production.

5. Result: Real-Time Monitoring via Telegram

Once the integration is active, you can:
- Ask the AI “what’s the current temperature?” – it reads the latest logged value.
- Set thresholds: “alert me if temperature drops below 5°C at night.”
- Generate reports: “give me a summary of hourly averages for the last 24 hours.”

The AI stores data in memory (or in a database if you request it), and you can interact through chat without touching any code.

Real-World Pitfalls and How to Avoid Them

I’ve run this setup for months. Here are the gotchas:

  • Wrong baud rate / parity: The AI assumes you configured the bridge correctly. Always test with a simple serial tool first.
  • Modbus slave ID mismatch: The most common error. Double-check your sensor’s ID (often set via DIP switches).
  • USB adapter power: Some RS-485 adapters need external power for long cable runs. Use a powered hub if you see intermittent errors.
  • Bridge disconnects: If the bridge loses connection, the AI can’t send commands. I run bridge.py as a systemd service on a Raspberry Pi – it auto-reconnects.

Connecting Any RS-485 Device

The same pattern works for any serial device, not just Modbus. If you have a proprietary protocol (e.g., a weight scale with a simple ASCII command set), just tell the AI:

“Connect to COM4 at 115200 baud. Send the command ‘W\r\n’ and parse the response as a floating point number. Log it every minute.”

The AI will generate a script using pyserial with raw read/write. No Modbus library needed.

Why This Beats Manual Integration

Aspect Traditional Approach ASI Biont Approach
Time to first data 2–4 hours (code, test, debug) 5 minutes (describe in chat)
Protocol knowledge Must know CRC, framing AI knows pymodbus, pyserial
Remote access VPN, port forwarding Bridge + long polling (no open ports)
Extensibility Rewrite code for new sensor Just chat a new description

Conclusion

RS-485 doesn’t have to be a walled garden. With ASI Biont’s Hardware Bridge and the AI’s ability to write serial integration code on the fly, you can connect any industrial sensor to an AI agent in minutes. No cloud platform lock-in, no complex dashboards – just a chat where you describe what you need and get it done.

If you’re tired of wrestling with Modbus libraries and want your factory data to start talking to an AI, head over to asibiont.com and try the integration. Connect your first RS-485 device today – I promise it’s easier than writing a single line of code.

← All posts

Comments