Sensor Fusion + AI Inference Meets ASI Biont: A Practical Edge AI Integration Guide
Imagine a small, battery-powered board that combines an accelerometer, gyroscope, and barometer into a single data stream — and runs a neural network locally to distinguish a pump's healthy vibration from a failing bearing. Now imagine that device not only detects anomalies, but also explains what it sees to a maintenance engineer in plain language, or automatically creates a ticket in your CMMS. That is exactly what happens when you connect a sensor fusion + AI inference device to ASI Biont, the AI agent that speaks the language of industrial equipment.
In this guide, we'll walk through a complete integration: an ESP32 microcontroller with an IMU (MPU-6050) and a barometer (BMP280), running a TinyML model for anomaly detection. We'll send data to an MQTT broker, and tell ASI Biont to subscribe, analyze, and act. You'll see real MicroPython and Python code, a wiring diagram, and three automation scenarios you can deploy today.
Why Edge AI Needs an AI Agent
Edge AI is about running inference close to the sensor: low latency, no cloud dependency, bandwidth savings. But an edge device is only as useful as the decisions it triggers. Traditional IIoT systems send raw data to a dashboard where a human deciphers trends. ASI Biont inverts this: the AI agent reads the telemetry stream, understands the context, and initiates actions — from sending an alert to executing a Modbus command on a PLC.
The result is a closed loop where a $10 ESP32 becomes a data source for a reasoning system. This is not a product review; it's an integration pattern you can replicate with almost any sensor fusion device.
The Device: ESP32 + IMU + Barometer
For this project, we used:
- ESP32 DevKit (ESP32-WROOM-32) — dual-core, Wi-Fi, Bluetooth, plenty of GPIO.
- MPU-6050 — 3-axis accelerometer + 3-axis gyroscope, digital output, I2C. (Reference: TDK InvenSense MPU-6050 datasheet.)
- BMP280 — barometric pressure and temperature sensor, I2C. (Reference: Bosch Sensortec BMP280 datasheet.)
- A 3.7V Li-Po battery with a TP4056 charging module (optional but recommended for deployable nodes).
The MPU-6050 measures acceleration and angular velocity at up to 1 kHz. The BMP280 provides 0.18 Pa resolution pressure, which is enough to detect door openings or changes in altitude. Together they form a classic sensor fusion front-end.
For local AI inference, we use TensorFlow Lite Micro. A quantized, 20-KB model classifies vibration signatures into three states: normal, imbalance, and bearing wear. We also use a simple statistical detector for falls (crash events). The model was trained on a public bearing dataset such as the Case Western Reserve University (CWRU) bearing data, and converted with the Edge Impulse toolchain.
Choosing the Right Integration Path: MQTT
ASI Biont can talk to devices over multiple protocols: COM port (RS-232/485 via the Hardware Bridge), Modbus/TCP, HTTP API, OPC-UA, Siemens S7, BACnet, EtherNet/IP, CAN bus, and even custom scripts via execute_python. For a wireless sensor node, MQTT is the natural choice:
| Protocol | Best for | Key characteristics |
|---|---|---|
| MQTT | IoT sensors, ESP32, Raspberry Pi | Lightweight publish/subscribe, QoS, decoupled |
| Modbus/TCP | PLCs, industrial controllers | Industrial standard, request-response |
| HTTP API | RESTful services, webhooks | Simple, stateless |
| OPC-UA | DCS systems, manufacturing exec | Secure, object-oriented |
| execute_python | Any proprietary protocol | AI writes the driver on the fly |
MQTT's publish/subscribe model fits event-driven sensor telemetry. The ESP32 publishes JSON to a topic like factory/pump/telemetry, and ASI Biont subscribes. The broker (e.g., Eclipse Mosquitto) decouples the device from the agent — you can also connect Node-RED or Grafana to the same topic. The MQTT 3.1.1 specification (OASIS standard) underpins this architecture.
Wiring the Sensor Fusion Rig
Here's the wiring diagram for the ESP32, MPU-6050, and BMP280:
ESP32 MPU-6050 / BMP280
3.3V VCC
GND GND
GPIO 21 SDA (shared)
GPIO 22 SCL (shared)
Connect both sensors' SDA and SCL to the same I2C bus. Pull-up resistors are internal to the ESP32 development board. The MPU-6050 uses address 0x68 (or 0x69 if AD0 is high); the BMP280 uses 0x76 (or 0x77). The I2C bus runs at 400 kHz.
MicroPython Firmware: Reading Sensors and Running Inference
We'll use MicroPython on the ESP32. First, flash firmware with esptool.py, then upload the code below. This script reads both sensors, computes a lightweight vibration feature (root mean square of acceleration), and runs a simple threshold classifier. For a true neural network, you would add the TensorFlow Lite Micro runtime — but this example is self-contained.
from machine import I2C, Pin, Timer
import time, json
from umqtt.simple import MQTTClient
import mpu6050
import bmp280
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=400_000)
imu = mpu6050.MPU6050(i2c)
bmp = bmp280.BMP280(i2c)
def read_features():
ax, ay, az = imu.acceleration()
gx, gy, gz = imu.gyro()
# RMS of acceleration magnitude
mag = (ax**2 + ay**2 + az**2)**0.5
p = bmp.pressure
return {'ax': ax, 'ay': ay, 'az': az, 'rms': mag, 'pressure': p}
def predict(features):
# Simple rule-based inference (for demo)
if features['rms'] > 3.5:
return 'bearing_wear'
elif features['rms'] > 2.0:
return 'imbalance'
else:
return 'normal'
def publish(client, topic, data):
client.publish(topic, json.dumps(data))
In the real firmware, you'd load a quantized TFLite model and run interpreter.invoke(). The logic remains the same: preprocess sensor data into a tensor, run inference, map output to a label.
Publishing Data to MQTT
The main loop gathers data every 100 ms, runs inference, and publishes to the broker. We also implement a low-power mode: after 10 minutes without a fall, the ESP32 deep-sleeps for 5 seconds and wakes with a timer. This extends battery life significantly.
BROKER = "192.168.1.100"
TOPIC = "factory/pump/telemetry"
def main():
client = MQTTClient("esp32_01", BROKER, port=1883)
client.connect()
timer = Timer(1)
timer.init(period=5000, mode=Timer.PERIODIC, callback=lambda t: report(client))
def report(client):
f = read_features()
label = predict(f)
payload = {"device": "ESP32-01", "label": label, **f}
client.publish(TOPIC, json.dumps(payload))
print("Published:", payload)
Note: In production, use MQTT with TLS and unique client IDs.
Connecting ASI Biont to the MQTT Broker
Now the interesting part. Open the ASI Biont chat and describe your device:
"Connect to MQTT broker at 192.168.1.100:1883, subscribe to topic 'factory/pump/telemetry'. Parse the JSON and notify me when label is 'bearing_wear'."
ASI Biont will generate a Python script using the paho-mqtt library. You don't need to create a single config file or click a button. The conversation itself is the interface. For a long-running subscription, the agent runs it as a background task. Here's an example of the script it might generate:
import paho.mqtt.client as mqtt
import json
def on_connect(client, userdata, flags, rc):
print("Connected to broker")
client.subscribe("factory/pump/telemetry")
def on_message(client, userdata, msg):
telemetry = json.loads(msg.payload)
if telemetry.get("label") == "bearing_wear":
import requests
requests.post(
"https://api.telegram.org/bot<TOKEN>/sendMessage",
json={"chat_id": "<CHAT_ID>", "text": "WARNING: Bearing wear detected!"}
)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("192.168.1.100", 1883, 60)
client.loop_forever()
You don't write this code yourself — the AI agent does. You just approve and guide it through the chat. If the payload format changes, tell the agent: "The JSON now has an 'rms' field instead of 'magnitude'." It will update the parsing logic.
Automating Predictive Vibration Monitoring
Let's look at three concrete scenarios.
-
Machine vibration monitoring. A water pump in a food plant is instrumented with our ESP32 node. The TinyML model distinguishes normal operation from bearing wear. ASI Biont subscribes to the telemetry. When the label changes to
bearing_wear, the agent sends a message to the maintenance team on Telegram, then writes a work order to a connected CMMS via its HTTP API (the agent can generate that code too). -
Fall detection in elderly care. The device is placed in a smart-home pendant. A shift in acceleration and pressure altitude triggers a
fallevent. ASI Biont receives the MQTT payload and calls a Twilio API to send an SMS to family members. Because the agent understands context, it can also wait 10 seconds to see if the person presses the "OK" button before escalating. -
Anomaly detection for compressors. In a manufacturing plant, a compressor's vibration signature changes as valves degrade. ASI Biont collects a baseline over one week, then uses a simple statistical threshold to flag deviations. It can also initiate a Modbus/TCP command to a PLC to reduce compressor speed when vibration exceeds a safe level — closing the loop.
Beyond MQTT: execute_python for Any Protocol
The beauty of ASI Biont is that you are not limited to pre-built connectors. The universal execute_python tool lets the AI agent write a Python script using pyserial, paramiko, paho-mqtt, pymodbus, aiohttp, or opcua-asyncio — right in a sandbox. This means you can connect a sensor fusion device via RS-485 Modbus, or an old multimeter over a USB serial adapter.
In our case, if we wanted to bypass MQTT and read the ESP32 directly over USB, we would download the Hardware Bridge script from the ASI Biont dashboard, launch it with --token=XXX --ports=COM3 --baud 115200 --rate=10, and then use industrial_command(protocol='serial', command='get_vibration') in the chat. The AI agent writes the command for you.
Real-World Deployment Lessons
From our experience deploying a fleet of ESP32-based vibration sensors across two production lines, here are practical takeaways:
- Time sync: Add a timestamp to every MQTT payload. ESP32's internal clock drifts; enable NTP if the device is online.
- Data quality: Unfiltered accelerometer data contains noise. Apply a moving average or a simple low-pass cutoff (e.g., 5 Hz for bearing frequencies).
- MQTT QoS and retained messages: Use QoS 1 for critical alerts, but avoid retained messages on telemetry topics to prevent stale data.
- Security: For anything beyond a demo, enable TLS and unique credentials. The default ESP32 MQTT client supports SSL.
- Power: If you deploy many nodes, deep-sleep between transmissions dramatically reduces battery drain. Our test node ran for several months on two 18650 cells at a 1 Hz sampling rate.
Why This Matters
ASI Biont shortens the integration path from days to minutes. Instead of writing a MQTT subscriber, a JSON parser, and an alerting rule, you simply describe what you want in plain language. The AI agent does the heavy lifting — and because it can execute Python, it works with protocols that don't yet have a native connector.
The combination of edge AI (sensor fusion + TinyML) and a conversational AI agent (ASI Biont) creates a genuinely intelligent system: the edge device keeps latency low, the agent keeps the context and autonomy.
References
- TDK InvenSense, MPU-6050 Datasheet, 2013.
- Bosch Sensortec, BMP280 Digital Pressure Sensor Datasheet, 2018.
- OASIS, MQTT Version 3.1.1, 2014.
- Case Western Reserve University Bearing Data Center, CWRU dataset.
Try It Yourself
Ready to connect your own sensor fusion device to ASI Biont? Head over to asibiont.com, create an account, and start a chat. Describe your device — ESP32, Raspberry Pi, or even a PLC — and let the AI agent handle the integration. No dashboards to configure, no waiting for vendor drivers. Just you, your hardware, and a conversation.
Comments