In this tutorial, you will learn how to get started with your Garmin (Qwiic) LIDAR-Lite v4 LED, including:
1. How to connect the LIDAR-Lite v4 to Arduino.
2. How to use parameters of the sensor.
3. The operational detection range of the sensor.
Garmin (Qwiic) LIDAR-Lite v4 LED is a LIDAR (Light Detection and Ranging) system that uses echolocation to detect objects. The sensor offers high accuracy and low-power consumption in a tiny package.
Like all the LIDAR-Lite line, this sensor provides an alternative to the expensive laser LIDAR sensors and the very cheap – but noise affected and low range – infrared and ultrasonic sensors. Since I plan to use a laser-based sensor in the future for indoor and outdoor robots, first, I want to discover if the cheapest version that is using LED and optics instead of a laser can be used indoors to build a 2D obstacle detection system.
For this tutorial, I bought the Qwiic version of LIDAR-Lite v4. The LIDAR-Lite v4 sensor comes in two versions: the sensor with the Qwiic connecting system and the sensor without the connection system. The Qwiic system provides an easy interface with development boards.
The sensor measures the time of flight for a light using an LED, optics, and receptor. It sends a near-infrared light and looks for its reception after the reflection of a target object. The sensor calculates the time delay between the transmission and the response of the beam light using the known speed of light.
LIDAR-Lite v4 is an active remote sensing system that generates energy – in this case, light – to measure the distance between the sensor and objects. Using an LED instead of the laser makes this sensor safe for eyes. This is important for me for the moment since I use the sensor without safety protection equipment.
Until now, we saw the variants and how the sensor works. To learn how to connect the sensor to Arduino, use parameters of the sensor, and determine the operational detection range of 1 meter in front of the sensor, keep reading the tutorial. I promise that you will know all of these.
1. How to connect the LIDAR-Lite v4 to Arduino
The simplest solution to read the outputs of the LIDAR-Lite v4 sensor is using the I2C interface with Arduino. In addition to the I2C, the sensor includes a wireless communication system called ANT. A tutorial using the ANT system is beyond the scope of this tutorial. My goal is to use the sensor with a microcontroller board and read the output via the I2C interface.
For this tutorial, I use an Arduino UNO board to read and control the sensor. This is important because the I2C interface is using the SDA (data line) and SCL (clock line) of the board. If you are using another microcontroller board, you have to be sure which pins are the SDA and SCL.
The I2C pins for Arduino boards:
- Uno, Ethernet:A4 (SDA), A5 (SCL)
- Mega2560: 20 (SDA), 21 (SCL)
- Leonardo: 2 (SDA), 3 (SCL)
- Due: 20 (SDA), 21 (SCL), SDA1, SCL1
The sensor requires a current of 85 mA during data acquisition. The 5V pin of Arduino UNO is suitable for ~400 mA on USB, and ~900 mA when it is used with an external power adapter. If you choose to power the sensor using the 5V pin of Arduino, it is recommended to use a 680uF capacitor between + and – pins to mitigate inrush current when the device is enabled.
Instead of using the 5V pin of Arduino to power the sensor, I use a battery and a step-down voltage regulator to supply a 5V voltage to the sensor.
Once we know the data line and clock line pins, we connect the sensor to the Arduino board. For UNO and external power supply, the connections are:
- LIDAR-Lite 5 VDC to 5V power supply;
- LIDAR-Lite Ground to Gnd power supply and to Arduino Gnd; (we have to share the ground between power supply and Arduino)
- LIDAR-Lite I2C SDA to Arduino SDA (for UNO is pin A4)
- LIDAR-Lite I2C SCL to Arduino SCL (for UNO is pin A5)
Another advantage of using the I2C interface is that you can configure the LIDAR sensor address and chain together up to ten sensors on one microcontroller platform.
The LIDARLite_Arduino_Library makes getting data easy and supports changing the I2C address and the parameters to configure the sensor.
You can download the library and use the “Add .ZIP Library…” menu from Arduino IDE to install the library.
Arduino sketch to read and transform in centimeters the output of the sensor:
byte liddarLiteAddress = 0x62;
// Initialize Arduino serial port
// Initialize Arduino I2C (for communication to LidarLite)
#if ARDUINO >= 157
Wire.setClock(400000UL); // Set I2C frequency to 400kHz (for Arduino Due)
TWBR = ((F_CPU / 400000UL) - 16) / 2; // Set I2C frequency to 400kHz
if (myLidarLite.getBusyFlag() == 0)
// Trigger the next range measurement
// Read new distance data from device registers
distance = myLidarLite.readDistance();
Serial.print("Sensor distance: ");
At this moment, we know how to read and transform in centimeters the output of the sensor. In the next part of the tutorial, we go further and learn how to use the parameters of the sensor.
2. How to use parameters of the sensor
In this part of the tutorial, we will work with the parameters of the sensor.
In the datasheet of the sensor is a list of control register lists. Some of these parameters can be read (status, board temperature, the hardware version, and more), while most of them can be read/update with values to fit your requirements.
The parameters in the datasheet:
To read a parameter:
regAddr: register address to read
dataBytes: pointer to array of bytes to read
numBytes: number of bytes in 'dataBytes' array to read
lidarliteAddress: Default 0x62.*/
byte liddarLiteAddress = 0x62;
myLidarLite.read(0xE0, distanceArray, 1, liddarLiteAddress);
Serial.print("Board temperature: ");
Writing a parameter is as easy as reading one. Before writing the parameter, you have to check the datasheet for a valid value of the function.
regAddr: register address to write to
dataBytes: pointer to array of bytes to write
numBytes: number of bytes in 'dataBytes' array to write
lidarliteAddress: Default 0x62.*/
uint8_t dataByte = 0x00;
myLidarLite.write(0xEB, &dataByte, 1, 0x62); // Turn off high accuracy mode
Until now, we connected the sensor to the Arduino, print on serial the distance measured, and read/write the parameters of the sensor. In the next part of the tutorial, we will determine the operational detection range for 1 meter in front of the sensor.
3. The operational detection range of the sensor
Obstacle detection is applicable to autonomous robots that move from an initial position to a goal position avoiding any obstacle in its path. We aim to detect all objects in a particular area in front of the sensors regardless of the shape or size of the object.
The first step in determining the range of the LIDAR sensor is to decide the range that you need for your robot. Let me explain what it means!
The LIDAR-Lite v4 sensor has up to 10 meters range at a resolution of 1 centimeter. For an indoor robot, a range of 10 meters means a lot, while for an outdoor robot that is moving fast in a dynamic environment – it is not enough.
My aim is to use the LIDAR-Lite v4 with a servo motor to build a 2D-based object detection system. The system will be attached to a mobile robot and tested indoors. I will show you the results in another article.
Since I don’t have large spaces inside my apartment, an operational detection range of 1 meter in front of the sensor is enough for the moment.
As you can see from the result of my test, the operational detection range for 1 meter in front of the sensor can be interpreted as being a square with 7cm sides.
The sensor has low power consumption and is very stable in determining the distance. During testing, I used several types of objects made of different materials – wooden, plastic, and soft materials were accurately detected. This is what I liked most at LIDAR-Lite v4.
The lack of mounting holes or any other types of supports could be an issue in case the sensor will be mounted on a mobile robot. To make things harder, the interface for connections is on one side, which makes fixing support much more difficult.