Distance Reading Problems with Lidar-Lite V3

I am currently working on a project for a class that involves distance measurement between parked cars. Recently, I purchased a Lidar-Lite V3 sensor from Sparkfun to use for measuring this distance. I followed the instructions on Sparkfun’s website linked below for the sensor’s setup. After setting up the sensor as depicted on the website (over I2C) and installing the Lidar-Lite V3 Arduino library, I ran tests to see if the distance measurements were accurate. The serial monitor, though, printed distance values about 10 cm off at lower ranges (0 cm - 50 cm) and varying differences in distance from the actual distance for 50+cm values.

https://learn.sparkfun.com/tutorials/lidar-lite-v3-hookup-guide

Here’s the code I’m currently using with my sensor from the Sparkfun website

/**
 * LIDARLite I2C Example
 * Author: Garmin
 * Modified by: Shawn Hymel (SparkFun Electronics)
 * Date: June 29, 2017
 * 
 * Read distance from LIDAR-Lite v3 over I2C
 * 
 * See the Operation Manual for wiring diagrams and more information:
 * http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf
 */

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

// Globals
LIDARLite lidarLite;
int cal_cnt = 0;

void setup()
{
  Serial.begin(9600); // Initialize serial connection to display distance readings

  lidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz
  lidarLite.configure(0); // Change this number to try out alternate configurations
}

void loop()
{
  int dist;

  // At the beginning of every 100 readings,
  // take a measurement with receiver bias correction
  if ( cal_cnt == 0 ) {
    dist = lidarLite.distance();      // With bias correction
  } else {
    dist = lidarLite.distance(false); // Without bias correction
  }

  // Increment reading counter
  cal_cnt++;
  cal_cnt = cal_cnt % 100;

  // Display distance
  Serial.print(dist);
  Serial.println(" cm");

  delay(10);
}

I have attempted to work with HC-SR04 ultrasonic sensors and Sharp IR sensors, but both also had problems with inaccurate measurement. I’m fairly new to sensors and Arduino, so any help with getting accurate distance measurements would be appreciated :smiley:

tapsoc:
distance values about 10 cm off at lower ranges (0 cm - 50 cm) and varying differences in distance from the actual distance for 50+cm values.

Is it operating within spec. ?

LIDAR_Datasheet:
Accuracy < 5m +/- 2.5cm typical (Nonlinearity present below 1m)
Accuracy >=5m +/- 10cm typical

How accurate did you expect it to be ?

Yours,
TonyWilk

TonyWilk:
How accurate did you expect it to be?

The finished product will likely only require about 3-4 meters of range at maximum. I understand that at higher ranges there will be a greater variation in distance readouts, but I would like to achieve the +/- 2.5cm resolution at ranges < 5m as they discuss in the operation manual. Currently, I am getting the +/- 10cm across all ranges, not just those above 5m.

Hey Man,

I have the same “problem”… but if you make a good old array and other stuff, the measures can be “good”.
I us it for the same stuff, if you need help say hello! :slight_smile:

void loop()
{

const byte ANZAHL_MESSUNGEN = 20; //Array with 20 xTimes (myLidarLite.distance()…
unsigned int reading0 = 0;

for(byte i = 0; i < ANZAHL_MESSUNGEN; i++)
{
reading0 += myLidarLite.distance();

}

reading0 /= ANZAHL_MESSUNGEN;

Entfernung =reading0;
smoothWert = 0.50 * smoothWert + 0.50 * reading0;
differenz = abs(Entfernung - EntfernungAlt); //WERTE der Messung bei 0.6 zu 0.4 etwas genauer!!! Dafür kleiner als Orginal!!!

if (differenz <= 5 && quickAktiv == false) {
quickSmooth = 0.50 * smoothWert + 0.50 * reading0; //WERTE der Messung bei 0.6 zu 0.4 etwas genauer!!! Dafür kleiner als Orginal!!!
}
else if (differenz <= 5 && quickAktiv == true){
quickSmooth = myLidarLite.distance();
x++;
}
else {
quickSmooth = myLidarLite.distance();
quickAktiv = true;
};

if (x >= 10) {
x = 0;
quickAktiv = false;
};
EntfernungAlt = Entfernung;

Serial.print("\t");
Serial.print(myLidarLite.distance());
Serial.print("\t");
Serial.print(reading0);
Serial.print("\t");
Serial.print(smoothWert);
Serial.print("\t");
Serial.print(differenz);
Serial.print("\t");
Serial.print(quickSmooth);
Serial.print("\t");
Serial.println(quickAktiv);

}