Edge AI Meets the Cloud: Integrating Arduino Nano BLE Sense (TinyML) with ASI Biont

Introduction

The Arduino Nano BLE Sense is a powerful microcontroller that packs an accelerometer, gyroscope, microphone, and environmental sensors into a tiny board, capable of running TensorFlow Lite models directly on-device (TinyML). While this enables low-latency inference without cloud round trips, you often still need to act on those inferences—send alerts, log data, or adapt behavior based on external context. That’s where the AI agent from ASI Biont comes in. Instead of building a custom dashboard or server, you simply describe your setup in plain English and the AI handles the integration, whether via serial, MQTT, or HTTP.

Why Connect TinyML to an AI Agent?

Running ML on the edge reduces bandwidth and latency, but it also creates isolated islands of intelligence. By connecting the Nano BLE Sense to ASI Biont, you can:
- Forward only significant events (e.g., a fall detected, temperature spike) to the cloud.
- Dynamically adjust inference thresholds without reflashing firmware—just send a command via the AI agent.
- Combine multiple edge devices (e.g., several Nano boards) into a single monitoring system.

The key is that the AI agent can communicate with the board through Hardware Bridge (serial over BLE UART) or via MQTT through an intermediary gateway. We’ll focus on the serial path because it’s the most direct and works with any PC that has Bluetooth.

Connection Architecture

The Nano BLE Sense has a built-in BLE module. For this integration, we set it up as a BLE peripheral with a UART service. On the PC, we pair the device, which creates a virtual COM port (e.g., COM5 on Windows, /dev/cu.Nano-XX on macOS). We then run bridge.py (downloaded from the ASI Biont dashboard) pointing to that port:

pip install pyserial requests websockets
python bridge.py --token=YOUR_TOKEN --ports=COM5 --baud=115200

The bridge connects to ASI Biont via WebSocket and exposes the serial port to the AI agent. The AI can now send commands and read responses using the industrial_command tool with serial_write_and_read.

Real-World Scenario: Fall Detection with Wearable

Imagine a elderly-care wearable using the Nano BLE Sense’s accelerometer. The board runs a TensorFlow Lite model trained to detect falls. When a fall is detected, it sends the string "FALL" over BLE UART. The user tells ASI Biont: "Connect to COM5 at 115200 baud, listen for 'FALL' messages, and send me a Telegram alert with the timestamp."

The AI agent will write a Python script (sandboxed) that polls the serial via the bridge protocol. But the easier way is to use the built-in serial_write_and_read command to check for new data. Because the bridge supports atomic write+read, the AI can periodically send a command like POLL (hex: 504f4c4c0a) and parse the response.

Arduino Firmware Sketch (C++)

#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>

BLEService fallService("180C");
BLEStringCharacteristic fallCharacteristic("2A56", BLERead | BLENotify, 20);

void setup() {
  Serial.begin(115200);  // USB serial for debug
  if (!IMU.begin()) while(1);
  if (!BLE.begin()) while(1);
  BLE.setLocalName("NanoFallDetector");
  BLE.setAdvertisedService(fallService);
  fallService.addCharacteristic(fallCharacteristic);
  BLE.addService(fallService);
  BLE.advertise();
}

void loop() {
  BLE.poll();
  float x, y, z;
  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);
    // Run TinyML inference (simplified):
    if (abs(z) > 3.0) {  // high g-force → fall
      fallCharacteristic.writeValue("FALL");
      Serial.println("FALL");  // also print over USB for debugging
      delay(2000);
    }
  }
}

This sketch broadcasts the "FALL" string via BLE notification. On the PC, the BLE UART service appears as a serial port. bridge.py reads from that port and forwards everything to the AI agent.

AI Agent Interaction

After starting bridge.py, the user opens a chat with ASI Biont and says: "Read COM5 and when you receive 'FALL', send me a Telegram message." The AI agent will set up a monitoring loop using industrial_command like this:

# This code runs in the AI sandbox (not on the PC)
# It uses paho-mqtt to receive events from the bridge? No, better to use execute_python to poll the bridge via industrial_command.
# However, the AI can also ask the user to use the 'serial' tool directly.

In practice, the AI will use the industrial_command tool with:
- protocol = "serial"
- command = "serial_write_and_read"
- data = "504f4c4c0a" (hex for "POLL\n")

If the Nano firmware is programmed to respond with any pending event when it receives "POLL", the AI can retrieve it. But even simpler: the user can ask the AI to "monitor the serial port continuously", and the AI will write a Python script that runs in sandbox and issues repeated serial_write_and_read calls (with a delay) until a "FALL" is received.

Why This Matters

The entire integration—from pairing the BLE device to receiving alerts—is done through natural language. There’s no need to write a custom MQTT publisher, no dashboard configuration, no rule engine. The AI agent understands your hardware and writes the glue code for you. This is especially valuable for prototyping edge-AI applications where the logic changes rapidly: you can update thresholds or add new triggers simply by chatting with the AI, without reflashing the microcontroller.

Try It Yourself

Integrating the Nano BLE Sense with ASI Biont takes minutes. Download bridge.py from the ASI Biont dashboard, flash your board with a simple BLE UART sketch, and tell the AI agent what you want to monitor. From fall detection to voice-triggered events (using the built-in microphone), the possibilities are endless. Start your edge-AI journey at asibiont.com.

← All posts

Comments