Overview
This product uses I2C interface to achieve distance measurement, with a measurement distance of up to 2 meters; Supports Raspberry Pi models, as well as Arduino and STM32; We provide C and Python versions of Raspberry Pi demo codes, as well as Arduino and STM32 versions of demo codes. The demo codes can achieve three ranging working modes: single ranging, continuous ranging, and timed ranging, as well as four ranging configuration modes: default mode, high speed, high accuracy, and long range.
Parameters
Supply voltage | 3.3V/5V |
Ranging distance | 30~2000mm |
Ranging accuracy | ±5%( high speed mode),±3%(high accuracy mode) |
Ranging time (min) | 20ms(short distance mode),200ms (medium/long distance mode) |
Field of view | 25° |
Laser wavelength | 940nm |
Control Chip | VL53L0X |
Signal interface | I2C |
Size | 25mm(Length) x 18mm(width) |
Weight | 2g |
Resource Profile
① PH2.0 terminal leads out control pin
② Lead out GPIO1 and XSHUT pins
③ VL53L0X ranging chipr
Usage
Raspberry Pi demo codes usage
Hardware interface configuration description
The module with Raspberry Pi motherboard wiring is defined in the following table:
PIN | Describe | Raspberry Pi |
---|---|---|
VCC | Power supply positive(3.3V/5V) | 3.3V |
GND | Power supply ground | GND |
SDA | I2C data line | SDA1 |
SCL | I2C clock line | SCL1 |
SHT | shutdown control, can connects to IO pin | NC |
GP1 | Interrupt output, can connects to IO pin | NC |
Wiringpi library installation
sudo apt-get install wiringpi
wget https://project-downloads.drogon.net/wiringpi-latest.deb
#Version 4B upgrade of Raspberry Pi
sudo dpkg -i wiringpi-latest.deb
gpio -v
If version 2.52 appears, the installation is successful
For the Bullseye branch system, use the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v
Running "gpio - v" will result in version 2.70. If it does not appear, it indicates an installation error
If the error prompt "ImportError: No module named 'wiringpi'" appears when running the python version of the demo codes , run the following command
For Python 2. x version
pip install wiringpi
For Python 3. x version
pip3 install wiringpi
Note: If the installation fails, you can try the following compilation and installation:
git clone --recursive https://github.com/WiringPi/WiringPi-Python.git
Note: The -- recursive option can automatically pull the submodule, otherwise you need to download it manually.
Enter the WiringPi Python folder you just downloaded, enter the following command, compile and install:
For Python 2. x version
sudo python setup.py install
For Python 3. x version
sudo python3 setup.py install
If the following error occurs:
At this time, enter the command sudo apt install swig to install swig. After that, compile and install sudo python3 setup.py install. If a message similar to the following appears, the installation is successful.
Turn on the I2C interface
sudo raspi-config
Enable I2C interface:
Interfacing Options -> I2C -> Yes
Restart the device.
sudo reboot
Run the command to check whether I2C and SPI are started.
lsmod
If i2c_bcm2835 and spi_bcm2835 are displayed, it means I2C, the SPI module is started.
Install the i2c-tools tool to confirm
sudo apt-get install i2c-tools
View connected I2C devices
i2cdetecty -y 1
Check the address and indicate that the module has successfully connected to Raspberry Pi, and the displayed address is 0X29;
Turn on the I2C interface
The demo codes uses the python 3 environment. To run the python demo codes , you need to install smbus:
sudo apt-get install -y python-smbus
2.1.5 Demo Codes
After downloading the demo codes, enter the Raspberry Pi/c directory and compile the code
sudo make clean
sudo make
sudo make example
The compiled code results are as follows.
After waiting for the program to compile, enter the bin directory
Run demo codes
sudo ./VL53L0X_single_example
Connect the module according to the demo codes description. After running the demo codes , the Raspberry Pi terminal outputs device information and measured distance (using a single ranging as an example)(Unit:mm).
Python Demo Codes
Enter the Raspberry Pi/Python directory
sudo make
Wait for the program compilation to complete, enter the example directory, and run the demo codes:
sudo python VL53L0X_singleexample.py
The routine phenomenon in the Python version is similar to that in the C language version, and the running results are shown in the following figure(Unit:mm):
Arduino Demo Codes Usage
Wiring instructions
PIN | Describe | Arduino |
---|---|---|
VCC | Power supply positive(3.3V/5V) | 5V |
GND | Power supply ground | GND |
SDA | I2C data line | SDA |
SCL | I2C clock line | SCL |
SHT | shutdown control, can connects to IO pin | NC |
GP1 | Interrupt output, can connects to IO pin | NC |
Demo codes usage
Open the project file demo_codes\Arduino\VL53L0X_single_example\VL53L0X_single_example.ino with the Arduino IDE, import API.zip from the Arduino directory into Arduino, as shown in the following figure.
Click Verify, and upload it to the development board after verification.
Click the tool, open the serial port monitor, set the baud rate to 115200, and observe the data changes.
Open the serial port monitor and the display is as follows. Set the baud rate to 115200 (as shown in "1" in the figure below). The program running results are shown in the figure below(Unit:mm):
STM32 Demo Codes Usage
Wiring instructions
PIN | Describe | Arduino |
---|---|---|
VCC | Power supply positive(3.3V/5V) | 3.3V |
GND | Power supply ground | GND |
SDA | I2C data line | PB11 |
SCL | I2C clock line | PB10 |
SHT | shutdown control, can connects to IO pin | NC |
GP1 | Interrupt output, can connects to IO pin | NC |
Demo codes usage
Use Keil uVision5 software to open the VL53L0X.uvprojx project file in the directory demo_codes\STM32\USER, and connect the module with STM32 according to the above table; download the program to the STM32 development board after compiling without errors;The debugging information output serial port in the demo codes is USART1, where PA9 is Tx and PA10 is Rx; After connecting the cable, open the Serial Port Debugging Assistant, select the serial port number, adjust the baud rate to 115200, click "Open", and the Serial Port Debugging Assistant window is shown as follows(Unit:mm):Resources
Data Sheet