VL53L0X time-of-flight sensor
ST's VL53L0X laser distance sensor on its breakout board (GY-VL53L0XV2, Pololu, Adafruit).
It sends a pulse of infrared laser light and times how long the light takes to come back. Aliases: time of flight, ToF, laser ranger, lidar.
Pins
| Pin | What it does |
|---|---|
VIN |
Supply, 2.6 to 5.5 V; the board regulates it down for the chip. |
GND |
Ground. |
SCL, SDA |
The I2C bus, address 0x29. The board has the pull-ups. |
GPIO1 |
Interrupt output, open drain: low while a new range is ready. |
XSHUT |
Shutdown. The board pulls it up; hold it low and the chip is off. |
While it runs
The slider is how far away the target is, 0 to 2000 mm.
Reading it on an Arduino
With Pololu's VL53L0X library, which Mokxi ships as VL53L0X.h:
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
void setup() {
Serial.begin(9600);
Wire.begin();
sensor.setTimeout(500);
sensor.init();
sensor.startContinuous();
}
void loop() {
Serial.println(sensor.readRangeContinuousMillimeters()); // millimeters
}
Adafruit's library (Adafruit_VL53L0X.h, lox.rangingTest(&measure)) reads it
too.
What the model gets right
ST describes the VL53L0X through its software API rather than a register map, so the model answers the registers the libraries' ranging path uses:
Identity: the model ID 0xEE at 0xC0, which every library checks first.
Measurements take time. Each one takes the default 33 ms timing budget. Single
shot, back to back and timed modes run as written to SYSRANGE_START, and a range
is ready when the interrupt status says so; clearing the interrupt clears it.
Out of range: past about 1.2 m, the default mode's reach for a white target indoors, the chip reports 8190 and a phase-fail status.
A new address written to 0x8A holds until power goes or XSHUT is pulled low,
which is how several sensors share one bus.
What it does not model
The few millimeters of noise a real reading has, and how the target's color and the room's light change the reach. The reference SPAD and temperature calibration ST's full start-up runs, and the long range and high accuracy modes.
Common mistakes
Two sensors on one bus without changing an address: both answer 0x29. Hold one in
shutdown with XSHUT, give the other a new address, then let the first one up.
Reading a range before it is ready: wait for the interrupt status, or use the library's calls, which do.
See it in action
Laser ruler prints the distance to the target. Open it at /templates.