Gokux
Published © CC BY-NC-SA

Ultra Compact LiDAR Distance Meter/Range Finder

“tiny LiDAR laser range finder ” anUltra Compact LiDAR Distance Meter/Range Finder

AdvancedFull instructions provided2 hours811
Ultra Compact LiDAR Distance Meter/Range Finder

Things used in this project

Hardware components

Seeed studio xiao esp32c3
×1

Software apps and online services

Fusion 360
Autodesk Fusion 360

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

back_cap_pNaL15b4rX.stl

Sketchfab still processing.

main_body_8ljO1iPkuK.stl

Sketchfab still processing.

laser_range_finder_B6gmlNnV8c.step

Schematics

sch

Code

code

C/C++
/* This example shows how to get single-shot range
 measurements from the VL53L0X. The sensor can optionally be
 configured with different ranging profiles, as described in
 the VL53L0X API user manual, to get better performance for
 a certain application. This code is based on the four
 "SingleRanging" examples in the VL53L0X API.


 The range readings are in units of mm. */


#include <Wire.h>
#include <VL53L0X.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <MedianFilter.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels


// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);




VL53L0X sensor;


MedianFilter test(10, 0);


// Uncomment this line to use long range mode. This
// increases the sensitivity of the sensor and extends its
// potential range, but increases the likelihood of getting
// an inaccurate reading because of reflections from objects
// other than the intended target. It works best in dark
// conditions.


//#define LONG_RANGE




// Uncomment ONE of these two lines to get
// - higher speed at the cost of lower accuracy OR
// - higher accuracy at the cost of lower speed


//#define HIGH_SPEED
#define HIGH_ACCURACY






void setup()
{
  Serial.begin(9600);
  Wire.begin();


 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
 }
  sensor.init();
  sensor.setTimeout(500);


#if defined LONG_RANGE
  // lower the return signal rate limit (default is 0.25 MCPS)
  sensor.setSignalRateLimit(0.1);
  // increase laser pulse periods (defaults are 14 and 10 PCLKs)
  sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
  sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
#endif


#if defined HIGH_SPEED
  // reduce timing budget to 20 ms (default is about 33 ms)
  sensor.setMeasurementTimingBudget(20000);
#elif defined HIGH_ACCURACY
  // increase timing budget to 200 ms
  sensor.setMeasurementTimingBudget(200000);
#endif


  // Clear the buffer.
   display.setTextColor(WHITE);
 
}
void displayDistance( int val)
{
  display.clearDisplay();
  display.setTextSize(3);
  display.setCursor(40,32);
  display.print(val);


  display.setTextSize(1);
  display.setCursor(60,55);
  display.print("mm");
  display.display();
  delay(100);
}
void loop()
{
  int o,r = sensor.readRangeSingleMillimeters();
  test.in( r );
  o = test.out();
  Serial.print(o);
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }


  Serial.println();


  displayDistance( o );
 
}

Credits

Gokux

Gokux

17 projects • 12 followers

Comments