OPC-UA Integration with ASI Biont: AI-Driven SCADA and DCS Automation
Introduction
Industrial automation systems—SCADA (Supervisory Control and Data Acquisition) and DCS (Distributed Control Systems)—rely on OPC-UA (Open Platform Communications Unified Architecture) to standardize data exchange between sensors, controllers, and enterprise applications. OPC-UA is the de facto protocol for Industry 4.0, supported by Siemens, Rockwell, Schneider Electric, ABB, and over 400 vendors (OPC Foundation, 2025). However, connecting OPC-UA servers to AI agents for intelligent decision-making often requires custom scripting, middleware, and extensive engineering time.
ASI Biont changes this: instead of writing and maintaining brittle Python scripts, you describe your OPC-UA server in a chat, and the AI agent generates the integration code, reads tags, and triggers actions—from emergency shutdowns to Telegram alerts. In this article, we’ll walk through a real-world architecture, provide a working code example using asyncua (opcua-asyncio), and show how to replace manual scripting with AI-driven automation.
Why Connect OPC-UA to an AI Agent?
In a typical factory, OPC-UA servers expose hundreds or thousands of tags: temperature, pressure, flow rate, motor status, valve position. Operators monitor these via HMI screens. But manual monitoring is error-prone—operators miss subtle trends, delays in response cause downtime. AI agents can:
- Continuously read tags and detect anomalies (e.g., temperature rising beyond threshold).
- Execute automated responses: send shutdown commands, log events to Notion, alert via Telegram.
- Predict failures using historical data (if integrated with a database).
ASI Biont connects directly to any OPC-UA server via the industrial_command tool, using opcua-asyncio (the asyncua library). No middleware, no custom API—just a chat conversation.
Architecture: ASI Biont + OPC-UA
┌──────────────────┐ ┌──────────────────────┐ ┌──────────────────┐
│ OPC-UA Server │ │ ASI Biont Cloud │ │ Telegram / Notion│
│ (SCADA/DCS) │◄────────│ (execute_python) │────────►│ (alerts, logs) │
│ tags: temp, │ asyncua│ AI generates script │ └──────────────────┘
│ pressure, motor │ │ industrial_command │
└──────────────────┘ └──────────────────────┘
The user provides connection parameters (IP, port, username/password or certificate). ASI Biont’s AI writes a Python script using asyncua and runs it in a sandbox (30-second timeout). The script connects to the OPC-UA server, reads or writes variables, and returns results to the chat.
Connection Methods: OPC-UA via industrial_command
ASI Biont supports OPC-UA through the industrial_command tool with commands:
| Command | Description | Example |
|---|---|---|
read_variable |
Read a single OPC-UA variable (tag) | industrial_command(protocol='opcua', command='read_variable', params={'node_id': 'ns=2;i=1001', 'url': 'opc.tcp://192.168.1.100:4840'}) |
write_variable |
Write a value to a variable | industrial_command(protocol='opcua', command='write_variable', params={'node_id': 'ns=2;i=2001', 'value': 1.0, 'url': 'opc.tcp://192.168.1.100:4840'}) |
browse |
List child nodes under a parent | industrial_command(protocol='opcua', command='browse', params={'node_id': 'ns=2;i=1000', 'url': 'opc.tcp://192.168.1.100:4840'}) |
For complex workflows (e.g., polling multiple tags every 5 seconds), the AI writes a custom Python script using execute_python with asyncua.
Step-by-Step Use Case: Emergency Shutdown Based on Temperature
Scenario
A chemical reactor has an OPC-UA server exposing tags:
- ns=2;i=1001 — temperature (float, °C)
- ns=2;i=1002 — pressure (float, bar)
- ns=2;i=2001 — emergency_shutdown (boolean, writable)
If temperature exceeds 85°C for more than 10 seconds, AI should write True to emergency_shutdown, log the event to Notion, and send a Telegram alert.
Step 1: User Describes the Task in Chat
“Connect to OPC-UA server at opc.tcp://192.168.1.100:4840. Read temperature (ns=2;i=1001) every 5 seconds. If temp > 85 for two consecutive readings, write True to emergency_shutdown (ns=2;i=2001). Log to Notion and send Telegram alert.”
Step 2: AI Generates the Script
ASI Biont’s AI writes a Python script using asyncua (opcua-asyncio). Below is a simplified version:
import asyncio
from asyncua import Client
import requests
# Configuration
OPC_URL = "opc.tcp://192.168.1.100:4840"
TEMP_NODE = "ns=2;i=1001"
SHUTDOWN_NODE = "ns=2;i=2001"
THRESHOLD = 85.0
CONSECUTIVE_READINGS = 2
# Notion and Telegram tokens (provided by user)
NOTION_TOKEN = "ntn_..."
TELEGRAM_BOT_TOKEN = "bot..."
TELEGRAM_CHAT_ID = "123456"
async def main():
async with Client(url=OPC_URL) as client:
temp_var = await client.nodes.root.get_child(TEMP_NODE)
shutdown_var = await client.nodes.root.get_child(SHUTDOWN_NODE)
consecutive_high = 0
while True:
temp = await temp_var.read_value()
print(f"Temperature: {temp}°C")
if temp > THRESHOLD:
consecutive_high += 1
if consecutive_high >= CONSECUTIVE_READINGS:
# Trigger shutdown
await shutdown_var.write_value(True)
print("Emergency shutdown initiated")
# Log to Notion
headers = {"Authorization": f"Bearer {NOTION_TOKEN}", "Content-Type": "application/json"}
data = {"parent": {"database_id": "your_db_id"}, "properties": {"Title": {"title": [{"text": {"content": "Emergency Shutdown"}}]}, "Temperature": {"number": temp}}}
requests.post("https://api.notion.com/v1/pages", headers=headers, json=data)
# Send Telegram alert
url = f"https://api.telegram.org/{TELEGRAM_BOT_TOKEN}/sendMessage"
requests.post(url, json={"chat_id": TELEGRAM_CHAT_ID, "text": f"🚨 Emergency shutdown triggered! Temperature: {temp}°C"})
break
else:
consecutive_high = 0
await asyncio.sleep(5)
asyncio.run(main())
Note: The actual AI-generated script will include error handling, reconnection logic, and user-specific tokens. The sandbox enforces a 30-second timeout, so for continuous monitoring, the script runs as a one-shot verification; the AI then sets up a scheduled task in ASI Biont (e.g., cron trigger every 5 minutes).
Step 3: AI Executes the Script and Returns Results
The AI runs the script in the sandbox. If successful, it confirms the connection and shows the first reading. The user can then ask to run it periodically or adjust parameters.
Alternative: Using industrial_command Directly
For simple read/write operations, you don’t need a full script. Just ask:
“Read temperature from OPC-UA server at 192.168.1.100:4840, node ns=2;i=1001”
The AI uses industrial_command:
industrial_command(
protocol='opcua',
command='read_variable',
params={
'url': 'opc.tcp://192.168.1.100:4840',
'node_id': 'ns=2;i=1001'
}
)
Response: Temperature: 72.3°C
Real-World Automation Scenarios
| Scenario | AI Action | Integration |
|---|---|---|
| Emergency shutdown | Read temp/pressure, write shutdown command | Telegram alert + Notion log |
| Daily log generation | Read all tags at 8:00 AM, generate Excel report | Email report via SendGrid |
| Predictive maintenance | Read motor vibration, check against trend | If anomaly → Slack message to engineer |
| Batch recipe control | Write setpoints to DCS based on user request | Chat: “Start batch 42” → AI writes recipe |
How to Connect: User’s Perspective
- Sign up at asibiont.com (free tier available).
- Start a chat with the AI agent.
- Describe your OPC-UA server: “Connect to opc.tcp://192.168.1.100:4840, username=admin, password=pass123”
- Ask for a task: “Read temperature every 5 minutes and log to Notion if above 80°C.”
- AI writes the code, runs it, and confirms. You see the results in the chat.
No dashboards to configure, no “add device” buttons. Everything is conversation-driven.
Why This Matters for Control Engineers
Traditional SCADA integration requires:
- Installing OPC-UA client libraries (e.g., UA Expert, Python-opcua).
- Writing scripts with error handling, reconnection, logging.
- Maintaining cron jobs or scheduled tasks.
With ASI Biont, an engineer who knows the tag names can automate in minutes—no Python expertise needed. The AI handles boilerplate code, edge cases, and integration with external services (Telegram, Notion, Slack, databases).
Limitations and Best Practices
| Limitation | Mitigation |
|---|---|
| 30-second sandbox timeout | Use scheduled tasks (cron) for continuous monitoring |
| No direct access to local network from cloud | Ensure OPC-UA server is reachable via public IP or VPN |
| OPC-UA security (certificates) | Provide certificate file in script via base64 encoding |
Conclusion
OPC-UA integration with ASI Biont transforms industrial automation from manual scripting to AI-driven conversation. Whether you need emergency shutdowns, daily reports, or predictive maintenance, the AI agent connects to your SCADA/DCS in seconds. No middleware, no waiting for developer support.
Try it yourself: Go to asibiont.com, sign up, and tell the AI: “Connect to my OPC-UA server and monitor temperature.” The future of industrial automation is a chat away.
Comments