How to Integrate Energy Meters with ASI Biont AI Agent for Smart Energy Management

Introduction

Energy meters (electricity meters) are the backbone of any smart energy management system. They provide real-time data on voltage, current, power, and cumulative energy consumption. However, raw data alone doesn’t cut costs or prevent overloading. To truly optimize energy usage, you need an intelligent layer that analyzes trends, detects anomalies, and automates actions. That’s where ASI Biont comes in. ASI Biont is an AI agent that connects to your energy meters via Modbus, MQTT, or serial protocols, interprets the data, and executes automation scenarios—all through a simple chat conversation. You describe what you need, and AI writes the integration code on the fly.

In this article, we’ll walk through concrete examples of connecting energy meters to ASI Biont, from reading Modbus registers to triggering load shedding when consumption spikes. You’ll see actual code for both Modbus/TCP and Modbus RTU (via Hardware Bridge), and learn how to build a complete energy monitoring and control system without manual programming.

1. Why Integrate Energy Meters with an AI Agent?

Traditional energy monitoring dashboards require you to manually set up data pipelines, write scripts, and configure alerts. With ASI Biont, the AI does all of that for you. Benefits include:

  • Instant connectivity: Connect any Modbus, MQTT, or serial‑based energy meter in seconds by describing the connection parameters in chat.
  • Intelligent analysis: AI calculates trends, predicts peak loads, and identifies savings opportunities.
  • Automated response: Execute actions like turning off non‑critical loads, sending notifications, or generating reports.
  • Zero coding required: No need to learn Python, Modbus libraries, or MQTT clients—AI writes the code for you.

2. Connection Methods Supported by ASI Biont

Energy meters typically expose data through one of these interfaces:

Protocol Typical Use Case ASI Biont Integration Method
Modbus/TCP Meters with Ethernet port (e.g., Eastron SDM630MCT, Schneider iEM3000) Use industrial_command with protocol='modbus', command='read_registers'
Modbus RTU via RS-485 Meters with serial output (e.g., Eastron SDM120, many DIN‑rail meters) Hardware Bridge (bridge.py) on a PC with USB‑RS485 converter; AI uses serial_write_and_read with hex‑formatted Modbus frames
MQTT Smart meters that publish data to a broker (e.g., Shelly EM, Tasmota‑flashed meters) AI writes a Python script using paho-mqtt inside execute_python, or uses industrial_command with publish
HTTP API Cloud‑connected meters (e.g., Sense, Emporia Vue) AI uses aiohttp in execute_python to fetch data via API calls

In the following sections, we’ll focus on the two most common industrial scenarios: Modbus/TCP and Modbus RTU via Hardware Bridge.

3. Real Example: Modbus/TCP Energy Meter (Eastron SDM630MCT)

3.1. The Problem

A small factory wants to monitor its main incoming power and automatically shut down non‑essential machinery when total power exceeds 50 kW to avoid demand charges.

3.2. What the User Tells ASI Biont

The user writes in the chat:

“Connect to my Eastron SDM630MCT energy meter at IP 192.168.1.100, port 502, Modbus device ID 1. Read the total active power (register 0x0034) every 10 seconds. If power exceeds 50 kW, send a command to a smart plug (Shelly Plug S at 192.168.1.200) to turn off via HTTP.”

3.3. AI’s Response: Generated Code and Execution

ASI Biont uses industrial_command with Modbus/TCP. The AI constructs the following sequence:

Step 1 – Read power register

industrial_command(
  protocol='modbus',
  command='read_registers',
  host='192.168.1.100',
  port=502,
  unit=1,
  address=0x0034,
  count=2  // 32‑bit float
)

Step 2 – Parse the response
The AI receives raw bytes, converts them to a 32‑bit float (two registers), and checks if power > 50 kW.

Step 3 – Trigger action
If threshold exceeded, AI calls:

industrial_command(
  protocol='http',
  command='post',
  url='http://192.168.1.200/relay/0?turn=toggle',
  timeout=5
)

Step 4 – Continuous loop
Because industrial_command is executed per request, the AI sets up a recurring task inside execute_python. The sandbox script runs with a 30‑second timeout, so the AI uses a non‑blocking loop with asyncio.sleep(10).

import asyncio
from pymodbus.client import AsyncModbusTcpClient

async def monitor_power():
    client = AsyncModbusTcpClient('192.168.1.100', port=502)
    await client.connect()
    while True:
        result = await client.read_input_registers(0x0034, 2, unit=1)
        power = result.registers[0] | (result.registers[1] << 16)
        power = power / 1000.0  # scale factor
        print(f"Current power: {power} kW")
        if power > 50:
            # HTTP call to smart plug
            import aiohttp
            async with aiohttp.ClientSession() as session:
                await session.post('http://192.168.1.200/relay/0?turn=toggle')
        await asyncio.sleep(10)

asyncio.run(monitor_power())

The script runs in the sandbox, connects to the meter via Modbus/TCP, and executes the HTTP action when power exceeds 50 kW.

3.4. Result

  • Real‑time power monitoring every 10 seconds.
  • Automatic load shedding when demand peaks, preventing costly demand charges.
  • The entire integration was built in seconds by simply describing the setup in chat.

4. Real Example: Modbus RTU via RS-485 (Hardware Bridge)

Many legacy energy meters use RS‑485 serial communication with Modbus RTU. ASI Biont connects to these via the Hardware Bridge (bridge.py) running on a local PC.

4.1. Setup

  1. User downloads bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge).
  2. Connects a USB‑RS485 converter to the PC and plugs it to the meter’s RS‑485 bus.
  3. Runs bridge.py:
    bash pip install pyserial requests websockets python bridge.py --token=YOUR_API_TOKEN --ports=COM3 --baud 9600

4.2. User Chat Command

“I have an Eastron SDM120 Modbus RTU meter on COM3, 9600 baud, device ID 1. Read voltage (register 0x0000), current (0x0006), power (0x000C). If power > 2.3 kW, turn on a relay at COM3 pin DTR.”

4.3. AI Action

AI uses industrial_command with protocol='serial://' and command='serial_write_and_read'. For Modbus RTU, AI must construct a valid Modbus frame (including CRC16). ASI Biont’s bridge handles raw serial read/write; the AI calculates the CRC and encodes the request as a hex string.

Example request to read register 0x0000 (voltage):

  • Modbus RTU read input register request: 01 04 00 00 00 01 31 CA (hex)
  • AI sends:
industrial_command(
  protocol='serial://COM3',
  command='serial_write_and_read',
  data='01040000000131CA'
)

The bridge transmits the 8 bytes and returns the response (e.g., 0104020E56B9A3 for 0x0E56 = 3670 → 367.0 V).

AI parses the response and converts to human‑readable values. It does this for each register. Then, if power > 2.3 kW, AI sends another serial command to set DTR high (which controls the relay):

industrial_command(
  protocol='serial://COM3',
  command='serial_write_and_read',
  data='DTR_ON'  // bridge interprets escape sequences
)

4.4. Automation without Coding

All the CRC calculation, framing, and repetition happen behind the scenes. The user never writes a line of Modbus code. ASI Biont handles it all in the chat conversation.

5. MQTT‑Based Energy Meters

Smart meters that publish data over MQTT (e.g., Shelly EM, Tasmota‑based sensors) are even simpler. The user provides the broker address and topic, and AI subscribes and processes.

Example:
User: “Connect to my MQTT broker at 192.168.1.50, topic tele/energy/SENSOR. Send me a Telegram message when daily consumption exceeds 10 kWh.”

AI writes an MQTT subscriber in execute_python using paho-mqtt. It listens to the topic, accumulates energy values, and when the threshold is reached, uses telegram.send_message (via aiohttp) to notify.

import paho.mqtt.client as mqtt
import json

daily_kwh = 0.0

def on_message(client, userdata, msg):
    global daily_kwh
    data = json.loads(msg.payload)
    power = data.get('Power', 0)  # in W
    daily_kwh += (power / 1000.0) * (5/3600)  # assume 5‑sec intervals
    if daily_kwh > 10:
        client.publish('tele/energy/alert', 'Daily limit exceeded!')
        daily_kwh = 0

client = mqtt.Client()
client.on_message = on_message
client.connect('192.168.1.50')
client.subscribe('tele/energy/SENSOR')
client.loop_forever()

This script runs in the sandbox, but note it uses loop_forever() which would exceed the 30‑second sandbox timeout. In practice, AI adapts by using non‑blocking loops or scheduling periodic checks. The key point: the user only describes the need, and AI delivers a working solution.

6. Why ASI Biont Is Different

  • No dashboard needed: Forget about “Add Device” buttons and JSON configuration. You chat with AI, and it handles the connection.
  • Unlimited protocols: Modbus, MQTT, HTTP, OPC UA, BACnet, Siemens S7, CAN bus, and more are supported out of the box. If your energy meter speaks one of these, ASI Biont can connect.
  • Adaptive automation: AI doesn’t just read data—it understands context. For example, “Turn off HVAC when electricity price exceeds $0.15/kWh” requires combining meter data with a price API. AI does that in one script.

7. Conclusion

Integrating energy meters with ASI Biont transforms raw consumption data into actionable intelligence. Whether you have a Modbus/TCP meter on the factory floor, a RS‑485 meter in an office building, or a smart meter publishing MQTT at home, ASI Biont can connect in minutes—not days. You describe the goal, AI writes the integration code, and you get real‑time monitoring and automated energy saving.

Stop writing boilerplate scripts. Start chatting with your energy data.

👉 Try it now at asibiont.com – connect your first energy meter and see the AI in action.

← All posts

Comments