Arduino Nano BLE Sense (TinyML) + ASI Biont: On-Device Machine Learning Meets AI Automation

Why Connect Arduino Nano BLE Sense to an AI Agent?

Arduino Nano BLE Sense is a compact microcontroller packed with sensors — microphone, accelerometer, gyroscope, magnetometer, temperature, humidity, and a Bluetooth Low Energy (BLE) module. It runs TensorFlow Lite Micro (TinyML) models directly on the chip, enabling real-time gesture recognition, anomaly detection, or keyword spotting without cloud dependency. However, raw predictions from TinyML are limited to local actions (LED patterns, buzzer sounds). By integrating with ASI Biont AI agent, you unlock automated decision-making: the microcontroller sends predictions over BLE, and the AI can trigger cloud APIs, send alerts, log data to databases, or coordinate other smart devices — all without writing a single line of integration code yourself.

Connection Method: Hardware Bridge via COM Port (Serial over BLE)

Arduino Nano BLE Sense is often connected to a PC via USB, which appears as a virtual COM port (e.g., COMB on Windows, /dev/ttyACM0 on Linux). ASI Biont connects to COM ports through the Hardware Bridge — a lightweight Python script (bridge.py) that runs on your PC. The bridge opens a WebSocket connection to the ASI Biont cloud server. When you instruct the AI agent (via chat) to interact with the device, the AI calls the industrial_command tool with protocol='serial' and data='hex_string'. The bridge forwards the command to the COM port, reads the response, and returns it to the AI. This is the most reliable method for microcontrollers that expose a serial interface.

Why not BLE directly? BLE is a wireless protocol that requires a central device (like a PC or phone) to act as a bridge. The Hardware Bridge can also handle BLE via a dedicated dongle, but for simplicity and stability, most users connect the Nano via USB serial. The microcontroller sends TinyML predictions as JSON strings over serial, and the bridge relays them to ASI Biont.

Real-World Use Case: Gesture-Controlled Smart Home

Scenario

You train a TinyML model on the Arduino Nano BLE Sense to recognize three gestures: circle (turn lights on), triangle (turn lights off), and wave (set thermostat to 22°C). The model runs on the microcontroller and outputs a prediction label (e.g., "circle") over serial every 500ms. ASI Biont receives these predictions via the bridge and triggers corresponding actions via HTTP API calls to a smart home hub (e.g., Home Assistant).

Step-by-Step Implementation

  1. Train and flash the TinyML model on Arduino Nano BLE Sense using TensorFlow Lite Micro. The Arduino sketch reads accelerometer data, runs inference, and prints predictions as JSON: {"gesture":"circle"}.
  2. Set up Hardware Bridge on your PC:
  3. Download bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge).
  4. Install dependencies: pip install pyserial requests websockets.
  5. Run: python bridge.py --token=YOUR_API_KEY --ports=COM3 --baud 115200
  6. The bridge connects to ASI Biont via WebSocket and opens the COM port.
  7. In ASI Biont chat, describe the task:

    "Connect to Arduino on COM3 at 115200 baud. Read serial data. When gesture is 'circle', turn on smart light via HTTP POST to http://192.168.1.100:8123/api/states/light.living_room with payload '{"state":"on"}'. When 'triangle', turn off. When 'wave', set thermostat to 22°C."

  8. AI writes and executes the integration code using execute_python with pyserial and requests. The sandbox script subscribes to the bridge via a callback (or polls), parses the JSON, and calls the smart home API. No manual coding required.

Code Example (AI-generated, runs in sandbox)

import serial
import json
import requests
import time

ser = serial.Serial('COM3', 115200, timeout=1)
light_on_url = 'http://192.168.1.100:8123/api/states/light.living_room'
headers = {'Authorization': 'Bearer YOUR_HA_TOKEN', 'Content-Type': 'application/json'}

while True:
    line = ser.readline().decode('utf-8').strip()
    if line:
        try:
            data = json.loads(line)
            gesture = data.get('gesture')
            if gesture == 'circle':
                requests.post(light_on_url, json={"state": "on"}, headers=headers)
            elif gesture == 'triangle':
                requests.post(light_on_url, json={"state": "off"}, headers=headers)
            elif gesture == 'wave':
                requests.post('http://192.168.1.100:8123/api/states/climate.thermostat',
                              json={"temperature": 22}, headers=headers)
        except:
            pass

Note: The actual sandbox timeout is 30 seconds, so for long-running automation, the AI uses a polling loop with time.sleep(1) and the bridge streams data continuously.

Alternative Connection: MQTT via BLE Gateway

If the Arduino Nano BLE Sense is battery-powered and not tethered to a PC, you can use a BLE-to-MQTT gateway (e.g., ESP32 running ESP-IDF). The Nano advertises TinyML predictions as BLE characteristics. The gateway reads them and publishes to an MQTT broker (e.g., Mosquitto). ASI Biont connects to the broker via paho-mqtt in execute_python, subscribes to the topic, and triggers actions. This is ideal for remote sensors in industrial monitoring.

Connection Method Latency Power Usage Best For
USB Serial + Bridge Low (~10ms) Medium (USB power) Desktop prototyping, fast feedback
BLE + MQTT Gateway Medium (~200ms) Low (battery) Wireless sensor networks, wearables
Direct BLE (experimental) Variable Very low Short-range, low-data applications

Why ASI Biont for TinyML Integration?

  • Zero manual coding: You describe the device and behavior in natural language. The AI generates, tests, and deploys the integration code in seconds.
  • No GUI dashboards: No need to click "Add device" or fill forms. Everything happens in chat — the most intuitive interface.
  • Unlimited device types: ASI Biont supports 14+ protocols (COM, MQTT, Modbus, SSH, HTTP, OPC-UA, etc.). You can mix a TinyML Arduino with a Modbus PLC in the same conversation.
  • Edge AI synergy: TinyML handles low-latency on-device inference. ASI Biont handles cloud-scale logic, data storage, and multi-device orchestration.

Conclusion

Arduino Nano BLE Sense is a powerful TinyML device, but its true potential is unlocked when connected to an intelligent agent that can act on predictions. ASI Biont connects via Hardware Bridge (serial) or MQTT, reads gesture or anomaly data, and automates any digital action — from smart home control to industrial alarm systems. Try it yourself at asibiont.com: describe your Arduino setup in chat, and watch the AI build the integration in real time.

← All posts

Comments