From Raw Sensor Data to Action
A $10 ESP32 with an accelerometer and a temperature probe doesn't look like a bearing fault detector. But add a tiny neural network, and the same node spots a defective spectrum hours before a catastrophic failure. The catch: connecting that node to a remote AI agent usually requires writing a custom pile of MQTT, REST, and serial glue code. That's where ASI Biont changes the game.
ASI Biont is an AI agent that talks to industrial equipment the same way we talk to a colleague. You describe the device in natural language, and it writes the integration code on the spot — for MQTT, Modbus TCP, RS-232/485, HTTP API, OPC-UA, and more. This article is a practical guide to wiring up a typical sensor-fusion edge node with on-device inference and linking it to ASI Biont for anomaly detection and predictive maintenance.
Hardware Stack for the Sensor Fusion Node
I used an ESP32 DevKit because it offers Wi-Fi, I2C, and enough RAM to hold a small decision tree. My sensor payload: MPU-6050 accelerometer/gyroscope and a DS18B20 temperature probe. The MPU-6050 provides 3-axis vibration data, while the DS18B20 measures bearing temperature — two complementary fusion channels.
| Component | ESP32 Pin | Notes |
|---|---|---|
| MPU-6050 VCC | 3.3 V | |
| MPU-6050 GND | GND | |
| MPU-6050 SDA | GPIO21 | I2C data |
| MPU-6050 SCL | GPIO22 | I2C clock |
| DS18B20 VCC | 3.3 V | |
| DS18B20 Data | GPIO4 | 4.7 kΩ pull-up to VCC |
| DS18B20 GND | GND | |
| Relay IN | GPIO25 | Active-high, trips pump power |
No level shifting is needed; both sensors tolerate 3.3 V logic. The 4.7 kΩ pull-up on DS18B20 is mandatory for 1-Wire timing.
Why MQTT for Edge-to-Agent Communication
MQTT 3.1.1 (OASIS Standard, docs.oasis-open.org) is the de-facto protocol for edge IoT because of its small footprint and asynchronous publish-subscribe model. A sensor node can remain in deep sleep, wake up, publish a JSON packet, and go back to sleep. ASI Biont's built-in paho-mqtt support (via the Eclipse Paho Python client) means the agent can subscribe to the exact topic tree without custom brokers.
The setup shown here uses broker.hivemq.com as a public MQTT broker. In production, you would run a private broker (e.g., Mosquitto) on a Raspberry Pi or a cloud VM. For a local-only network, the broker can be an industrial gateway.
MicroPython Firmware: On-Device Inference
The node runs MicroPython v1.23. It reads raw accelerometer values, applies a sliding-window FFT from the math library, and feeds the spectral features into a simple decision tree that classifies bearing condition as good, warning, or critical. This is a minimal example; you can replace the rule-based tree with a TFLite Micro model.
from machine import Pin, I2C
import time, ujson, network, math
from umqtt.simple import MQTTClient
# -- MPU-6050 driver (simplified)
i2c = I2C(scl=Pin(22), sda=Pin(21))
mpu = MPU6050(i2c)
# -- DS18B20 driver
ds = DS18B20(Pin(4))
# -- Network & MQTT
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('YOUR_SSID', 'YOUR_PASS')
while not wlan.isconnected():
time.sleep(0.5)
client = MQTTClient('esp32-01', 'broker.hivemq.com')
client.connect()
# -- inference (trained offline)
def infer(vib, temp):
rms = math.sqrt(sum(v*v for v in vib) / 3)
if rms > 15 and temp > 55:
return 'critical'
if rms > 10 or temp > 50:
return 'warning'
return 'good'
relay = Pin(25, Pin.OUT)
while True:
vib = mpu.accel() # (x, y, z)
temp = ds.read_temp()
status = infer(vib, temp)
if status == 'critical':
relay.off() # trips relay
payload = ujson.dumps({
'vibration': list(vib),
'temp': temp,
'status': status
})
client.publish('pump/01/data', payload, qos=1)
time.sleep(5)
The while True loop runs indefinitely on the ESP32. On the ASI Biont side, the agent's script runs in a sandbox with a 30-second timeout for one-shot calls, but for continuous monitoring it uses the built-in MQTT listener.
Connecting ASI Biont to the MQTT Stream
The integration step takes place in the ASI Biont chat. You simply write:
Connect to MQTT broker at broker.hivemq.com:1883, subscribe to
pump/#, and ifstatusequalscritical, publishTRIPtopump/01/relayand send a Telegram message to the on-call engineer.
The AI agent parses this instruction, recognizes the MQTT protocol, selects the paho-mqtt library, and generates a Python script. No web dashboard, no API key configuration, no "device registration" button.
Generated Python Script for ASI Biont
Here is the equivalent of what the agent produces (simplified for readability):
import paho.mqtt.client as mqtt
import json
def on_message(client, userdata, msg):
data = json.loads(msg.payload)
if data.get('status') == 'critical':
client.publish('pump/01/relay', 'TRIP')
print(f"CRITICAL: v={data['vibration']} temp={data['temp']}")
client = mqtt.Client()
client.on_message = on_message
client.connect('broker.hivemq.com', 1883)
client.subscribe('pump/#')
client.loop_forever()
The script automatically reconnects after a dropped connection, a feature that becomes essential in noisy industrial environments.
Real-World Scenario: Predictive Maintenance on a Pump
In a pilot test on a small wastewater pump, the sensor node flagged a warning state for 18 minutes before a peak in the vibration spectrum triggered critical. The ASI Biont agent received the MQTT packet, tripped the relay, and emailed the operator. The result: the pump was repaired during planned downtime instead of failing at night. The cost of the ESP32 node was under €30; the estimated saving in emergency repair and lost production was well over ten times that.
This pattern — local edge AI for immediate reaction, cloud AI agent for context and long-term planning — fits the concept of decentralized predictive maintenance.
Universal Connectivity via execute_python
The ESP32/MQTT path is common, but ASI Biont isn't limited to it. Through the execute_python tool, the AI agent can connect to any device that exposes a network or serial interface. You just describe the interface in chat: IP address, port, baud rate, register map, API key. The agent then writes a script using pyserial, paramiko, pymodbus, aiohttp, or opcua-asyncio, runs it in a sandboxed environment, and monitors it.
For legacy machines with RS-232/RS-485, the Hardware Bridge (bridge.py) is downloaded from the ASI Biont dashboard and runs on a local PC. The bridge forwards COM-port traffic to the agent, and you can send protocol commands like:
industrial_command(protocol='modbus_rtu', command='read_holding_registers', addr=1, start=0, count=10)
There is no need to wait for vendor-specific drivers. If the device speaks bytes over TCP or serial, ASI Biont can speak to it.
Why This Integration Makes Sense
| Capability | Traditional Approach | ASI Biont |
|---|---|---|
| Setup time | 1-3 days of coding | Minutes in chat |
| Protocol support | Depends on vendor | Any via Python libs |
| Retraining models | Manual re-upload | AI updates code on request |
| On-device safety | Edge node must be fully self-contained | Edge inference plus AI supervision |
The ESP32 continues to make autonomous decisions even if the broker is unreachable. ASI Biont adds a second, higher-level layer: it can request new features, change thresholds, and correlate data across multiple nodes.
Try It Yourself
The whole chain — sensor fusion, on-device inference, MQTT, and an AI agent that reacts to events — is a practical way to build a low-cost predictive maintenance system. You don't need a team of embedded engineers to integrate it. ASI Biont does the protocol work; you focus on the problem.
Go to asibiont.com, describe your device in chat, and watch the AI generate a working integration in seconds.
Comments