How ASI Biont AI Agent Connects to Modbus/TCP PLCs: A Case Study in Industrial Automation

Introduction

In the world of industrial automation, Modbus/TCP remains one of the most widely adopted protocols for communicating with PLCs, RTUs, and other field devices. Developed by Modicon (now Schneider Electric) in 1979 and later standardized as an open protocol, Modbus/TCP allows controllers to read and write data over Ethernet using a simple client‑server model. Despite its age, Modbus/TCP is still the backbone of thousands of factories, water treatment plants, and energy management systems because of its reliability, low overhead, and ease of implementation.

However, traditional Modbus/TCP setups require engineers to write custom scripts (often in Python, C#, or ladder logic) to poll registers, parse data, and make decisions. This manual approach is time‑consuming, error‑prone, and hard to scale when multiple devices or conditional logic are involved. Enter ASI Biont – an AI agent that can connect to Modbus/TCP devices directly through natural language commands. Instead of writing code yourself, you simply describe your goal in a chat conversation, and ASI Biont handles the entire integration: it reads holding registers, writes coils, logs trends, and even triggers alerts when values exceed thresholds.

This article is a deep‑dive into how ASI Biont integrates with Modbus/TCP (PLC, RTU) devices to solve real industrial problems. We’ll cover the connection mechanism, a concrete use case with a step‑by‑step example, and explain why this approach dramatically reduces engineering effort.

What is Modbus/TCP and Why Connect It to an AI Agent?

Modbus/TCP is an application‑layer protocol that uses TCP/IP port 502 by default. It defines a set of function codes:
- Read Coils (0x01) – read discrete outputs
- Read Discrete Inputs (0x02) – read discrete inputs
- Read Holding Registers (0x03) – read 16‑bit analog output registers
- Read Input Registers (0x04) – read 16‑bit analog input registers
- Write Single Coil (0x05) – write a single discrete output
- Write Single Register (0x06) – write a single 16‑bit register
- Write Multiple Coils (0x0F) and Write Multiple Registers (0x10) – for bulk operations

These operations allow a client (e.g., an HMI or SCADA) to monitor and control PLC‑based systems. But the real power emerges when you combine Modbus/TCP with an AI agent that can:
- Interpret natural language – “Read temperature from register 100 and log it every 5 seconds.”
- Make decisions – “If pressure exceeds 10 bar, open valve coil 3.”
- Automate without programming – The AI writes and executes the Modbus logic on your behalf.

ASI Biont connects to Modbus/TCP devices through its industrial_command tool, which uses the pymodbus library under the hood. The tool supports all standard function codes and handles connection management, retries, and timeouts. Users do not need to install or configure anything on the PLC side – the AI only requires the device’s IP address and port.

Connection Mechanism: industrial_command with Modbus/TCP

When a user asks ASI Biont to interact with a Modbus/TCP device, the AI agent uses the industrial_command tool with the protocol set to modbus. The allowed commands are:

Command Description Typical Use
read_registers Read holding registers (function code 0x03) Read sensor values, setpoints
write_register Write a single holding register (0x06) Change setpoint, reset counters
read_coils Read discrete outputs (0x01) Monitor valve or motor status
write_coil Write a single coil (0x05) Start/stop equipment

Parameters are passed as JSON. For example, to read two holding registers starting at address 0 from a PLC at 192.168.1.100:502, the AI would internally call:

{
  "protocol": "modbus",
  "command": "read_registers",
  "params": {
    "host": "192.168.1.100",
    "port": 502,
    "unit_id": 1,
    "address": 0,
    "count": 2
  }
}

The result is returned as a list of register values, which the AI then presents to the user in a readable format. Because the tool is synchronous and fast, the AI can poll registers repeatedly in a loop (within the limitations of the execute_python sandbox) to implement continuous monitoring.

For more complex workflows – such as polling multiple devices, combining Modbus data with other protocols, or generating historical reports – the AI can also write a standalone Python script that uses pymodbus directly and run it inside the execute_python sandbox. This gives unlimited flexibility while keeping the code generation automated.

Real‑World Use Case: Temperature & Pressure Monitoring in a Chemical Plant

The Problem

A mid‑sized chemical plant uses a Siemens S7‑1200 PLC to control a reactor vessel. The PLC holds temperature in register 100 and pressure in register 101, both scaled as 16‑bit integers (temperature = raw × 0.1 °C, pressure = raw × 0.01 bar). The plant’s existing SCADA only logs data every 15 minutes, which is insufficient for early warning of runaway reactions. Operators want real‑time alerts when temperature exceeds 150 °C or pressure exceeds 12 bar, and they need a web‑accessible dashboard. Building a custom Python script with an MQTT bridge would take an engineer several days.

The Solution with ASI Biont

An engineer opens the ASI Biont chat and types:

“Connect to Modbus/TCP PLC at 192.168.1.100:502 unit ID 1. Every 5 seconds read registers 100 and 101. If temperature > 1500 (dec 150.0 °C) or pressure > 1200 (dec 12.0 bar), send a Telegram alert to @operator. Plot the last 100 readings on a chart.”

ASI Biont interprets this request, generates a Python script that uses pymodbus for polling, telegram‑send for alerts, and matplotlib for the chart – all within the sandbox. The AI then runs the script, which executes a loop for 30 seconds (the sandbox timeout). For a production deployment, the script can be exported to a Raspberry Pi or on‑premise server using the Hardware Bridge approach (not covered here but documented in ASI Biont’s device guides).

Step‑by‑Step Implementation

Let’s break down what the AI actually does internally:

  1. Identify parameters – The user provided IP, port, unit ID, register addresses, scaling, thresholds, and alert channel.
  2. Generate the polling loop – The AI writes a Python script using pymodbus synchronous client:
from pymodbus.client import ModbusTcpClient
import time

client = ModbusTcpClient('192.168.1.100', port=502, timeout=5)
client.connect()

for _ in range(6):  # 30 seconds / 5 sec = 6 iterations
    rr = client.read_holding_registers(100, 2, unit=1)
    if not rr.isError():
        temp = rr.registers[0] * 0.1
        pressure = rr.registers[1] * 0.01
        if temp > 150.0:
            send_telegram_alert(f"Temp {temp:.1f}°C exceeded 150°C!")
        if pressure > 12.0:
            send_telegram_alert(f"Pressure {pressure:.2f} bar exceeded 12 bar!")
    time.sleep(5)
client.close()
  1. Execute and visualize – The AI runs the script in the sandbox, captures output, and also generates a matplotlib chart of the historical data if requested. The chart is displayed as an image inline.

  2. Return results – The AI summarizes: “Polling started. At 14:32:15, temperature was 148.2°C, pressure 10.45 bar. At 14:32:20, temperature 149.1°C, pressure 10.52 bar. No alerts triggered.” If an alert condition occurs, the AI immediately notifies the user and sends the Telegram message.

Results Achieved

  • Setup time reduced from 2‑3 days to under 2 minutes (the duration of the chat conversation).
  • Alert latency dropped from 15‑minute SCADA poll to 5 seconds.
  • No coding required – the engineer simply described the logic in English.
  • Flexibility – the same approach can be extended to write back to registers (e.g., open a relief valve via write_coil) or log data to a cloud spreadsheet.

Extending to Any Device: The Power of execute_python

While Modbus/TCP is directly supported via industrial_command, ASI Biont can connect to any device that speaks a protocol not in the built‑in list – as long as a Python library exists. Using the execute_python tool, the AI writes a custom script that runs in a secure sandbox with access to over 200 libraries including:
- pyserial (serial ports)
- paramiko (SSH)
- paho.mqtt (MQTT)
- requests, aiohttp (HTTP)
- opcua-asyncio (OPC UA)
- snap7 (Siemens S7)
- bac0 (BACnet)
- pycomm3 (EtherNet/IP)
- python-can (CAN bus)

For example, if you have an older PLC that only exposes Modbus over RS‑485, you can use the Hardware Bridge (bridge.py) to convert serial to WebSocket, then have ASI Biont talk to it via the serial:// protocol. The AI can also generate a combined script that reads from Modbus/TCP and writes to an OPC UA server for unified access.

Why This Matters for Industrial IoT

Traditional industrial automation projects often get stuck because:
- Engineers are scarce and expensive.
- Custom integration code is brittle and hard to maintain.
- Adding a new sensor or protocol requires weeks of development.

ASI Biont eliminates these bottlenecks. By using natural language as the programming interface, any plant operator or technician can bring up a Modbus/TCP connection in seconds. The AI handles the low‑level details – byte swapping, endianness, connection retries – and focuses on the business logic: “If this, then that.”

Security Considerations

Modbus/TCP was designed for isolated networks and has no built‑in authentication or encryption. When connecting ASI Biont, the PLC must be reachable over the network. Best practices:
- Use a VPN or firewall to restrict access to the PLC’s IP/port 502.
- Never expose Modbus/TCP directly to the internet.
- Consider using a local Hardware Bridge (on a Raspberry Pi) that polls the PLC and forwards only relevant data to the cloud via an authenticated WebSocket.

ASI Biont’s sandbox runs in a secure environment and does not store credentials unless explicitly saved by the user. All communication between the sandbox and the PLC is ephemeral.

Getting Started

To try the Modbus/TCP integration with ASI Biont:

  1. Go to asibiont.com and create an account.
  2. Open a new chat with the AI agent.
  3. Type a request like: “Read register 0 from Modbus/TCP at 192.168.1.50 and tell me the value.”
  4. The AI will use the industrial_command tool, connect to the device, and return the result.

No dashboard panels, no “Add Device” buttons – just a conversation. The agent automatically detects the protocol and validates the connection. For advanced scenarios, simply describe what you need (alerts, logging, trends) and the AI writes the complete Python code on the fly.

Conclusion

Modbus/TCP remains the workhorse of industrial communication, but its integration with modern AI agents unlocks new levels of efficiency. ASI Biont’s ability to connect to Modbus/TCP PLCs through natural language dramatically reduces the time and effort required to monitor and control factory floor equipment. Whether you need simple register reads or complex multi‑device orchestration, the AI handles the heavy lifting.

The case study from the chemical plant shows that what used to be a multi‑day engineering task now takes minutes – and the same paradigm applies to hundreds of other protocols (OPC UA, BACnet, MQTT, CAN bus, and more). By removing the need for manual scripting, ASI Biont democratizes industrial automation: anyone who can describe a problem can now solve it.

Try it today – connect your Modbus/TCP device to ASI Biont and see how AI transforms your workflow. Visit asibiont.com to start your first integration.

For more technical details, refer to the Modbus specification (modbus.org) and pymodbus documentation (pymodbus.readthedocs.io).

← All posts

Comments