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 ![]()