How to Integrate BLE Modules (HM-10, HC-05) with ASI Biont AI Agent: A Step-by-Step Guide

Why Connect a BLE Module to an AI Agent?

BLE (Bluetooth Low Energy) modules like HM-10 and HC-05 are the backbone of countless IoT projects—from smart locks and temperature sensors to wearable health monitors. But managing BLE data manually (writing custom scripts, parsing packets, setting up alerts) is tedious and error-prone.

With ASI Biont, you can skip all that. The AI agent connects directly to your BLE device through one of several supported protocols, writes the integration code for you, and lets you control everything via natural language chat. No dashboard, no drag-and-drop—just describe what you need, and the AI does the rest.

How ASI Biont Connects to BLE Devices

ASI Biont doesn't have a built-in Bluetooth stack. Instead, it connects to BLE modules through a local bridge or intermediary that has Bluetooth hardware. Here are the two most common paths:

Connection Method How It Works Best For
Hardware Bridge (COM port) You run bridge.py on a PC (Windows/Linux/macOS) that has a BLE dongle or ESP32 connected via USB. The bridge talks to ASI Biont via HTTP short-polling. AI sends commands through industrial_command tool, which routes them to the bridge, and the bridge writes/reads to the COM port (e.g., COM3) using pyserial. HM-10/HC-05 modules connected to an Arduino or USB-to-serial adapter.
SSH (single-board computer) AI uses paramiko (inside execute_python) to SSH into a Raspberry Pi with a BLE dongle. Then it runs gatttool or bluepy scripts to scan, connect, and exchange data with BLE peripherals. Raspberry Pi + any BLE device (sensors, beacons).

Important: The AI writes all the integration code itself. You just provide connection details (port, baud rate, IP, etc.) in the chat.

Real-World Use Case: BLE Temperature Sensor + LM35DZ

Scenario: You have an HM-10 module connected to an Arduino Uno, which reads an LM35DZ temperature sensor. You want the AI to:
- Read temperature every 10 seconds
- Log data to a file
- Send a Telegram alert if temperature exceeds 30°C

Step 1: Hardware Setup

Connect HM-10 to Arduino:
- HM-10 VCC → Arduino 3.3V
- HM-10 GND → Arduino GND
- HM-10 TX → Arduino RX (pin 0)
- HM-10 RX → Arduino TX (pin 1)

Upload this sketch to Arduino (it sends temperature in Celsius every second):

void setup() {
  Serial.begin(9600);
}

void loop() {
  int reading = analogRead(A0);
  float voltage = reading * 5.0 / 1024.0;
  float temperature = voltage * 100.0;
  Serial.print("TEMP:");
  Serial.println(temperature);
  delay(1000);
}

Step 2: Run Hardware Bridge

Download bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge). Run it with your API token and specify the COM port:

python bridge.py --token=YOUR_TOKEN --ports=COM3 --default-baud=9600

The bridge connects to ASI Biont and listens for commands.

Step 3: Ask AI to Connect

In the ASI Biont chat, type:

Connect to COM3 at 9600 baud via bridge. Read temperature data every 10 seconds. If temperature > 30°C, send a Telegram alert to my chat ID 123456.

The AI will:
1. Use industrial_command with protocol='bridge' and command='serial://COM3?baud=9600&read=1' to open the port and read a line.
2. Parse the TEMP: prefix.
3. Set up a loop (using execute_python with asyncio.sleep(10) and the send_telegram tool).

Example code the AI might generate (simplified):

import asyncio
from asi_sdk import ASIClient

client = ASIClient(token='YOUR_TOKEN')

async def monitor():
    while True:
        # Read from bridge
        response = await client.industrial_command(
            protocol='bridge',
            command='serial://COM3?baud=9600&read=1'
        )
        data = response['output'].strip()
        if data.startswith('TEMP:'):
            temp = float(data.split(':')[1])
            print(f'Temperature: {temp}°C')
            if temp > 30:
                await client.send_telegram(
                    chat_id=123456,
                    text=f'ALERT: Temperature {temp}°C exceeds 30°C!'
                )
        await asyncio.sleep(10)

asyncio.run(monitor())

Note: Loops longer than 30 seconds should use industrial_command with scheduling, not execute_python (which has a 30-second timeout). For production, use the AI's built-in cron-like scheduler.

Step 4: Test and Automate

Once the AI runs the script, you'll see temperature updates in the chat. You can ask:

Show me the last 5 temperature readings.

The AI will read from the log file or re-query the bridge.

Turn on an LED connected to pin 13 if temperature drops below 20°C.

The AI will add a write command: serial://COM3?baud=9600&write=LED_ON (you'd need to extend the Arduino sketch to parse commands).

Pitfalls to Avoid

  1. Baud rate mismatch: Both ends must match. Default HM-10 baud is 9600, but some modules use 115200. Check with AT+BAUD?.
  2. Bridge timeout: If no data comes in 10 seconds, the bridge may disconnect. Add a keepalive message (e.g., AT) every 30 seconds.
  3. Infinite loops in execute_python: The sandbox kills scripts after 30 seconds. Use industrial_command with scheduling for long-running tasks.
  4. BLE pairing: HM-10 uses a simple PIN (usually 1234). If you need secure pairing, use HC-05 or a BLE 4.2+ module.

Why Use ASI Biont for BLE Integration?

  • Zero coding required: The AI writes all code—you just describe the task.
  • Flexible protocols: COM port, SSH, MQTT, HTTP—whatever your BLE setup needs.
  • Real-time control: Change thresholds, add actions, or switch devices by typing a message.
  • Open source hardware: Works with any BLE module that speaks serial AT commands or GATT.

Try It Yourself

  1. Go to asibiont.com and create a free account.
  2. Connect your HM-10 or HC-05 to any microcontroller (Arduino, ESP32, Raspberry Pi).
  3. Run the bridge or enable SSH.
  4. In the chat, tell the AI: "Connect to my BLE temperature sensor on COM3 and alert me if it goes above 30°C."

See the integration happen in seconds. No dashboard, no waiting for feature updates—just pure AI-powered automation.

← All posts

Comments