See also this more info post. This sensor is a carrier/breakout board for ST’s VL53L0X laser-ranging sensor, which measures the range to a target object up to 2 m away. The VL53L0X uses time-of-flight measurements of infrared pulses for ranging, allowing it to give accurate results independent of the target’s color and surface. Distance measurements can be read through a digital I²C interface. The board has a 2.8 V linear regulator and integrated level-shifters that allow it to work over an input voltage range of 2.6 V to 5.5 V, and the 0.1″ pin spacing makes it easy to use with standard solderless breadboards and 0.1″ perfboards.
The connections are pretty easy, see the image below with the breadboard circuit schematic. The sensor the data uisng i2c communication. For that connect A4 from the Arduino to the SDA pin and A5 to the SCL pin. Do the same for the LCD inc ase you want to print the values to the LCD screen instead of serial monitor.
Download the code from below. You will also need the Adafruit_VL53L0X library. Below are 2 codes, one with serial print and another with i2c LCD print. Select the one you want. Compile, upload, make the connections and open serial monitor at 9600 bauds and see the results.
// SVL53L0X Distance Test
// http://www.electronoobs.com/eng_arduino_tut73.php
#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
Serial.begin(9600);
// wait until serial port opens for native USB devices
while (! Serial) {
delay(1);
}
Serial.println("Adafruit VL53L0X test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4) { // phase failures have incorrect data
Serial.print("Distance (mm): ");
Serial.println(measure.RangeMilliMeter);
} else {
Serial.println(" out of range ");
}
delay(100);
}
// SVL53L0X Distance Test
http://www.electronoobs.com/eng_arduino_tut73.php
#include "Adafruit_VL53L0X.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 or 0x3f for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
lcd.init();
lcd.backlight();
Serial.begin(9600);
// wait until serial port opens for native USB devices
while (! Serial) {
delay(1);
}
Serial.println("Adafruit VL53L0X test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4) { // phase failures have incorrect data
Serial.print("Distance (mm): ");
Serial.println(measure.RangeMilliMeter);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" DISTANCE in mm ");
lcd.setCursor(0,1);
lcd.print(measure.RangeMilliMeter);
} else {
Serial.println(" out of range ");
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" DISTANCE in mm ");
lcd.setCursor(0,1);
lcd.print(" OUT OF RANGE ");
}
delay(100);
}