VL53L0X Laser Distance Sensor
The VL53L0X is a next-generation ToF (Time-of-Flight) laser distance sensor developed by STMicroelectronics. It utilizes the second-generation FlightSense™ technology, which operates based on the Time-of-Flight principle. By calculating the time it takes for photons to travel back and forth, the sensor can measure distances accurately. Compared to the previous generation VL6180X, the VL53L0X extends the measurement range to 2 meters, offering faster measurement speeds and higher energy efficiency. In addition, to facilitate integration, ST provides the VL53L0X software API and comprehensive technical documentation. Through the main I2C interface, the sensor outputs distance data to the application side, significantly reducing the development effort for users.
Module Source
Purchase Link:
https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-19589090137.10.690136b4Dw8DLW&id=611048504034
Baidu Netdisk Download Link:
https://pan.baidu.com/s/15Ld90aG1VC0y_xp120UbZg
Password:qydr
Specifications
Operating Voltage: 2.6 ~ 3.5 V
Measurement Range: 2 meters
Communication Protocol: I2C
I2C Address: 0x52
Pin Count: 6 Pins (2.54mm pitch header)
Hardware Connection
The VL53L0X module typically has four main connection ports: VCC, GND, SDA, and SCL.
- Connect VCC to the 3.3V of the development board.
- Connect GND to the GND of the development board.
- Connect SDA (Data Line) to the A4 or SDA port on the development board (SDA is pin A4).
- Connect SCL (Clock Line) to the A5 or SCL port on the development board (SCL is pin A5).
Usage Method
Install Library
In the Arduino IDE, go to Tools > Manage Libraries..., search for and install the Adafruit VL53L0X
library.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 9, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
Serial.begin(9600);
// 等待串口连接
while (!Serial) {
delay(1);
}
Serial.println("Adafruit VL53L0X test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while (1);
}
// 如果传感器成功初始化,代码会进行到这里
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // 'true'将输出调试数据到Serial
if (measure.RangeStatus != 4) { // 0代表测量成功
Serial.print("Distance (mm): ");
Serial.println(measure.RangeMilliMeter);
} else {
Serial.println("Out of range");
}
delay(100);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Usage Testing
Place an object 20 cm away from the distance sensor, then read the sensor data and output it through the serial monitor.