Integrating LiDAR (RPLIDAR, TFmini) with ASI Biont AI Agent: Real-Time Navigation and Automation

Introduction: Why Connect a LiDAR to an AI Agent?

LiDAR (Light Detection and Ranging) sensors like the Slamtec RPLIDAR A1/A2 and Benewake TFmini are the eyes of modern robotics — they provide real-time distance measurements, enabling obstacle avoidance, mapping, and autonomous navigation. But raw LiDAR data is just numbers: a stream of angles and distances. To turn that into actionable intelligence — like "stop before hitting the wall" or "map this room" — you need a decision-making engine. That's where ASI Biont comes in.

ASI Biont is an AI agent that connects to any device via natural language conversation. Instead of writing complex integration code from scratch, you simply describe your LiDAR setup, and the AI writes the Python or MicroPython code to read sensor data, analyze it, and trigger actions. This article covers how to integrate RPLIDAR and TFmini with ASI Biont using COM port (via Hardware Bridge), MQTT, and SSH, with real code examples and wiring diagrams.

Which Connection Method and Why?

LiDAR sensors typically communicate over UART (serial) or USB-to-serial adapters. For example:
- RPLIDAR A1/A2: outputs data at 115200 baud over USB serial (virtual COM port).
- TFmini: a smaller, lightweight lidar that communicates at 115200 baud via UART or I²C.

To connect such devices to ASI Biont, the most practical methods are:

Method Use Case Pros Cons
COM port via Hardware Bridge Direct connection from PC to LiDAR Low latency, no network required Requires bridge.py running on PC
SSH to Raspberry Pi LiDAR connected to a single-board computer Remote control, can run complex scripts Requires network, SSH credentials
MQTT Sending LiDAR data to broker for IoT Decouples sensor from AI, scalable Extra latency, needs broker

For this guide, we'll focus on the COM port method — it's the most direct and common for LiDAR sensors.

Real-World Scenario: Obstacle Avoidance Robot

Imagine you're building a wheeled robot with an RPLIDAR A1 mounted on top. The robot must navigate a room, avoiding furniture and walls. The LiDAR spins at 5-10 Hz, sending 360° distance data. You want the AI to:
1. Read the LiDAR data in real time.
2. Detect obstacles within 50 cm.
3. Send a command to the robot's motor controller (e.g., "turn left 30°") via a second serial port.

Step 1: Connect the LiDAR

  • Plug the RPLIDAR into your PC via USB. It appears as COM3 (Windows) or /dev/ttyUSB0 (Linux).
  • Download and run bridge.py from ASI Biont, specifying the COM port and baud rate:
python bridge.py --token=YOUR_TOKEN --ports=COM3 --default-baud=115200
  • The bridge connects to ASI Biont via HTTP long polling, creating a secure tunnel to your local serial port.

Step 2: Describe the Task in Chat

In ASI Biont, you write:

"Connect to RPLIDAR on COM3 at 115200 baud. Send the start motor command (byte 0xA5 0x60). Continuously read scan data packets. Each packet starts with header 0xFA and contains quality, angle, and distance. If any distance is < 50 cm, print 'OBSTACLE DETECTED at angle X' and send a telegram alert."

Step 3: AI Generates and Runs the Code

ASI Biont uses its industrial_command tool to send commands through the bridge. It first sends a command to start the LiDAR motor, then reads responses. The AI writes a Python script that runs in the sandbox (execute_python) to parse the serial data. Here's a simplified example of what the AI might generate:

import serial
import struct

# Send start motor command (RPLIDAR)
ser = serial.Serial('COM3', 115200, timeout=1)
ser.write(b'\xa5\x60')  # start motor

# Read response
response = ser.read(7)  # first response: 4 bytes descriptor + data
if response[0] == 0xA5:  # sync byte
    print("LiDAR started")

# Read scan data loop (simplified)
while True:
    # Look for packet header 0xFA
    byte = ser.read(1)
    if byte == b'\xFA':
        # Read 5 bytes: quality (1), angle (2), distance (2)
        packet = ser.read(5)
        quality = packet[0] >> 2
        angle = struct.unpack('<H', packet[1:3])[0] / 64.0
        distance = struct.unpack('<H', packet[3:5])[0] / 4.0
        if distance < 500:  # 50cm in mm
            print(f"OBSTACLE at {angle:.1f}°, distance={distance:.0f}mm")
            # Send alert via Telegram (using HTTP API)
            # requests.post(...)

Note: The above code is a simplified example. In reality, RPLIDAR data frames are more complex (multiple scan points per packet). The AI handles the full protocol.

Step 4: AI Executes and Monitors

ASI Biont runs the code in the sandbox (execute_python) and streams output back to the chat. If an obstacle is detected, the AI can automatically send a command to the robot's motor controller via a second serial port (e.g., COM4) using another industrial_command.

TFmini Integration via SSH on Raspberry Pi

The TFmini is a smaller, fixed-beam lidar ideal for distance sensing. Connect it to a Raspberry Pi's UART pins (GPIO 14/15) or USB-to-serial. Then use SSH to connect ASI Biont to the Pi:

  1. Enable UART on Raspberry Pi (/boot/config.txt).
  2. Connect TFmini VCC to 5V, GND to GND, TX to RX (GPIO 15), RX to TX (GPIO 14).
  3. In ASI Biont chat: "SSH into raspberrypi.local with user pi, key. Read TFmini data from /dev/ttyAMA0 at 115200 baud. Parse 9-byte frames (0x59, 0x59, dist_low, dist_high, strength_low, strength_high, temp_low, temp_high, checksum). If distance < 30cm, turn on GPIO 18 (LED)."

The AI generates a Python script using paramiko, connects via SSH, and runs the script on the Pi. It then monitors the output and can even modify the script on the fly.

Wiring Diagram for TFmini with Raspberry Pi

TFmini Pin Raspberry Pi Pin Wire Color
VCC (5V) Pin 4 (5V) Red
GND Pin 6 (GND) Black
TX Pin 10 (RX, GPIO15) Green
RX Pin 8 (TX, GPIO14) White

Note: The TFmini operates at 3.3V logic, so it's safe to connect directly to the Pi's UART pins. For 5V devices like some Arduinos, use a level shifter.

Why This Integration is Revolutionary

Traditionally, programming a LiDAR involves:
- Reading datasheets (e.g., RPLIDAR communication protocol is 30+ pages).
- Writing low-level serial code (handling sync bytes, checksums, timeouts).
- Debugging packet parsing errors.
- Writing separate scripts for different actions (alerts, logging, motor control).

With ASI Biont, you just describe what you want in plain English. The AI knows the protocols, writes the code, tests it, and can adapt in real time. No waiting for library updates — the AI can generate custom parsers for any LiDAR model.

Practical Benefits

  • Speed: Integration takes minutes instead of days.
  • Flexibility: Change sensor behavior by just typing a new request.
  • Remote Monitoring: The AI can log data to a database, send SMS alerts, or visualize distance on a web dashboard via HTTP API.
  • No Coding Required: Even non-programmers can set up complex robotics tasks by describing them.

Getting Started

To try it yourself:
1. Sign up at asibiont.com.
2. Plug your LiDAR into your PC or Raspberry Pi.
3. In the chat, type something like: "Connect to RPLIDAR on COM3 at 115200, read scan data, and if anything is closer than 50cm, print the angle."
4. Watch the AI do the rest.

Example Chat Commands

  • "Read TFmini distance on /dev/ttyUSB0, baud 115200, and log to a CSV file every second."
  • "Connect to RPLIDAR A1 on COM5, start motor, and if distance < 30cm in any direction, send a POST request to http://myrobot.local/stop."
  • "Use SSH to connect to my Raspberry Pi at 192.168.1.100, run a script that reads TFmini and publishes distance to MQTT topic 'robot/distance'."

Conclusion

LiDAR sensors are powerful but require tedious low-level programming. ASI Biont eliminates that friction by acting as an intelligent bridge between your hardware and your goals. Whether you're building a robot vacuum, a security patrol bot, or a smart warehouse system, connecting LiDAR to ASI Biont unlocks real-time AI-driven automation.

Stop writing protocol parsers — start describing what you want your robot to do. Try ASI Biont today at asibiont.com.

← All posts

Comments