Introduction
Industrial IoT gateways are the backbone of modern smart factories. These rugged devices sit between field-level sensors, PLCs, and the cloud, translating legacy protocols (Modbus RTU, Profibus, CAN) into IP-based communication. According to a 2025 IoT Analytics report, the global IIoT gateway market surpassed $4.5 billion, driven by demand for real-time data and predictive maintenance. Yet, integrating these gateways with AI agents typically requires custom middleware, MQTT brokers, and endless scripting.
ASI Biont changes that. Instead of writing glue code, you simply describe your gateway and connection parameters in a chat. The AI agent uses execute_python — a sandboxed environment with 60+ pre-installed libraries — to generate and run the integration code on the fly. No dashboards, no 'add device' buttons. Just a conversation that ends with your gateway feeding data into an AI pipeline.
This article shows you exactly how to connect an industrial IoT gateway to ASI Biont using MQTT, Modbus/TCP, OPC UA, or COM port via the Hardware Bridge. You'll get working code examples, wiring tips, and real-world scenarios — all without writing a single line of boilerplate.
Why Connect an IIoT Gateway to an AI Agent?
A typical Industrial IoT gateway (like the Advantech WISE-4000, Siemens IOT2050, or a custom ESP32-based gateway) collects data from:
- Temperature/pressure/vibration sensors (4-20 mA, 0-10 V)
- PLCs via Modbus RTU or Profinet
- Energy meters via M-Bus or DLMS/COSEM
- Barcode scanners and vision cameras
Historically, that data ends up in a SCADA system or a cloud dashboard. But with ASI Biont, the AI agent can:
- Detect anomalies in real time (e.g., a sudden vibration spike → predicts bearing failure)
- Send alerts via Telegram, email, or Slack when thresholds are exceeded
- Log historical trends and generate daily reports in Excel or PDF
- Automate control actions (e.g., turn off a motor if temperature exceeds 85°C)
All of this happens through a chat interface. You ask, the AI connects and acts.
Connection Methods Supported by ASI Biont
ASI Biont connects to IIoT gateways using these mechanisms:
| Method | Libraries | Typical Use Case |
|---|---|---|
| MQTT | paho-mqtt | ESP32 sending sensor data to Mosquitto broker |
| Modbus/TCP | pymodbus | Read/write registers on a Schneider PLC behind the gateway |
| OPC UA | opcua-asyncio (asyncua) | Connect to a Siemens IOT2050 running an OPC UA server |
| COM port (RS-232/485) | pyserial via Hardware Bridge | Direct serial connection to a gateway's debug UART |
| SSH | paramiko | Remote control of a Raspberry Pi-based gateway |
| HTTP API | aiohttp / requests | REST endpoints on a cellular router (e.g., Teltonika) |
The fastest path is MQTT — most modern IIoT gateways support MQTT natively. But if yours speaks Modbus or OPC UA, ASI Biont handles those too.
Real-World Scenario 1: ESP32 Gateway → MQTT → ASI Biont (Temperature & Humidity)
Device: ESP32 with DHT22 sensor, publishing to a local Mosquitto broker.
Goal: Monitor temperature in three factory zones, send alerts if any zone exceeds 40°C, log daily average to Excel.
Step 1: User describes the task in chat
"Connect to MQTT broker at 192.168.1.100:1883, subscribe to topic 'factory/temp/+', parse JSON payloads, save to a log file, and alert me if temperature > 40°C."
Step 2: AI writes and executes the code
The AI generates a Python script using paho-mqtt and runs it via execute_python. Here's the equivalent code the AI creates:
import paho.mqtt.client as mqtt
import json
from datetime import datetime
import requests # for Telegram alert
def on_message(client, userdata, msg):
topic = msg.topic
payload = json.loads(msg.payload.decode())
temp = payload.get('temperature')
zone = topic.split('/')[-1]
print(f"{datetime.now()} - Zone {zone}: {temp}°C")
# Log to file
with open('temperature_log.csv', 'a') as f:
f.write(f"{datetime.now()},{zone},{temp}\n")
# Alert if threshold exceeded
if temp and temp > 40:
requests.post("https://api.telegram.org/bot<TOKEN>/sendMessage",
json={"chat_id": "<CHAT_ID>", "text": f"🔥 Zone {zone} at {temp}°C!"})
client = mqtt.Client()
client.on_message = on_message
client.connect("192.168.1.100", 1883, 60)
client.subscribe("factory/temp/+")
client.loop_forever()
Note: The sandbox has a 30-second timeout for scripts. For long-running MQTT listeners, ASI Biont uses a persistent bridge pattern (details below).
Step 3: AI explains the result
The AI shows the latest readings, the log file content, and confirms the alert system works. The user can now ask: "Show me the average temperature for yesterday" — the AI reads the CSV and calculates it.
Real-World Scenario 2: Modbus/TCP PLC via Gateway
Device: A factory PLC (e.g., WAGO 750-8212) connected to an Moxa MGate 5105 Modbus gateway.
Goal: Read holding registers 0-10 (production counters), write to register 20 to reset counters daily.
Step 1: User command
"Connect to Modbus TCP device at 10.0.0.50:502, read registers 0 to 10, display current values, then write value 1 to register 20."
Step 2: AI executes via industrial_command tool
The AI uses the industrial_command tool with protocol modbus_tcp:
# AI generates this and runs it
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('10.0.0.50', port=502)
client.connect()
rr = client.read_holding_registers(0, 10, unit=1)
print("Current registers:", rr.registers)
# Write to register 20
wr = client.write_register(20, 1, unit=1)
print("Write status:", wr)
client.close()
Step 3: AI logs and schedules
The AI can then set up a cron-like scheduler (via a separate persistent task) to run this every hour, building a trend. The user can ask: "Plot production over the last 24 hours" — the AI generates a matplotlib chart and shows it inline.
Real-World Scenario 3: COM Port via Hardware Bridge (RS-485)
Device: An industrial gateway with a debug UART (RS-232) at COM3, 115200 baud.
Goal: Send a 'STATUS' command and parse the response for diagnostics.
How the Hardware Bridge Works
The user downloads bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge). They run it locally:
pip install pyserial requests websockets
python bridge.py --token=YOUR_API_KEY --ports=COM3 --baud=115200 --rate=10
This connects to ASI Biont via WebSocket (the only communication channel). The AI can now send serial commands using industrial_command with serial:// protocol.
Step 1: User command
"Send 'STATUS\n' to the gateway on COM3, read the response."
Step 2: AI sends the command
The AI calls:
industrial_command(
protocol='serial://',
command='serial_write_and_read',
params={'port': 'COM3', 'data': '5354415455530a'}
)
(5354415455530a is hex for 'STATUS\n')
The bridge writes to COM3 and returns the response. The AI parses it and shows the result.
Step 3: AI automates diagnostics
The user can ask: "Check the gateway status every 10 minutes and email me if it's offline." The AI sets up a persistent task using a simple loop with time.sleep(600) (within sandbox limits) or schedules via an external cron job.
Real-World Scenario 4: OPC UA Server on Siemens IOT2050
Device: Siemens IOT2050 gateway running an OPC UA server with tags for temperature, pressure, and motor speed.
Goal: Read temperature every 5 seconds, predict overheating.
Step 1: User command
"Connect to OPC UA server at opc.tcp://192.168.1.200:4840, read variable 'ns=2;s=Temperature', display value."
Step 2: AI executes
from opcua import Client
client = Client("opc.tcp://192.168.1.200:4840")
client.connect()
temp = client.get_node("ns=2;s=Temperature").get_value()
print(f"Current temperature: {temp}°C")
client.disconnect()
Step 3: AI adds predictive logic
The AI can store historical readings in memory and use a simple linear regression (scikit-learn) to predict when temperature will exceed a threshold. If the prediction is <30 minutes away, it sends an alert.
The Power of execute_python: Connect to Anything
The examples above use specific protocols, but ASI Biont's real strength is execute_python. Because the sandbox has 60+ libraries, the AI can connect to any device with an API or protocol. For example:
- HTTP API: Teltonika RUT955 router → read GPS coordinates via REST
- CAN bus: Kvaser USBcan Pro → read J1939 messages from a tractor
- BACnet: Johnson Controls Metasys → read building temperature zones
- EtherNet/IP: Allen-Bradley CompactLogix → read/write tags
- gRPC: Custom microservice on the gateway → send commands
You just describe the device and what you want. The AI writes the code, runs it, and shows results. No waiting for developers to add support — it works now.
Why This Approach Wins
| Traditional Integration | ASI Biont Integration |
|---|---|
| Write Python script manually | Describe in chat, AI writes it |
| Debug connection issues yourself | AI handles error handling and retries |
| Set up cron jobs for periodic tasks | AI creates persistent listeners |
| Build dashboard to see data | AI shows data in chat on demand |
| Add new sensors → recompile firmware | Add new sensors → describe in chat |
For factories with heterogeneous equipment, this is a game-changer. You can connect a Modbus PLC, an MQTT weather station, and an OPC UA robot arm in one conversation.
Limitations and Best Practices
- Sandbox timeout:
execute_pythonscripts timeout after 30 seconds. For long-running listeners, use the Hardware Bridge or persistent tasks. - No direct COM access from cloud: Use the Hardware Bridge for serial connections.
- Security: The Hardware Bridge runs locally — data never leaves your network unless you choose to forward it. MQTT and Modbus connections are made from the cloud sandbox, so ensure your firewall allows outbound connections to your broker/PLC.
- Rate limiting: The bridge has a
--rateflag to limit commands per second, preventing flooding of slow serial devices.
Getting Started
- Go to asibiont.com and start a chat.
- Describe your Industrial IoT gateway: model, connection method (MQTT, Modbus, OPC UA, serial), IP/port/credentials.
- Ask the AI to connect, read data, and automate something (alerts, logging, predictions).
- Watch as the AI writes and executes the code in seconds.
No coding required. No integration projects. Just a conversation that makes your factory smarter.
Conclusion
Industrial IoT gateways bridge the gap between old-school sensors and modern cloud analytics. But bridging the gap between the gateway and an AI agent used to mean days of development. ASI Biont eliminates that friction. Whether your gateway speaks MQTT, Modbus, OPC UA, or plain serial, the AI agent connects, reads, analyzes, and acts — all through a chat interface.
Stop writing glue code. Start telling your AI what to do.
👉 Try it now at asibiont.com — connect your first IIoT gateway in under 5 minutes.
Comments