Siemens PLC to AI Agent: Real-Time Industrial Automation with ASI Biont (No Code Required)

Introduction

If you work with Siemens S7-300, S7-400, S7-1200, or S7-1500 PLCs, you already know the pain of pulling real-time data into a dashboard, writing custom SCADA scripts, or fighting with OPC-UA configuration. Every production line change means a new HMI screen, a new tag mapping, and hours of engineering. But what if your PLC could talk directly to an AI agent that understands plain English? That’s exactly what ASI Biont does — it connects to Siemens PLCs via the snap7 library, reads and writes DBs, markers, and I/O, and lets you control everything from a Telegram chat or a simple web interface. No coding required from your side — just describe what you need in natural language, and the AI writes the integration code in seconds.

In this guide, I’ll show you exactly how to connect a Siemens S7-1200 PLC to ASI Biont, using real snap7 commands, a batch reactor example, and even a Telegram alert scenario when a temperature exceeds a threshold. You’ll learn which connection method works best, what pitfalls to avoid (watch out for DB numbers and data types), and why this approach can replace expensive SCADA layers for small-to-medium industrial setups.

Why Connect a Siemens PLC to an AI Agent?

Most factories use Siemens PLCs for their reliability and deterministic control. But accessing live data often requires either a licensed SCADA (WinCC, Ignition) or a custom Python script with snap7 that you maintain yourself. Both are inflexible: you have to pre-define every tag, every alarm, every trend. An AI agent changes this by acting as a dynamic middleware. You can ask: “What’s the current temperature in reactor R-101?” or “Turn on pump P-202 if pressure drops below 50 psi” — and the AI reads registers in real time, evaluates conditions, and writes back commands.

ASI Biont uses snap7 under the hood — the de facto open-source library for Siemens S7 communication (developed by Dave Nardella, with full support for S7-300/400/1200/1500). It communicates over the S7 protocol (TCP port 102) and can access:
- Data Blocks (DBs)
- Markers (M)
- Inputs (I)
- Outputs (Q)
- Timers and Counters

No additional hardware needed — just a network connection to the PLC.

Connection Method: Siemens S7 via snap7

From the list of ASI Biont’s supported protocols, the correct one for Siemens PLCs is Siemens S7 via snap7. The AI uses the industrial_command tool with commands like read_db, write_db, read_merker, write_merker. You don’t need to install snap7 locally — the AI runs the snap7-based script inside the ASI Biont sandbox (cloud). The sandbox has full access to the snap7 library, so you just provide the PLC’s IP address, rack, and slot (default: rack=0, slot=1 for S7-1200/1500, slot=2 for S7-300/400).

Example: Reading a Data Block

Imagine you have a Siemens S7-1200 with DB1 containing a 32-bit real value (FLOAT) at offset 0 (temperature in °C). You tell the AI: “Read DB1, offset 0, as a real value from PLC 192.168.1.10.” The AI runs:

import snap7

plc = snap7.client.Client()
plc.connect('192.168.1.10', 0, 1)  # IP, rack, slot
data = plc.db_read(1, 0, 4)  # DB1, start byte 0, length 4 bytes
temp = snap7.util.get_real(data, 0)
print(f"Temperature: {temp:.2f} °C")
plc.disconnect()

The AI then replies with the value. You don’t write a single line — just describe the task.

Real-World Use Case: Batch Reactor Monitoring & Control

Let’s take a concrete industrial scenario: a batch reactor with two sensors (temperature, pressure) and two actuators (heater valve, pressure relief valve). The PLC stores:
- DB1.DBD0: Temperature (REAL)
- DB1.DBD4: Pressure (REAL)
- DB1.DBX8.0: Heater valve status (BOOL)
- DB1.DBX8.1: Relief valve status (BOOL)

The AI agent can be configured to:
1. Read temperature and pressure every 5 seconds.
2. If temperature > 150 °C, close heater valve (write FALSE to DBX8.0).
3. If pressure > 200 psi, open relief valve (write TRUE to DBX8.1).
4. Send a Telegram alert when either condition triggers.

Step-by-Step: Set Up Telegram Alerts

  1. Create an API key in ASI Biont dashboard (Devices → Create API Key → Download bridge.py – but for S7, no bridge needed; the AI connects directly via snap7 from the cloud).
  2. Describe your setup to the AI: “My Siemens S7-1200 at 192.168.1.10, rack 0, slot 1. DB1 has temperature at 0, pressure at 4, heater valve at 8.0, relief valve at 8.1. Monitor every 5 seconds. If temp > 150, close heater. If pressure > 200, open relief. Send Telegram alert to my bot.”
  3. The AI generates and runs a Python script like this:
import snap7
import time
import requests

PLC_IP = '192.168.1.10'
RACK = 0
SLOT = 1
TELEGRAM_TOKEN = 'your_bot_token'
CHAT_ID = '123456789'

def send_telegram(message):
    url = f'https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage'
    requests.post(url, json={'chat_id': CHAT_ID, 'text': message})

plc = snap7.client.Client()
plc.connect(PLC_IP, RACK, SLOT)

try:
    while True:
        # Read temperature (DB1, offset 0, 4 bytes)
        temp_data = plc.db_read(1, 0, 4)
        temp = snap7.util.get_real(temp_data, 0)

        # Read pressure (DB1, offset 4, 4 bytes)
        press_data = plc.db_read(1, 4, 4)
        press = snap7.util.get_real(press_data, 0)

        # Check conditions
        if temp > 150.0:
            # Close heater valve (write FALSE to DBX8.0)
            plc.db_write(1, 8, b'\x00')
            send_telegram(f"⚠️ Temperature {temp:.1f}°C > 150°C — Heater closed")
        if press > 200.0:
            # Open relief valve (write TRUE to DBX8.1)
            plc.db_write(1, 9, b'\x01')  # offset 9 for bit 8.1? Actually need byte-wise
            # Correct way: read current byte, modify bit, write back
            byte_data = plc.db_read(1, 8, 1)
            snap7.util.set_bool(byte_data, 0, 1, True)  # bit 1 of byte 8
            plc.db_write(1, 8, byte_data)
            send_telegram(f"🔥 Pressure {press:.1f} psi > 200 psi — Relief valve opened")

        time.sleep(5)
except KeyboardInterrupt:
    pass
finally:
    plc.disconnect()

Pitfall: Writing a single bit in snap7 requires reading the whole byte, modifying the bit, and writing back. The AI knows this and handles it correctly.

Why This Beats Traditional SCADA

Feature Traditional SCADA (WinCC) ASI Biont + snap7
Setup time Days to weeks Minutes
Cost License + engineering hours Free AI agent (usage-based)
Flexibility Pre-defined tags, alarms Dynamic: ask anything
Remote access Requires VPN, RDP Chat interface (Telegram, Web)
Maintenance Manual tag updates AI updates on request

For small production lines, pilot plants, or R&D setups, this approach eliminates the need for a dedicated SCADA system. You get real-time data, automated responses, and alerts — all through a chat conversation.

Connecting to ANY Device via execute_python

One of the most powerful features of ASI Biont is execute_python — the AI writes and runs any Python script inside a sandbox with access to hundreds of libraries. Even if your specific device isn’t covered by the predefined industrial_command tools, you can still connect it. Just describe what you need:

“Connect to my Siemens S7-1200 at 192.168.1.10 using snap7. Read DB1 every 10 seconds and log the temperature to a PostgreSQL database.”

The AI will write a script using snap7, psycopg2, and schedule (or a simple loop) and run it. The sandbox supports:
- Industrial: snap7, pymodbus, paho-mqtt, opcua-asyncio, bac0, pycomm3, python-can
- Databases: psycopg2, asyncpg, pymysql, pymongo, redis, sqlalchemy
- Communications: slack_sdk, twilio, sendgrid
- Data: numpy, pandas, matplotlib, openpyxl

No waiting for developers to add support — connect anything with a network interface right now.

Telegram Monitoring in Action

A practical scenario: you have a Siemens S7-1200 controlling a cooling system. You want to receive a Telegram message if the coolant temperature exceeds 80 °C. Here’s how you set it up in the chat:

  1. User: “Monitor DB1.DBD0 (REAL) on my S7-1200 at 192.168.1.10, rack 0, slot 1. If value > 80, send ‘Coolant temp high: X °C’ to my Telegram bot.”
  2. AI: Creates a script that reads every 10 seconds, checks condition, sends Telegram message via requests.
  3. Result: You get alerts on your phone without any coding.

The AI also handles edge cases: if the PLC is unreachable, it retries 3 times; if the data is invalid (e.g., NaN), it logs an error and continues.

Conclusion

Connecting a Siemens S7 PLC to an AI agent like ASI Biont transforms industrial monitoring from a rigid, code-heavy task into a flexible conversation. You can read registers, write values, set up alerts, and even create automated responses — all by describing your intent in plain English. The snap7 library provides reliable, low-level access to S7-300/400/1200/1500, and the AI handles the boilerplate code, error handling, and scheduling.

Whether you’re managing a single reactor or a small production line, this approach saves engineering hours, reduces software costs, and gives you real-time visibility from anywhere. No SCADA license, no custom dashboard, no waiting for IT.

Ready to try it? Go to asibiont.com, create an API key, and describe your Siemens PLC setup in the chat. The AI will connect in seconds.

← All posts

Comments