Project tutorial
LiDAR-Lite Module

LiDAR-Lite Module © GPL3+

Use a LiDAR-Lite module to measure distance with better accuracy, precision, and range.

  • 1,495 views
  • 0 comments
  • 6 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

Introduction

Similar to the last project, we’ll be interfacing a sensor that can measure distance, but instead of using ultrasonic sound waves, we use light in the form of a pulsed laser with a 905 nm wavelength. The LiDAR-Lite module offers better accuracy, precision, range, and more data samples per second than the ultrasonic sensor. LiDAR systems are typically found in autonomous vehicles, drones, and satellites to map terrain.

16x2 Character LCD

Please see Project 9 for more details on how to interface the 16×2 LCD in 4-bit mode. You should have pins 4, 6, and 11-14 of the LCD connected to Uno pins 2, 3, and 4-7, respectively. The LCD is mounted to the Modulus Canister via the 16-pin, right-angle female header soldered to the 1-to-1 link, as shown in the image below. You can also use a solderless breadboard to mount the LCD.

We are mounting the LiDAR to the Adapticon Canister. If you are doing this as well, you’ll have to remove the F/M jumper wires on Modulus and wire-wrap 30 AWG wire to the male header pins. This is so we can stack Modulus and Adapticon together.

Garmin LiDAR-Lite

LiDAR stands for “Light Detection and Ranging, ” and measures distances via a laser. The laser is a pulsed light source that has wavelengths ranging from ultraviolet through visible light and to infrared. They also vary in the amount of power – some are mW lasers (pointers) while others can be over 500W (used for cutting). This particular module has a laser that operates at a 905nm wavelength and 1.3 watts of power. The LiDAR-Lite emits a laser signal and measures the time it takes for the laser to return back once it reflects off of a target. Once the time is acquired, the distance can be calculated since we know time and the speed of light. The module makes this calculation and returns the distance to the host via I2C.

If you are using the module in PWM mode, it returns a HIGH pulse width that is proportional to the measured distance.

NOTE: This module emits laser radiation and is designated as a Class 1laser. All precautions should be taken regarding a Class 1 laser.

The LiDAR-Lite module consists of 6 pins: +5V, Power EN, Mode Control, I2C SCL, I2C SDA, and GND. The module can be operated in two modes: I2C (Inter-Integrated Circuit) and PWM (Pulse Width Modulation). We’ll be operating the module in I2C mode. There are two models that Garmin offers: LiDAR-Lite v3 and LiDAR-Lite v3HP. We are using the LiDAR-Lite v3 since it is cheaper. A table of specifications is shown below and Garmin’s full datasheet can be found here.

Inter-Integrated Circuit (I2C)

We’ll be using the module in I2C mode. Since we are only using one module, we do not have to change its default 7-bit slave address which is 0x62. Even though we only have one slave device, the master (Uno) must still send the address to the slave that it wants to communicate with. Along with the address, there is a read/write bit that tells the slave if the master wants to read or write to it.

The simplest way to obtain distance measurements from the LiDAR-Lite is:

  • Master writes 0x62 to address the slave and wait for acknowledge (ACK) bit from slave.
  • Master writes 0x04 to slave register 0x00. Register 0x00 of the LiDAR-Lite is Receiver Bias Correction. Writing 0x04 to this register tells the device that you want to take a distance measurement with receiver bias correction.
  • Master reads 0x01 register which indicates the LiDAR-Lite’s system status. If bit 0 (LSB) is a one, then the device is busy. If it is a zero, then we can proceed to obtain the distance measurement.
  • By setting the MSB of the address byte to one, we can trigger automatic incrementing of the register address with successive reads or writes. We want to read the high byte of the distance measurement which is in register 0x0F, so by setting the MSB to one, this address becomes 0x8F. By sending 0x8F, the master receives both the high-byte distance measurement and the low-byte distance measurement.

A timing diagram for the above steps is shown below.

Adapticon

We are using Adapticon to mount the LiDAR-Lite. Adapticon has footprints to mount a Raspberry Pi 3 Model B/B+, Raspberry Pi 4, Raspberry Pi Zero, and an Arduino Uno Rev3, so we created an adapter plate (made out of 1/8″ acrylic), that mounts to the RPi3 footprint, to be able to mount the LiDAR-Lite. Before mounting the plate to Adapticon, we must mount the LiDAR-Lite to the plate using four #4-40 x 3/8″ socket head screws and four #4 hex nuts. An image is shown below with the LiDAR-Lite mounted to the plate.

Once the LiDAR-Lite is mounted to the plate, we can then secure it to Adapticon using the provided hex standoffs and the #4-40 x 1/4″ socket head screws. The final assembly is shown below.

Canister Stack

Next, we need to connect Modulus and Adapticon together. It is recommended that you connect Modulus to Adapticon first (as shown in the image below) as opposed to inserting Modulus into the FuelCan’s 4×26-pin connector and then inserting Adapticon.

When you have the two Canisters mated, carefully insert the stack into the FuelCan’s 4×26-pin connector and plug in the wiring harness for the LiDAR-Lite, as shown in the image below.

LiDAR-Lite Wiring

The harness has a JST female connector on one side and stripped ends on the other side. You may need to tin the ends of the wire so it does not bend when you insert the ends into the breadboard. Place a solderless breadboard into the bottom storage compartment and insert each stripped end into adjacent nodes on the breadboard. Place a polarized 680uF electrolytic capacitor between pins 1 and 6 (5Vdc and GND, respectively) of the module. Make sure the capacitor is oriented correctly or it could become damaged or explode when you power up the device.

Use an 8″ M/M jumper to connect LiDAR-Lite pins 4 (I2C SCL) and 5 (I2C SDA) to the Uno’s analog in pins A5 and A4, respectively. LiDAR-Lite pins 2 and 3 are connected to the breadboard, but they are not connected to anything – pin 2 has an internal pull-up resistor to enable the device at all times and pin 3 is unconnected since we’re using I2C mode. The circuit schematic is shown below.

FuelCan Wiring

If you haven’t mounted the Uno onto the prototyping area of the FuelCan, go ahead and do that. If you are using a breadboard instead of Modulus, place the breadboard in the bottom storage compartment to limit the length of the jumper wires. You’ll need to supply +5V and GND to the power and ground rails on the breadboard by using the provided banana jack to test-lead clip cables. You will need two male header pins to mount the test-lead clips on the breadboard side. Plug the Type A side of the USB cable into USB1 receptacle and the Type B side into the Uno’s receptacle. Power up the FuelCan with the AC-DC power adapter.

Software

Once the wiring is complete and the FuelCan is powered up, we can now load the sketch onto the Uno. You will need Garmin’s LiDAR-Lite library which is available here. It will direct you to their GitHub repository.

Once you download the library, add it to your Arduino IDE by navigating to Sketch -> Include Library -> Add.ZIP Library…. You can also install the library by going to Sketch -> Library Manager and searching “LIDAR.” When the search results pop up, install the LIDAR-Lite by Garmin library.

The first sketch below acquires distance measurements without receiver bias corrections which does not take target distance, device temperature, or optical noise into account. One advantage to not using receiver bias corrections is that you can acquire distance measurements much faster. However, the accuracy and sensitivity will be affected.

The next sketch (below) performs receiver bias corrections periodically. It is recommended to do this every 100 sequential measurement commands. By using receiver bias corrections, accuracy and sensitivity are improved. However, acquiring distance measurements is slower.

Digital Waveforms

The digital waveforms were acquired on the SCL and SDA wires. The first waveform (below) shows the master communicating with the slave that it wants to write 0x03 (no receiver bias corrections) to slave register 0x00.

The second waveform (below) shows the master polling the slave status register 0x01 until bit 0 is a zero. You can see that that the status register is read twice since bit 0 is a one.

The third waveform (below) shows the master polling the slave status register 0x01 until bit 0 is a zero. The second time the slave register was polled, bit 0 was a zero, so the master was able to proceed with retrieving the distance measurement from the slave. The master sends 0x8F for successive reads of slave registers 0x0F and 0x10. In the final frame, the slave sends the two bytes of data, 0x01 and 0x05, from registers 0x0F and 0x10, respectively.

Code

LiDAR-Lite No BiasArduino
//Interface LiDAR-Lite module and display distance on LCD
//Without receiver bias corrections

#include <LiquidCrystal.h>
#include <Wire.h>
#include <LIDARLite.h>

//variable declarations
int distancecm;
int distancein;
const int RS = 2, EN = 3, D4 = 4, D5 = 5, D6 = 6, D7 = 7;

LiquidCrystal lcd(RS,EN,D4,D5,D6,D7);   //set Uno pins that are connected to LCD, 4-bit mode
LIDARLite lidarLite;

void setup() {
  lcd.begin(16,2);            //set 16 columns and 2 rows of 16x2 LCD
  lidarLite.begin(0, true);   //set config to default and I2C to 400kHz, starts I2C
  lidarLite.configure(0);     //there are 6 different configs available, 0 is default
}

void loop() {
  distancecm = lidarLite.distance(false);    //without bias correction, faster distance measurements performed
  distancein = distancecm*0.3937;           //1cm = 0.3937in
  
  //display distance to LCD
  lcd.clear();
  lcd.print("Distance: ");
  lcd.print(distancecm);
  lcd.print("cm");
  lcd.setCursor(10,1);
  lcd.print(distancein);
  lcd.print("in");
  delay(1000);
}
LiDAR-Lite BiasArduino
//Interface LiDAR-Lite module and display distance on LCD
//With receiver bias corrections

#include <LiquidCrystal.h>
#include <Wire.h>
#include <LIDARLite.h>

//variable declarations
int distancecm;
int distancein;
uint8_t i = 0;
const int RS = 2, EN = 3, D4 = 4, D5 = 5, D6 = 6, D7 = 7;

LiquidCrystal lcd(RS,EN,D4,D5,D6,D7);   //set Uno pins that are connected to LCD, 4-bit mode
LIDARLite lidarLite;

void setup() {
  lcd.begin(16,2);            //set 16 columns and 2 rows of 16x2 LCD
  lidarLite.begin(0, true);   //set config to default and I2C to 400kHz, starts I2C
  lidarLite.configure(0);     //there are 6 different configs available
}

void loop() {
  distancecm = lidarLite.distance();     //with bias correction
  distancein = distancecm*0.3937;        //1cm = 0.3937in
  
  //display distance to LCD
  lcd.clear();
  lcd.print("Distance: ");
  lcd.print(distancecm);
  lcd.print("cm");
  lcd.setCursor(10,1);
  lcd.print(distancein);
  lcd.print("in");
  delay(1000);

  for(i = 0; i < 100; i++){
    distancecm = lidarLite.distance(false);     //with bias correction
    distancein = distancecm*0.3937;             //1cm = 0.3937in
  
    //display distance to LCD
    lcd.clear();
    lcd.print("Distance: ");
    lcd.print(distancecm);
    lcd.print("cm");
    lcd.setCursor(10,1);
    lcd.print(distancein);
    lcd.print("in");
    delay(750);
  }
}

Custom parts and enclosures

Adapter Plate
lidar-lite_adapter_plate_YFFP4xejY6.step

Schematics

Circuit Schematic
Circuit schematic p13 v2 dz7squzhao

Comments

Similar projects you might like

Servo Motor Using Arduino & PCA9685 16 Chanel Module

Project tutorial by Jithin Sanal

  • 39,858 views
  • 2 comments
  • 22 respects

Control Arduino Uno Using ESP8266 WiFi Module and Blynk App

Project tutorial by Adithya TG

  • 28,656 views
  • 12 comments
  • 39 respects

Arduino + GPS Module - Destination Notifier

Project tutorial by Amal Mathew

  • 3,319 views
  • 3 comments
  • 22 respects

How to Interface Arduino Mega with NEO-6M GPS Module

Project tutorial by Ruchir Sharma

  • 2,428 views
  • 0 comments
  • 8 respects

Nerf Scope Module | Arduino Project

Project tutorial by Michael Darby - 314Reactor

  • 2,026 views
  • 1 comment
  • 8 respects

Morse Code Communication Using Laser Module (Both)

Project tutorial by SURYATEJA

  • 1,713 views
  • 1 comment
  • 11 respects
Add projectSign up / Login