Introduction
Modern edge devices combine multiple sensors — accelerometers, gyroscopes, magnetometers, temperature, and humidity sensors — into a single fusion node. When paired with on-device machine learning (ML), such systems can detect gestures, classify motion, predict anomalies, and trigger real-time actions without cloud dependency. But extracting value from raw sensor data often requires complex signal processing, calibration, and decision logic. That's where ASI Biont enters: an AI agent that connects to any sensor fusion device via MQTT, COM port, SSH, or HTTP API, writes the integration code on the fly, and orchestrates automation scenarios — from smart home gestures to industrial predictive maintenance.
This article is a practical guide: we'll explore how ASI Biont connects to a multi-sensor microcontroller (e.g., ESP32 with MPU9250 + DHT22), runs Kalman filtering and gesture recognition on the edge, and enables advanced automation without manual programming.
Why Connect Sensor Fusion + AI Inference to an AI Agent?
Sensor fusion generates high-dimensional, noisy data streams. Traditional approaches require:
- Manual calibration (offsets, scaling)
- Custom filtering algorithms (complementary, Kalman)
- Hard-coded thresholds for event detection
- Separate cloud or local server for ML inference
ASI Biont eliminates this overhead. The AI agent:
- Writes and deploys the fusion/ML code directly to the device (via MicroPython/Arduino over COM or MQTT)
- Connects to the device in real time, reads fused data, and applies higher-level reasoning (trend analysis, anomaly detection, multi-sensor correlation)
- Triggers actions — send alerts, control actuators, update dashboards — based on AI-driven decisions
All through a natural language conversation: describe your sensor setup, and ASI Biont generates the integration script.
Supported Connection Methods for Sensor Fusion Devices
ASI Biont supports multiple protocols to interface with microcontrollers and single-board computers:
| Method | Best For | Real-World Example |
|---|---|---|
| MQTT (paho-mqtt) | ESP32, Raspberry Pi with Wi-Fi | ESP32 publishes sensor fusion data (e.g., orientation angles) to broker; ASI Biont subscribes and analyzes |
| COM port via Hardware Bridge | Arduino, ESP32 (UART) | Bridge.py on PC connects to ESP32 over USB; ASI Biont sends commands like serial_write_and_read to read IMU data |
| SSH (paramiko) | Raspberry Pi, Jetson Nano | AI runs a Python script on the SBC that reads sensors, runs ML inference, and returns results |
| HTTP API / WebSocket (aiohttp) | Devices with REST endpoints (e.g., ESP32 web server) | ASI Biont polls sensor JSON endpoints or listens to WebSocket streams |
| execute_python (universal) | Any device reachable via network | AI writes a custom Python script using pyserial, paho-mqtt, or aiohttp to connect directly from the sandbox |
For this article, we'll focus on MQTT and COM port via Hardware Bridge — the most common paths for sensor fusion on microcontrollers.
Concrete Use Case: ESP32 + MPU9250 + DHT22 → ASI Biont
Scenario
An ESP32 reads:
- MPU9250: 9-axis IMU (accelerometer, gyroscope, magnetometer)
- DHT22: temperature and humidity
The ESP32 runs:
- Madgwick filter for orientation (roll, pitch, yaw)
- Gesture classifier (simple MLP or decision tree) to detect: tap, shake, rotation
The ESP32 publishes fused data and gesture events via MQTT to a broker. ASI Biont subscribes, analyzes trends, and triggers automation:
- If temperature > 40°C → send Telegram alert + turn on fan (via smart plug HTTP API)
- If gesture = "shake" → toggle light (via MQTT to ESP32 relay)
- If orientation = "face-down" for > 10 seconds → log anomaly
Step 1: ESP32 Firmware (MicroPython)
# ESP32 MicroPython code (sensor fusion + MQTT publish)
import network
import time
from machine import Pin, I2C
import ujson
from umqtt.simple import MQTTClient
# IMU and DHT22 initialization (simplified)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# MPU9250 driver (assume mpu9250.py library loaded)
from mpu9250 import MPU9250
imu = MPU9250(i2c)
# WiFi + MQTT setup
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.connect('SSID', 'PASSWORD')
while not wifi.isconnected():
time.sleep(1)
client = MQTTClient('esp32_sensor', 'broker.hivemq.com', 1883)
client.connect()
# Kalman filter for accelerometer (simplified)
kf_ax = 0.0 # filtered value
kf_p = 1.0 # estimate error
q = 0.01 # process noise
r = 0.1 # measurement noise
def kalman_update(measurement):
global kf_ax, kf_p
kf_p = kf_p + q
k_gain = kf_p / (kf_p + r)
kf_ax = kf_ax + k_gain * (measurement - kf_ax)
kf_p = (1 - k_gain) * kf_p
return kf_ax
while True:
accel = imu.acceleration
gyro = imu.gyro
mag = imu.magnetic
temp_hum = (25.0, 60.0) # replace with DHT22 read
# Apply Kalman filter to accelerometer X
filtered_ax = kalman_update(accel[0])
# Simple gesture detection (threshold-based)
gesture = "none"
if abs(accel[0]) > 2.5:
gesture = "shake"
elif abs(gyro[2]) > 200:
gesture = "rotate"
# Publish fused JSON
payload = ujson.dumps({
"accel": [round(accel[0],2), round(accel[1],2), round(accel[2],2)],
"gyro": [round(gyro[0],2), round(gyro[1],2), round(gyro[2],2)],
"mag": [round(mag[0],2), round(mag[1],2), round(mag[2],2)],
"temp": temp_hum[0],
"humidity": temp_hum[1],
"gesture": gesture,
"filtered_ax": round(filtered_ax,2)
})
client.publish(b'sensors/esp32', payload.encode())
time.sleep(1)
Step 2: ASI Biont Connects via MQTT
The user tells ASI Biont in chat:
"Connect to MQTT broker at broker.hivemq.com:1883, subscribe to topic sensors/esp32. Analyze the sensor data. If temperature exceeds 40°C, send a Telegram alert. If gesture is 'shake', publish 'toggle' to topic relay/control."
ASI Biont generates and runs the following Python script (using execute_python sandbox):
import paho.mqtt.client as mqtt
import json
import requests
TELEGRAM_BOT_TOKEN = "your_bot_token"
TELEGRAM_CHAT_ID = "your_chat_id"
def on_message(client, userdata, msg):
data = json.loads(msg.payload.decode())
temp = data.get('temp', 25)
gesture = data.get('gesture', 'none')
# Rule 1: high temperature alert
if temp > 40:
message = f"⚠️ High temperature alert: {temp}°C"
requests.post(f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
json={"chat_id": TELEGRAM_CHAT_ID, "text": message})
# Rule 2: gesture 'shake' → toggle relay
if gesture == "shake":
client.publish("relay/control", "toggle")
print("Gesture detected: shake → relay toggled")
mqtt_client = mqtt.Client()
mqtt_client.on_message = on_message
mqtt_client.connect("broker.hivemq.com", 1883, 60)
mqtt_client.subscribe("sensors/esp32")
mqtt_client.loop_forever()
The script runs continuously (within sandbox timeout limitations; for production, deploy it externally). ASI Biont can also schedule periodic checks or use the industrial_command tool for one-off queries.
Step 3: Advanced AI Inference on Edge
For gesture recognition, ASI Biont can train and deploy a small neural network on the microcontroller. The AI agent:
- Generates a TensorFlow Lite model (quantized) for gesture classification
- Converts it to C array for Arduino or MicroPython bytearray
- Uploads via COM port (Hardware Bridge) or OTA MQTT
Example: AI writes a script to flash a .tflite model to ESP32:
# ASI Biont sends model via serial_write_and_read
# (assuming bridge.py is running)
import json
model_hex = "..." # hex-encoded TFLite model
command = {
"protocol": "serial://COM3",
"command": "serial_write_and_read",
"params": {
"data": model_hex,
"baud": 115200
}
}
# Sent via industrial_command tool in chat
Alternative Comparison: MQTT vs COM port vs SSH
| Approach | Latency | Power | Complexity | Best Use Case |
|---|---|---|---|---|
| MQTT | Medium (network) | Medium | Low | Battery-powered sensors, Wi-Fi available |
| COM port (UART) | Low (serial) | Low | Medium | Wired, real-time control, no network |
| SSH | Medium (network) | High | Medium | Single-board computer with Linux, complex processing |
| HTTP API | Higher (polling) | High | Low | REST-enabled devices, periodic data fetch |
For sensor fusion + AI inference, MQTT is often the sweet spot: the microcontroller publishes filtered data, and ASI Biont receives it without blocking the device's main loop.
Why This Integration Matters
Traditional sensor fusion projects require:
- Manual coding of communication protocols
- Separate cloud functions for data processing and alerting
- Custom dashboard setup
With ASI Biont, you simply describe what you want in plain English. The AI agent:
1. Understands your device capabilities (from your description)
2. Writes the communication code (MQTT subscription, COM port read, etc.)
3. Deploys it in the sandbox or via industrial_command
4. Handles data analysis, anomaly detection, and automation
This reduces development time from days to minutes. It also makes sensor fusion accessible to non-experts: a homeowner can set up gesture-controlled lights; a factory operator can deploy vibration-based predictive maintenance without hiring a full-time firmware engineer.
Getting Started: Connect Your Sensor Fusion Device to ASI Biont
- Prepare your device: Flash MQTT firmware (like the example above) or set up a serial protocol.
- Open ASI Biont chat at asibiont.com.
- Describe your device: "I have an ESP32 with MPU9250 and DHT22, connected to MQTT broker at 192.168.1.100:1883, topic sensors/esp32."
- State your goal: "Monitor temperature and gesture. If temp > 40°C, alert me on Telegram. If gesture is shake, toggle a relay."
- ASI Biont writes and runs the integration code — you'll see live data and automation in seconds.
No dashboard setup. No manual coding. Just conversation.
Conclusion
Sensor fusion + AI inference on the edge unlocks responsive, intelligent automation — from smart homes that react to your gestures to industrial systems that predict failures. ASI Biont makes this integration effortless: it connects to any multi-sensor microcontroller via MQTT, COM port, SSH, or HTTP API, writes the necessary Python code, and orchestrates data analysis and actions.
Whether you're prototyping a gesture-controlled lamp or deploying a vibration-based predictive maintenance system, ASI Biont reduces integration time from days to minutes. Try it today — describe your sensor fusion device in the chat at asibiont.com and see the AI agent bring your data to life.
Comments