Introduction
Industrial IoT gateways—like Siemens IOT2050, Advantech ARK series, or Dell Edge Gateways—are the backbone of modern smart factories. They collect sensor data (temperature, pressure, vibration) from PLCs, Modbus controllers, and OPC UA servers, then forward it to cloud platforms for analysis. But traditional integration requires scripting MQTT clients, writing REST handlers, and maintaining custom logic for each device. ASI Biont changes this: you describe your gateway in plain English, and the AI agent writes the integration code on the fly.
This article is a step-by-step guide to connecting an Industrial IoT gateway to ASI Biont using MQTT and Modbus/TCP—two protocols widely supported by these gateways. You’ll learn how to set up an MQTT bridge, define automation scenarios (alerts, parameter tuning), and leverage AI without writing a single line of Python yourself.
Why Connect an Industrial IoT Gateway to an AI Agent?
Industrial IoT gateways are powerful but complex. They often run Linux (Yocto, Ubuntu) and support multiple protocols simultaneously: Modbus TCP for PLCs, MQTT for cloud uplink, and HTTP APIs for configuration. Connecting them to an AI agent like ASI Biont unlocks:
- Real-time anomaly detection: AI reads sensor streams and triggers alerts when values exceed thresholds.
- Automatic parameter adjustment: If pressure drops, the AI sends a Modbus write command to adjust a valve.
- Chat-based control: Operators ask “What is the current temperature on line 3?” and the AI fetches the value in seconds.
All without a graphical dashboard. The entire interaction happens through a chat conversation—you describe the task, and the AI writes and executes the integration.
How ASI Biont Connects to an Industrial IoT Gateway
ASI Biont supports multiple connection methods for gateways. The most common are:
| Method | Protocol | Use Case |
|---|---|---|
| MQTT | paho-mqtt | Cloud-to-gateway messaging; gateways publish sensor data to a broker, ASI Biont subscribes and publishes commands back. |
| Modbus/TCP | pymodbus | Direct read/write to PLC registers or Modbus-enabled sensors behind the gateway. |
| SSH | paramiko | Execute shell commands or Python scripts on the gateway itself (e.g., to control GPIO). |
| OPC UA | opcua-asyncio | Read structured tags from OPC UA servers that the gateway exposes. |
| HTTP API | aiohttp | Interact with gateway’s own REST API (e.g., Advantech’s WISE-PaaS). |
In practice, you often combine MQTT for data collection with Modbus/TCP for control. For example, a Siemens IOT2050 reads Modbus registers from a PLC and publishes the values to an MQTT broker. ASI Biont subscribes to that topic, analyzes the data, and if a threshold is crossed, it publishes a command back to the gateway, which then writes a Modbus register to adjust the process.
Concrete Use Case: Siemens IOT2050 + MQTT + Modbus/TCP
Imagine a factory with a Siemens IOT2050 gateway connected to a Modbus/TCP PLC that controls a pump. The gateway publishes pump pressure (register 40001) to an MQTT broker every 5 seconds. You want ASI Biont to:
1. Monitor the pressure.
2. If pressure drops below 3 bar, send a Telegram alert.
3. If pressure stays low for 30 seconds, automatically increase the pump speed by writing to Modbus register 40002.
Step 1: Configure the Gateway to Publish MQTT Data
On the Siemens IOT2050 (running Node-RED or custom Python), you set up an MQTT client publishing to broker.hivemq.com:1883, topic factory/pump/pressure. The payload is JSON: {"value": 3.5, "unit": "bar"}.
Step 2: Describe the Integration to ASI Biont
In the ASI Biont chat, you write:
Connect to MQTT broker at broker.hivemq.com:1883, subscribe to topic
factory/pump/pressure. Also connect via Modbus TCP to the gateway IP 192.168.1.100:502. When pressure drops below 3 bar, send a Telegram alert to chat ID 123456789. If pressure is still below 3 bar after 30 seconds, write value 1500 to register 40002 (pump speed).
Step 3: AI Generates and Runs the Code
ASI Biont’s AI (via execute_python) writes a Python script using paho-mqtt and pymodbus. Here’s a simplified version of what it runs:
import paho.mqtt.client as mqtt
from pymodbus.client import ModbusTcpClient
import json
import time
from datetime import datetime, timedelta
# Configuration
MQTT_BROKER = "broker.hivemq.com"
MQTT_PORT = 1883
MQTT_TOPIC = "factory/pump/pressure"
MODBUS_IP = "192.168.1.100"
MODBUS_PORT = 502
PRESSURE_REGISTER = 40001
PUMP_SPEED_REGISTER = 40002
TELEGRAM_CHAT_ID = 123456789
PRESSURE_THRESHOLD = 3.0
ALERT_DELAY = 30 # seconds
modbus_client = ModbusTcpClient(MODBUS_IP, port=MODBUS_PORT)
modbus_client.connect()
low_pressure_start = None
def on_message(client, userdata, msg):
global low_pressure_start
data = json.loads(msg.payload.decode())
pressure = data["value"]
print(f"Received pressure: {pressure} bar")
if pressure < PRESSURE_THRESHOLD:
if low_pressure_start is None:
low_pressure_start = datetime.now()
# Send Telegram alert (simplified)
print(f"ALERT: Pressure below threshold! Sending Telegram to {TELEGRAM_CHAT_ID}")
elif (datetime.now() - low_pressure_start).seconds > ALERT_DELAY:
# Write pump speed
modbus_client.write_register(PUMP_SPEED_REGISTER, 1500)
print("Increased pump speed to 1500")
low_pressure_start = None
else:
low_pressure_start = None
mqtt_client = mqtt.Client()
mqtt_client.on_message = on_message
mqtt_client.connect(MQTT_BROKER, MQTT_PORT, 60)
mqtt_client.subscribe(MQTT_TOPIC)
mqtt_client.loop_forever()
The AI runs this script in a sandboxed environment (30-second timeout). Since MQTT subscriptions are event-driven, the script stays alive and reacts to incoming messages.
Step 4: Monitoring via Chat
You can also ask the AI in real time:
“What is the current pump pressure?”
The AI writes a quick script that publishes a request to the gateway’s MQTT topic and waits for the reply. It then returns the value in natural language.
Alternative Connection: Hardware Bridge for Local COM Ports
If your gateway exposes data via RS-232/RS-485 (common with older PLCs), use the Hardware Bridge. You run bridge.py on your local PC (Windows/Linux/macOS) with your API token:
python bridge.py --token=YOUR_API_KEY --ports=COM3 --default-baud=9600
Then in ASI Biont chat, command:
industrial_command(protocol='bridge://', command='read', params={'serial_path': 'COM3', 'baud': 9600, 'data': 'request'})
The AI reads the response and acts on it.
Why This Approach Beats Traditional Coding
| Aspect | Traditional Integration | ASI Biont AI Integration |
|---|---|---|
| Setup time | Hours to days (write MQTT client, Modbus logic) | Seconds (describe in chat) |
| Code maintenance | You update libraries, fix bugs | AI regenerates code on demand |
| Protocol support | Must manually install and configure libraries | AI picks the right library (pymodbus, paho-mqtt) automatically |
| Error handling | You write try/except blocks | AI includes error handling in generated code |
| Scalability | Add new devices = more code | Describe new device in chat |
Conclusion
Industrial IoT gateways are powerful, but their true potential is unlocked when combined with an AI agent that can read, analyze, and act on data without manual programming. ASI Biont connects to any gateway via MQTT, Modbus/TCP, SSH, OPC UA, or Hardware Bridge—all through a simple chat conversation. You describe the task, the AI writes the Python code, and your factory becomes smarter in minutes.
Ready to automate your industrial gateway? Go to asibiont.com, create an API key, and start chatting with your AI integration engineer.
Comments