How to Integrate OPC-UA (SCADA/DCS) with an AI Agent: Real-Time Telemetry and Predictive Alerts via ASI Biont

Why Connect OPC-UA to an AI Agent?

In industrial automation, OPC-UA (Open Platform Communications Unified Architecture) is the gold standard for secure, platform-independent data exchange between controllers, SCADA systems, and DCS. But raw OPC-UA data—temperature, pressure, flow rates—is only useful if someone (or something) monitors it, detects anomalies, and triggers actions. Traditional SCADA requires manual rule configuration, custom scripts, and constant human oversight.

An AI agent like ASI Biont changes that. Instead of writing Python scripts yourself or waiting for a developer, you simply describe your OPC-UA server and what you want to achieve in a chat. The AI writes the integration code, connects to the server using the opcua-asyncio library, reads tags, analyzes trends, and can even write values back to controllers. No dashboards, no drag-and-drop builders—just a conversation.

How ASI Biont Connects to OPC-UA

ASI Biont uses the industrial_command tool with the protocol='opcua' parameter. Under the hood, the AI generates a Python script using the asyncua library (the opcua-asyncio package) and runs it in a secure sandbox environment. The script connects to your OPC-UA server via TCP (opc.tcp://ip:port), reads variables by their node IDs, and returns the data to the chat. You can also write variables (e.g., set a setpoint) by sending a command like:

industrial_command(protocol='opcua', command='write_variable', params={'node_id': 'ns=2;i=1234', 'value': 75.0})

Real-World Use Case: Predictive Alerts for a Boiler Temperature

Imagine a factory with a boiler controlled by a DCS that exposes OPC-UA tags: Boiler.Temperature, Boiler.Pressure, Boiler.ValvePosition. The goal:
- Monitor temperature every 10 seconds.
- Send a Telegram alert if temperature exceeds 150°C.
- Predict failure by detecting a rising trend over 5 minutes.
- Allow operators to adjust the valve position via chat.

Step 1: Describe the Task in Chat

User types:

Connect to OPC-UA server at opc.tcp://192.168.1.100:4840, read tag ns=2;s=Boiler.Temperature, check if >150°C, send Telegram alert. Also, if temperature rises by more than 5°C in 5 minutes, warn about possible failure. Let me write a new valve position via ns=2;s=Boiler.ValvePosition.

Step 2: AI Generates the Integration Code

The AI writes a Python script using asyncua and asyncio. Since the sandbox has a 30-second timeout, the script runs a single read-check cycle and returns the result (for continuous monitoring, the AI can set up a scheduled task or use a loop with sleep, but for demo, we do one cycle).

Here’s a simplified example of the code the AI might generate:

import asyncio
from asyncua import Client

async def read_and_alert():
    url = "opc.tcp://192.168.1.100:4840"
    async with Client(url=url) as client:
        # Read temperature
        temp_node = client.get_node("ns=2;s=Boiler.Temperature")
        temp = await temp_node.read_value()

        # Read historical values for trend (simulate last 5 readings)
        # In real scenario, you'd subscribe or read history

        if temp > 150:
            # Send Telegram alert via another ASI Biont tool
            print(f"ALERT: Temperature {temp}°C exceeds 150°C!")
            # In real integration, AI would call send_telegram_message()

        # Write valve position (example: set to 45%)
        valve_node = client.get_node("ns=2;s=Boiler.ValvePosition")
        await valve_node.write_value(45.0)
        print(f"Valve position set to 45%")

        return {"temperature": temp, "valve": 45.0}

result = asyncio.run(read_and_alert())
print(result)

Step 3: AI Executes and Reports

The AI runs the script in the sandbox, gets the result, and responds in chat:

Connected to OPC-UA server. Current temperature: 142.5°C. No alert needed. Valve position updated to 45%. Would you like me to set up a scheduled check every 10 seconds?

If the user says yes, the AI can create a recurring task using ASI Biont’s scheduling feature (not covered here, but available).

Benefits of AI-Driven OPC-UA Integration

  • Zero coding for operators: Describe what you want in plain English. The AI writes the Python code instantly.
  • Flexible protocols: If your controller uses Modbus, MQTT, or Siemens S7 (via snap7), the AI can switch protocols by simply changing the protocol parameter.
  • Real-time decision making: The AI can combine OPC-UA data with external sources (weather API, production schedule) to make smarter decisions.
  • No hardware changes: Works with existing OPC-UA servers—no need to install agents or modify PLC logic.

Pitfalls to Avoid

  • Node ID syntax: OPC-UA node IDs vary (numeric, string, GUID). Always check your server’s address space (e.g., with UA Expert). The AI might guess wrong—just correct it in chat.
  • Security: If your OPC-UA server uses authentication, provide username/password or certificate in the chat. The AI can handle it via Client(url, username='...', password='...').
  • Sandbox timeout: For continuous monitoring, use ASI Biont’s scheduled tasks (ask the AI to set one up). Don’t run infinite loops in execute_python.

Conclusion

Integrating OPC-UA with an AI agent like ASI Biont turns your SCADA/DCS data into an intelligent, conversational assistant. Instead of complex dashboards and manual scripting, you get real-time alerts, predictive insights, and control via chat—all generated automatically by the AI.

Ready to connect your OPC-UA server? Start a chat at asibiont.com and tell the AI what you need. No setup, no coding—just results.

← All posts

Comments