From Blue Pill to AI: How to Integrate STM32 with ASI Biont for Remote Monitoring & Control
Last updated: July 26, 2026
You’ve spent hours debugging UART, soldering sensors, and writing firmware for your STM32 board. Now imagine offloading all the decision-making logic to an AI agent that can talk to your microcontroller, parse sensor data, and even send commands back – all through a chat interface. That’s exactly what ASI Biont does. In this guide, I’ll show you how to connect an STM32 Blue Pill or Nucleo board to ASI Biont, using nothing more than a USB/UART adapter and a few lines of code on the MCU side.
Why Connect an STM32 to an AI Agent?
STM32 microcontrollers are everywhere – from industrial controllers to hobbyist projects. They are powerful, low-power, and support a wide range of peripherals (GPIO, ADC, I2C, SPI, UART, CAN). But managing them often requires manual scripting, polling, and custom dashboards. ASI Biont acts as your intelligent middleware: you describe what you want in plain English, and the AI takes care of writing the integration code, connecting to your hardware, and executing the logic. No need to learn MQTT brokers or write REST endpoints – just chat.
Which Connection Method Does ASI Biont Use for STM32?
The most common way to interact with an STM32 board is over a serial (UART) connection. ASI Biont supports this via its Hardware Bridge – a lightweight Python application (bridge.py) that you run on your PC. The bridge connects to the ASI Biont cloud over WebSocket and provides direct access to your local COM ports. ASI Biont uses the industrial_command tool with the serial:// protocol to send and receive data.
For STM32 boards with Ethernet (e.g., Nucleo-F767ZI) or WiFi (e.g., STM32 + ESP8266), you could also use MQTT or HTTP API, but the simplest and most reliable approach for most users is the serial bridge.
Real Use Case: STM32 Blue Pill + DS18B20 Temperature Sensor + LED Control
Hardware Setup
- STM32 Blue Pill (STM32F103C8T6) with a USB-to-UART converter (e.g., CP2102).
- DS18B20 temperature sensor connected to PB1 (OneWire).
- LED on PC13 (built-in) or external on PA0.
Step 1: Flash the Firmware
I used the Arduino IDE (with STM32duino core) to write a simple sketch that waits for commands over UART. The protocol is simple ASCII:
- TEMP\n → replies with temperature in °C (e.g., 23.5).
- LED_ON\n → turns LED on.
- LED_OFF\n → turns LED off.
- HELP\n → lists commands (required for ASI Biont’s initial handshake).
Here’s the core code snippet:
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS PB1
#define LED_PIN PC13
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(115200);
sensors.begin();
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH); // off (active low)
}
void loop() {
if (Serial.available()) {
String cmd = Serial.readStringUntil('\n');
cmd.trim();
if (cmd == "HELP") {
Serial.println("TEMP,LED_ON,LED_OFF,HELP");
} else if (cmd == "TEMP") {
sensors.requestTemperatures();
float t = sensors.getTempCByIndex(0);
Serial.println(t);
} else if (cmd == "LED_ON") {
digitalWrite(LED_PIN, LOW);
Serial.println("OK");
} else if (cmd == "LED_OFF") {
digitalWrite(LED_PIN, HIGH);
Serial.println("OK");
}
}
}
Step 2: Download and Run the Hardware Bridge
On your PC, go to the ASI Biont Dashboard → Devices → Create API Key. Download the bridge.py file. Install dependencies:
pip install pyserial requests websockets
Run the bridge, specifying your token and the COM port (e.g., COM3 or /dev/ttyUSB0):
python bridge.py --token=YOUR_TOKEN_HERE --ports=COM3 --baud 115200 --rate=10
The bridge will connect to ASI Biont’s cloud via WebSocket and start listening for commands.
Step 3: Chat with the AI Agent
Now open the ASI Biont chat. Type something like:
"Connect to STM32 on COM3 at 115200 baud. Read the temperature from the DS18B20 every 30 seconds. If the temperature exceeds 30°C, turn on the LED and alert me on Telegram. Otherwise, keep the LED off."
The AI agent will use the industrial_command tool to send serial commands. Under the hood, it calls:
industrial_command(
protocol='serial://',
command='serial_write_and_read',
data='54454d500a' # hex for "TEMP\n"
)
The bridge sends TEMP\n to the STM32, reads the response (e.g., 23.5), and returns it to the AI. The AI can then decide to toggle the LED by sending LED_ON\n or LED_OFF\n.
Step 4: Automation in the Chat
The AI can schedule periodic readings by using execute_python (a sandboxed Python environment). For example, the AI writes a script that loops 10 times with 30-second intervals (avoiding infinite loops – sandbox timeout is 30 seconds):
import time
# The AI already has connection info stored
for i in range(10):
# send TEMP command via industrial_command (not shown, it's a tool call)
temp = get_temperature_from_stm32() # hypothetical function
if temp > 30:
send_telegram_alert(f"Temperature {temp}°C exceeds threshold!")
set_led(True)
else:
set_led(False)
time.sleep(30)
Note: The actual code generated by the AI will use the industrial_command tool inside the sandbox (via execute_python has access to all ASI Biont tools).
Why This Matters
- Zero coding for integration: You only write the MCU firmware (which you likely already have). The AI handles the bridge configuration, command generation, and scheduling.
- Multi-device control: You can later add more STM32s or other devices (ESP32, Arduino, PLC) – just define new ports in the bridge configuration and describe them to the AI.
- Telegram alerts: The AI can send you messages when something happens – no need to build a notification system.
- Any protocol: If your STM32 uses CAN, I2C, or SPI – you can still use the serial bridge as a proxy (e.g., send text commands over UART that the MCU interprets and forwards to I2C sensors).
Deeper Dive: Advanced Integration with execute_python
ASI Biont’s execute_python mode gives you unrestricted access to a rich set of libraries (see full list in the documentation). While the sandbox cannot directly access your local COM ports (that’s what the bridge is for), you can combine both: use the bridge for low-level communication and execute_python for complex logic, data analysis, or cloud storage.
For instance, you could ask the AI to:
"Read the temperature every minute, store the data in a CSV file, and after 24 hours generate a matplotlib chart and send it to my email."
The AI would write a Python script that periodically calls the industrial_command tool (available inside execute_python), accumulates values, and then uses matplotlib to plot and smtplib (via standard library) to email.
Pitfalls to Avoid
- Don't forget the
HELPcommand: The bridge expects your device to respond toHELP\nwith a list of commands. Without it, the AI may not be able to discover available actions. - BAUD rate mismatch: Double-check that the STM32 firmware and the bridge use the same baud rate (115200 is standard).
- Hex encoding: The
serial_write_and_readcommand expects hex-encoded data. If you send plain text like"TEMP\n", the AI will automatically convert it, but for custom binary protocols you must provide hex. - Windows overl I/O issues: On Windows, pyserial sometimes fails with
WriteFiledue to overlapped I/O. The bridge already handles this by callingCancelIoExandPurgeComm– but if you see write errors, try increasing the--rate(rate limiter) or use a USB-to-serial adapter with better drivers. - Avoid infinite loops in execute_python: The sandbox has a 30-second timeout. For long-running tasks, use the bridge’s scheduling or break work into chunks.
Comparison of Connection Methods for STM32
| Method | When to Use | Pros | Cons |
|---|---|---|---|
| Hardware Bridge (Serial) | Any STM32 with UART | Simple, works out-of-the-box, no network stack on MCU | Requires a PC running the bridge |
| MQTT | STM32 with Ethernet/WiFi module | Direct cloud connection, no local PC | Need to implement MQTT client on MCU |
| Execute_Python only | For simulation or when device is already network-connected | Fast, no bridge | Cannot access local COM ports |
Real-World Result: What I Built
I used this setup to monitor the temperature in my server closet. The STM32 Blue Pill reads two DS18B20 sensors (ambient and CPU intake), and the AI sends me a Telegram message if either goes above 35°C. I can also query the current temperature anytime by typing “What’s the temperature in the closet?” in the ASI Biont chat. The AI fetches the latest reading via the bridge and responds.
Setting up the entire integration took less than 30 minutes – most of that was soldering the sensors. The AI part was simply describing what I wanted.
Conclusion: Your Turn
You don’t need to be an IoT expert to connect your STM32 board to an intelligent agent. With ASI Biont’s Hardware Bridge and chat-driven interface, you can monitor sensors, control actuators, and automate responses – all without writing a single line of cloud infrastructure.
Try it yourself:
1. Go to asibiont.com and create an account.
2. Flash the simple serial firmware to your STM32.
3. Download bridge.py from the dashboard and run it.
4. Start chatting – tell the AI to connect to your board and control it.
The future of embedded development is conversational. Start today.
Comments