1

I came across this instructable which illustrates how to connect the TFMini LiDAR to the Raspberry Pi. In the list of materials, he said that I will be needing a Resistor (between 100-1k Ohm) (optional) but I haven't seen it on the actual pics. He also used USB - TTL converter, which is excellent for me because it's the easiest way to connect the module to the pi!

I have a few concerns though:

Since the Pi only has 4 USB ports and I will be needing to control 5 Lidar modules, is it advisable to use a USB hub to extend my ports?

In the tutorial he also said:

The code could be used to print the distance, but since RPi does not have a lot of processing power, it is advised to light an LED if the distance recorded is below a certain range

I'm not quite sure what that meant, I mean RPi has considerable processing power as compared to an Arduino. What does Arduino have that I should pick it over the RPi?

  • Quick comments: (1) You might not need 5 Lidars. You can just use one front, one rear, with servos rotating and sensing at the same time. Five Lidar might be difficult to cooperate. (2) If you insist, you can use 5 Lidars, just use a 6 port USB hub and 6 USB to UART cables to entertain 6 Lidars. (3) If your Lidar is mount on the top of a racing car at high speed, Rpi might not be powerful enough to do realtime processing, so you can use an alarm LED you are moving too fast, or out of measurment range etc. – tlfong01 Sep 9 at 13:39
2

Question

Can Rpi control 5 lidars at the same time?

Answer

lidar car

(1) You might not need 5 Lidars. You can just use one front, one rear, with servos rotating and sensing at the same time. Five Lidar might be difficult to cooperate.

(2) If you insist, you can use 5 Lidars, just use a 6 port USB hub and 6 USB to UART cables to entertain 6 Lidars.

(3) If your Lidar is mounted on the top of a racing car at high speed, Rpi might not be powerful enough to do real time processing, so you can use an alarm LED you are moving too fast, or out of measurement range (0.3m ~ 12m) etc.

(4) The Instructable's Rpi IDLE python program looks OK, though too brief. I guess you need to check out the GitHub.

(5) I read the spec and found that it uses near infra red, NOT laser. I doubt it can be called a Lidar.

(6) Actually I a couple of years ago I bought much cheaper infra red sensor, as cheap as the cheap ultrasound sensor. If you are a poor hobbyist like me, I would suggest to start small, first with ultrasound sensor, then infrared sensor, then Lidar (US$40, actually infra red, not laser), then the real thing real Lidar (I read that it costs 2,000 RMB).

(7) Rpi4B has 4 UARTs (Also I2C, SPI) on board. So you can connect 4 Lidars to the 40 pin connector, totaling 8, using the USB connectors. There is also an I2C version of the Lidar. So you can forget UART altogether, and connect many of them on the same I2C bus.

(8) AdaFruit's real laser thing also talks I2C. So no worries about how many you can connect.

References

(1) Lidar- Wikipedia

(2) Benewake LiDAR Module Specification

(3) TFmini Lidar Range Finder YouTube Demo

(4) TFmini andTFmini-Plus GitHub

(5) TFmini andTFmini-Plus GitHub Rpi

(6) Benewake LiDAR Products (with introduction video)

(7) Amazon MakerFocus UART Interface Lidar Range Finder Module - US$40

(8) Robot Shop Benewake TFMINI 12 metre UART Interface Micro LIDAR Module - US$38

(9) VL6180X Proximity and ambient light sensing (ALS) module Datasheet - ST

(10) Adafruit VL6180X Time of Flight Distance Ranging Sensor (VL6180) Tutorial

(11) Adafruit VL6180X Time of Flight Distance Ranging Sensor (VL6180) User Guide

(12) VL6180X 近距离感测器 光学测距 环境光线传感器 手势识别开发板 - ¥27

(13) YdLidar X4 Laser Radar Distance Sensor 10 meters 360 degrees motor driven ¥450

(14) YdLidar X4 Datasheet - Elecrow

Appendices

(A) VL6180X Time of Flight Distance Ranging Sensor Description - Lady Ada

The VL6180X is a Time of Flight distance sensor. The sensor contains a very tiny laser source, and a matching sensor. The VL6180X can detect the "time of flight", or how long the laser light has taken to bounce back to the sensor. Since it uses a very narrow light source, it is good for determining distance of only the surface directly in front of it.

Unlike sonars that bounce ultrasonic waves, the 'cone' of sensing is very narrow. Unlike IR distance sensors that try to measure the amount of light bounced, the VL6180X is much more precise and doesn't have linearity problems or 'double imaging' where you can't tell if an object is very far or very close.

This is the 'little sister' of the Adafruit VL53L0X ToF sensor, and can handle about 5mm to 100mm of range distance. We've seen up to 150-200mm with good ambient conditions. It also includes a lux sensor. If you need a larger range, check out the VL53L0X which can measure 50 - 1200 mm.

The sensor is small and easy to use in any robotics or interactive project. Since it needs 2.8V power and logic we put the little fellow on a breakout board with a regulator and level shifting. You can use it with any 3-5V power or logic microcontroller with no worries.

Communicating to the sensor is done over I2C with some simple commands. Most of the work is handled inside the sensor itself , ...

The VL6180X is a I2C sensor. That means it uses the two I2C data/clock wires available on most microcontrollers, and can share those pins with other sensors as long as they don't have an address collision. For future reference, the I2C address is 0x29 and you can't change it!

(B) AdaFruit VL6180X Demo Python Code

# Demo of reading the range and lux from the VL6180x distance sensor and # printing it every second. # Author: Tony DiCola
https://learn.adafruit.com/adafruit-vl6180x-time-of-flight-micro-lidar-distance-sensor-breakout/python-circuitpython

import time

import board
import busio

import adafruit_vl6180x

# Create I2C bus.

i2c = busio.I2C(board.SCL, board.SDA)

# Create sensor instance.
sensor = adafruit_vl6180x.VL6180X(i2c)

# Main loop prints the range and lux every second:
while True:
    # Read the range in millimeters and print it.
    range_mm = sensor.range
    print('Range: {0}mm'.format(range_mm))
    # Read the light, note this requires specifying a gain value:
    # - adafruit_vl6180x.ALS_GAIN_1 = 1x
    # - adafruit_vl6180x.ALS_GAIN_1_25 = 1.25x
    # - adafruit_vl6180x.ALS_GAIN_1_67 = 1.67x
    # - adafruit_vl6180x.ALS_GAIN_2_5 = 2.5x
    # - adafruit_vl6180x.ALS_GAIN_5 = 5x
    # - adafruit_vl6180x.ALS_GAIN_10 = 10x
    # - adafruit_vl6180x.ALS_GAIN_20 = 20x
    # - adafruit_vl6180x.ALS_GAIN_40 = 40x
    light_lux = sensor.read_lux(adafruit_vl6180x.ALS_GAIN_1)
    print('Light (1x gain): {0}lux'.format(light_lux))
    # Delay for a second.
    time.sleep(1.0)

.END

(C) Lidar Rpi3 Python Programs

(D) Instructable Lida python program listing

import serial
import time
import RPi.GPIO as GPIO

LEDpin = 11

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(LEDpin,GPIO.OUT)
GPIO.output(LEDpin,GPIO.LOW)

ser = serial.Serial('/dev/ttyUSB1',115200,timeout = 1)

#ser.write(0x42)
ser.write(bytes(b'B'))

#ser.write(0x57)
ser.write(bytes(b'W'))

#ser.write(0x02)
ser.write(bytes(2))

#ser.write(0x00)
ser.write(bytes(0))

#ser.write(0x00)
ser.write(bytes(0))

#ser.write(0x00)
ser.write(bytes(0))

#ser.write(0x01)
ser.write(bytes(1))

#ser.write(0x06)
ser.write(bytes(6))

while(True):
    while(ser.in_waiting >= 9):
        #print (ser.read())
        if((b'Y' == ser.read()) and ( b'Y' == ser.read())):

            GPIO.output(LEDpin, GPIO.LOW)
            Dist_L = ser.read()
            Dist_H = ser.read()
            Dist_Total = (ord(Dist_H) * 256) + (ord(Dist_L))
            for i in range (0,5):
                ser.read()

        #print(Dist_Total)
            if(Dist_Total < 20):
                GPIO.output(LEDpin, GPIO.HIGH)
  • Im not mounting it on a vehicle, just to measure object's distance. Is it not a LIDAR as what was posted? Its misleading then. – r2b2 Sep 9 at 20:46
  • If the TFMini is not using laser, how about this one adafruit.com/product/3316 – r2b2 Sep 9 at 23:48
  • @r2b2, Yes, VL6180X is real laser. I have updated my answer's references. So you might take a look. If goal is to learn something, building a toy car, for example, VL6018X is ideal, ... – tlfong01 Sep 10 at 1:32
  • Excellent answer tifong01 ! Very thorough! Thank you! – r2b2 Sep 10 at 1:57
  • @r2b2, Thank you for your nice words. By the way, you might also like to consider this, if you are a rich hobbyist: Laser Radar Distance Sensor 10 meters 360 degrees motor driven ¥450 detail.tmall.com/… – tlfong01 Sep 10 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.