Introduction
The promise of TinyML — running machine learning models on microcontrollers consuming milliwatts of power — has been around for a few years. But turning an on-device gesture classifier or voice command detector into a useful automation tool often requires a second brain: a gateway that can relay events to the cloud, trigger actions, and coordinate multiple devices. That’s where the ASI Biont AI agent steps in.
In this article, we’ll walk through a practical integration between an Arduino Nano BLE Sense (the go-to board for TinyML, with its onboard microphone, accelerometer, and BLE) and ASI Biont. You’ll learn how to train a simple gesture-recognition model, deploy it on the Nano, and then — without writing a single line of boilerplate integration code — have the AI agent react to those gestures by sending alerts, toggling smart plugs, or logging data to a spreadsheet.
Why Connect a TinyML Board to an AI Agent?
A standalone Arduino Nano BLE Sense can classify gestures at the edge — but what happens when you want to:
- Send a push notification when a specific gesture is detected?
- Log the count of each gesture to a Google Sheet for analytics?
- Trigger an MQTT command to turn off a lab power supply when a “stop” gesture is recognized?
Traditionally, you’d need to write a Python script running on a PC or Raspberry Pi that listens to the board’s serial output, parses the data, and then calls external APIs. That’s doable but time-consuming. With ASI Biont, you simply describe the task in natural language, and the AI agent writes and executes the integration code on the fly — using the Hardware Bridge for serial communication or MQTT for wireless scenarios.
Connection Methods Supported by ASI Biont
ASI Biont connects to devices through several channels. For the Arduino Nano BLE Sense, the most relevant methods are:
| Method | Best For | How It Works |
|---|---|---|
| Hardware Bridge (COM port) | Wired connection – reading sensor data, sending commands over USB | User runs bridge.py on their PC; AI sends commands via industrial_command tool with serial:// protocol |
| MQTT | Wireless – board publishes to broker, AI subscribes and reacts | AI writes a Python script using paho-mqtt in execute_python sandbox, or uses industrial_command with publish |
| SSH | If board is connected to a Raspberry Pi gateway | AI uses paramiko to log into the Pi and read serial data from the Nano |
For this guide, we’ll focus on the Hardware Bridge method, because it gives the fastest feedback loop and doesn’t require additional hardware.
Real-World Scenario: Gesture-Controlled Lab Automation
Imagine a chemical lab where a researcher needs both hands occupied with pipettes and test tubes. A simple hand gesture — a swipe left — could start a data-logging script; a swipe right could turn on a fume hood. The Arduino Nano BLE Sense, running a TinyML model trained on accelerometer data, can classify these gestures with 95% accuracy (as shown in TensorFlow’s official gesture recognition example).
Step 1: Train and Deploy the TinyML Model
You don’t need to be an ML expert. Using the Arduino Nano BLE Sense with the Arduino_TensorFlowLite library and the Arduino_LSM9DS1 IMU, you can train a model in TensorFlow (on your PC) and flash it to the board. The board will continuously classify gestures and print the result over the USB serial port:
// Pseudo-code for the Nano sketch
void loop() {
// Read accelerometer data
// Run interpreter
// Get output tensor
Serial.println(output_label); // e.g., "swipe_left"
delay(100);
}
Common output format: a single line with the gesture name, e.g., swipe_left or idle.
Step 2: Set Up Hardware Bridge
On your PC, download bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge). Run it with:
python bridge.py --token=YOUR_API_TOKEN --ports=COM3 --default-baud=115200
Replace COM3 with the port your Nano is on (check Arduino IDE or Device Manager). The bridge will poll the ASI Biont cloud for commands and forward them to the serial port.
Step 3: Tell ASI Biont to Read and React
Now, instead of writing a Python script yourself, you simply chat with the AI agent:
“Connect to Arduino Nano on COM3 at 115200 baud. Read the serial line every second. If the gesture is ‘swipe_left’, send me a Telegram message saying ‘Left swipe detected’. If it’s ‘swipe_right’, turn on the smart plug at 192.168.1.100 via its HTTP API.”
The AI agent will generate the appropriate industrial_command calls. Under the hood, it looks like this:
# This is a simplified representation of what the AI agent writes
# The AI uses industrial_command() to send serial read requests
# Step 1: Read from serial
# industrial_command(protocol='serial://COM3', command='read_line', params={'baud': 115200})
# Step 2: Based on result, send Telegram or toggle plug
You don’t need to execute the above code manually — the AI handles it.
Step 4: Automation Without Loops
Since execute_python has a 30-second timeout, the AI agent uses short-polling via the Hardware Bridge (which runs indefinitely on your PC). The bridge itself keeps the serial port open. The AI agent periodically (e.g., every 5 seconds) calls industrial_command to read the latest line from the Nano. This is perfectly suited for event-driven automation where latency of a few seconds is acceptable.
Code Example: MQTT Alternative
If you prefer a wireless setup (e.g., the Nano sends gestures via BLE to a gateway that publishes MQTT), the AI agent can subscribe to an MQTT topic. Here’s a snippet that the AI would generate and run in its sandbox:
import paho.mqtt.client as mqtt
def on_message(client, userdata, msg):
gesture = msg.payload.decode()
if gesture == "swipe_left":
# instruct industrial_command to send Telegram
pass
client = mqtt.Client()
client.on_message = on_message
client.connect("broker.hivemq.com", 1883, 60)
client.subscribe("lab/gestures")
client.loop_forever() # Note: runs until timeout
Again, the AI generates this code on-demand — you just describe your MQTT broker and topic.
Why This Approach Beats Manual Coding
- Zero boilerplate. You don’t write or maintain serial parsing, error handling, or reconnection logic. The AI handles it.
- Adaptable. Change your mind about what action to take? Just tell the AI: “Instead of Telegram, log to Google Sheets.” The AI rewrites the integration instantly.
- No dashboard needed. There is no “add device” button. Everything happens through conversation.
Conclusion
The Arduino Nano BLE Sense is a powerful platform for edge AI, but its true potential is unlocked when it becomes part of a larger automation ecosystem. By connecting it to ASI Biont — through the Hardware Bridge, MQTT, or SSH — you can turn on-device ML events into real-world actions without writing a single line of glue code.
Whether you’re automating a lab, a workshop, or a smart home, the combination of TinyML and an AI agent is a game-changer. Try it yourself: download the bridge from asibiont.com, flash a TinyML sketch to your Nano, and tell the AI what you want to happen next.
Comments