VL53L0X Time-of-Flight sensor and ESP8266

The VL53L0X is a new generation Time-of-Flight (ToF) laser-ranging module housed in the smallest package on the market today, providing accurate distance measurement whatever the target reflectances unlike conventional technologies. It can measure absolute distances up to 2m, setting a new benchmark in ranging performance levels, opening the door to various new applications.

The VL53L0X integrates a leading-edge SPAD array (Single Photon Avalanche Diodes) and embeds ST’s second generation FlightSenseTM patented technology.

The VL53L0X’s 940 nm VCSEL emitter (Vertical Cavity Surface-Emitting Laser), is totally invisible to the human eye, coupled with internal physical infrared filters, it enables longer ranging distances, higher immunity to ambient light, and better robustness to cover glass optical crosstalk.

  • Fully integrated miniature module
    • 940 nm laser VCSEL
    • VCSEL driver
    • Ranging sensor with advanced embedded micro controller
    • 4.4 x 2.4 x 1.0 mm
  • Fast, accurate distance ranging
    • Measures absolute range up to 2 m
    • Reported range is independent of the target reflectance
    • Advanced embedded optical cross-talk compensation to simplify cover glass selection
  • Eye safe
    • Class 1 laser device compliant with latest standard IEC 60825-1:2014 – 3rd edition
  • Easy integration
    • Single reflowable component
    • No additional optics
    • Single power supply
    • I2C interface for device control and data transfer
    • Xshutdown (reset) and interrupt GPIO
    • Programmable I2C address

Parts List

Here are the parts I used

 

Name Links
Wemos Mini
VL53L0X
Connecting cables

Schematics/Layout

esp8266 and VL53L0X
esp8266 and VL53L0X

 

Code

Again we use a library and again its an adafruit one – https://github.com/adafruit/Adafruit_VL53L0X

The default example worked fine, so here it is

 

#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

void setup()
{
Serial.begin(115200);

// 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);
}

 

Output

Open the serial monitor – this is what I saw. I moved an object closer to the sensor hence the readings decreasing

Reading a measurement… Distance (mm): 166
Reading a measurement… Distance (mm): 165
Reading a measurement… Distance (mm): 167
Reading a measurement… Distance (mm): 150
Reading a measurement… Distance (mm): 159
Reading a measurement… Distance (mm): 139
Reading a measurement… Distance (mm): 113
Reading a measurement… Distance (mm): 96
Reading a measurement… Distance (mm): 87
Reading a measurement… Distance (mm): 83
Reading a measurement… Distance (mm): 75
Reading a measurement… Distance (mm): 54

 

Links

https://www.st.com/resource/en/datasheet/vl53l0x.pdf

https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html