LiDAR + ASI Biont: Connect RPLIDAR A1 and TFmini to an AI Agent for Robot Navigation and Obstacle Alerts

Your robot is blind. It has a LiDAR spinning, but the serial port is just a stream of bytes. I spent a weekend fighting with angle parsing and baud rates until I realized the real fix: let an AI agent write the integration for me. In this guide I show how to connect a laser scanner — RPLIDAR A1 or TFmini — to ASI Biont, so you can build a map, avoid obstacles, and get a Telegram message when something crosses a distance threshold. No cloud dashboards, no waiting for a vendor plugin. Just chat, Python, and a serial port.

Why connect a LiDAR to an AI agent?

LiDAR sensors give you raw distance data. RPLIDAR A1 returns hundreds of (angle, distance) points per spin; TFmini gives a single distance value 100 times per second. An AI agent can turn that raw stream into a decision: 'obstacle on the left', 'doorway here', 'stop now'. ASI Biont is built for exactly this. You describe what you have and what you want, and it produces a working Python script. That saves hours of manual parsing and lets you focus on the robot itself.

How ASI Biont talks to serial devices

ASI Biont doesn't use a fixed driver list. For serial devices it uses a small program called Hardware Bridge (bridge.py), which you download from your ASI Biont dashboard — not from GitHub. Run it locally with parameters:

python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 115200 --rate=10

This bridge streams raw serial data into the AI agent and lets you send commands back with the industrial_command() function. For everything else — HTTP sensors, MQTT brokers, PLCs, custom CAN sniffers — ASI Biont writes a script using execute_python. That script runs in a sandbox where pyserial, paho-mqtt, pymodbus, paramiko and similar libraries are available. You don't need to wait for a dedicated 'LiDAR integration' to be shipped.

RPLIDAR A1 vs TFmini: which one for your project?

Sensor Type Range Field of View Interface Typical Use
RPLIDAR A1 2D laser scanner 12 m (A1M8) 360° Serial 115200 baud + motor control SLAM, room mapping
TFmini-S single-point ToF 12 m 3.6° cone UART, I2C Obstacle avoidance, follow-me

I use RPLIDAR for a disinfection robot's map, and TFmini on a drone to measure height. See Slamtec's official page (https://www.slamtec.com/products/rplidar-a1) and Benewake's TFmini docs (https://www.benewake.com/tfmini-s.html).

Step 1: Hardware connection

RPLIDAR A1 usually comes with a USB adapter; plug it into a USB port and let the OS create /dev/ttyUSB0 or COM3. Make sure the motor (MOTOR pin) is powered — on the A1M8 the USB adapter already handles this, but on a bare board connect 5V PWM control. TFmini needs a USB-UART adapter (CP2102 works). Wiring is simple: VCC to 5V, GND common, TX of TFmini to RX of adapter, RX of TFmini to TX of adapter. I once forgot the common ground and got garbage values for an hour — don't do that.

Step 2: Launch the Hardware Bridge

Download bridge.py from the ASI Biont dashboard, then run it with your token and port:

python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 115200 --rate=10

The --rate=10 means ten serial reads per second, enough for a distance sensor. For RPLIDAR's 360° scan you might want a higher rate (try 100) but don't flood the chat log.

Step 3: Read the sensor with Python

While the bridge is running, you can also test locally with your own script. Here is a minimal TFmini reader using pyserial (https://pyserial.readthedocs.io/en/latest/):

import serial

ser = serial.Serial('COM3', 115200, timeout=0.2)
for _ in range(30):  # never while True in execute_python
    raw = ser.read(9)
    if len(raw) == 9 and raw[0] == 0x59 and raw[1] == 0x59:
        distance = raw[2] | (raw[3] << 8)
        strength = raw[4] | (raw[5] << 8)
        print(f'distance={distance} cm, strength={strength}')
        break

For RPLIDAR, use PyLidar3 (https://github.com/bridgette-o/pylidar3):

import PyLidar3
import time

lidar = PyLidar3.RPLidarA1('/dev/ttyUSB0')
if lidar.Connect():
    lidar.StartScanning()
    for _ in range(5):
        scan = lidar.GetScan()
        for angle, dist_cm in scan.items():
            if dist_cm > 0:
                print(f'{angle:.0f} deg: {dist_cm/10.0:.1f} cm')
    lidar.StopScanning()
    lidar.Disconnect()

Install with pip install pylidar3 pyserial.

Step 4: Get ASI Biont to interpret the data

Now the magic. In ASI Biont chat, you type:

On COM3 there is a TFmini. Read distance every 2 seconds. Send me a Telegram alert if distance < 50 cm.

The AI will generate a script that uses the bridge's industrial_command() to read serial bytes, parse them, and call the Telegram Bot API. A typical snippet looks like this:

response = industrial_command(
    protocol='serial',
    command='read',
    data={'bytes': 9, 'port': 'COM3'}
)
distance = parse_tfmini(response)
if distance < 50:
    requests.post(
        'https://api.telegram.org/bot<TOKEN>/sendMessage',
        json={'chat_id': '<CHAT_ID>', 'text': f'Obstacle at {distance} cm'}
    )

Notice there is no send_telegram() — the AI simply uses requests.post to api.telegram.org.

Step 5: Turn scans into a map and control a robot

With RPLIDAR, the AI can construct an occupancy grid from successive scans. I connected my robot's motor controller to a GPIO pin, and asked ASI Biont for a command that stops the robot if any obstacle is closer than 30 cm. The script passed the stop value via GPIO, using RPi.GPIO:

import RPi.GPIO as GPIO
# ... after parsing scan ...
if min_distance < 30.0:
    GPIO.output(17, GPIO.LOW)  # stop signal to motor driver

ASI Biont can also publish the map to MQTT so other services (like a web dashboard) can consume it.

Step 6: Real-world scenario — disinfection robot

On a recent project, we used an RPLIDAR A1 to map a lab. The integration steps were exactly this: connect to USB, run bridge.py, and let ASI Biont write the mapping loop. The AI generated code that saved the scan as a JSON file every minute. When the robot entered a no-go zone, it sent a Telegram message with the current coordinates. This took 20 minutes, not two weeks.

Pitfalls that will eat your time

  • Don't run bridge.py and another serial script on the same port at the same time. You'll get 'Permission denied' or garbage readings.
  • Use the correct baud rate: 115200 for both RPLIDAR A1 and TFmini-S.
  • TFmini sends 9-byte frames; don't try to read variable-length strings.
  • In execute_python, respect the 30-second timeout; use for _ in range(...) instead of while True.
  • Use a separate 5V/1A power supply for RPLIDAR's motor; a Raspberry Pi USB port can brown-out.
  • Wait for the bridge to finish responding before sending a new industrial_command; otherwise the serial buffer gets mixed.

Why this integration approach wins

ASI Biont doesn't force you to configure a long list of fields. It reads the chat, then writes a Python script using pyserial, paramiko, paho-mqtt, pymodbus, aiohttp, or opcua-asyncio — whichever matches the device. That means you can connect not just LiDAR, but any serial device, PLC, industrial controller, or IoT gateway. The key is execute_python: if you can describe the port, IP, and protocol, the AI does the rest. No need to wait for developer support.

So plug in your RPLIDAR or TFmini, open asibiont.com, and ask: 'Read TFmini on COM3 and alert me in Telegram if anything comes closer than 40 cm.' Watch the AI write and run the integration in seconds. That's the difference between debugging a sensor driver and building a robot that sees.

← All posts

Comments