A complete implementation of the VL53L7CX multizone Time-of-Flight sensor driver for the Raspberry Pi Pico 2, using the official STMicroelectronics driver adapted for the Pico SDK.
- 8x8 Multizone Distance Sensing - 64 individual distance measurement zones
- Official ST Driver - Uses the professional STMicroelectronics VL53L7CX Ultra Lite Driver
- Pico 2 Compatible - Custom platform layer for Pico SDK integration
- Real-time Data Output - USB serial output with formatted distance data
- Complete Build System - CMake configuration for easy building
pico2/
├── vl53l7cx_project/ # Main VL53L7CX project
│ ├── main_st_driver.c # Working ST driver example
│ ├── platform_pico.h/c # Pico 2 platform layer
│ ├── inc/ # VL53L7CX API headers
│ ├── src/ # VL53L7CX API source files
│ ├── CMakeLists.txt # Build configuration
│ └── STSW-IMG036/ # Original ST driver files
├── main.c # Simple blink example
├── CMakeLists.txt # Root build configuration
└── README.md # This file
- Raspberry Pi Pico 2 (RP2350)
- VL53L7CX Sensor Module (Pololu or similar)
- I2C Connections:
- SDA: GPIO 4
- SCL: GPIO 5
- VCC: 3.3V
- GND: Ground
- Pull-up Resistors: 4.7kΩ on SDA and SCL lines
- Raspberry Pi Pico SDK installed
- ARM GCC toolchain
- CMake 3.13+
cd vl53l7cx_project
./build.sh
Or manually:
cd vl53l7cx_project
rm -rf build
mkdir build && cd build
cmake .. -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350-arm-s
make -j8
- Put Pico 2 in BOOTSEL mode
- Drag and drop
st_driver_example.uf2
to the mounted drive
Connect to serial monitor:
screen /dev/cu.usbmodem23101 115200
VL53L7CX ST Driver Example for Pico 2
=====================================
I2C initialized on pins SDA=4, SCL=5
Checking if VL53L7CX sensor is alive...
VL53L7CX sensor detected!
Initializing VL53L7CX sensor...
VL53L7CX ULD ready ! (Version : VL53L7CX_2.0.0)
Setting sensor to 8x8 mode...
Sensor set to 8x8 mode successfully
Starting ranging...
Ranging started successfully!
Reading distance data from all zones (8x8 grid)...
Press Ctrl+C to stop
Measurement #1:
=== VL53L7CX Zone Distance Data (8x8 grid) ===
Zone distances in mm:
Row 0: 245 230 215 200 185 170 155 140
Row 1: 265 250 235 220 205 190 175 160
Row 2: 285 270 255 240 225 210 195 180
...
The project includes a custom platform layer (platform_pico.h/c
) that adapts the ST driver from STM32 HAL to Pico SDK:
- I2C Communication: Uses Pico SDK
hardware_i2c
functions - Timing: Uses Pico SDK
sleep_ms
for delays - Memory Management: Standard C library functions
main_st_driver.c
- Complete working example using ST driverplatform_pico.h/c
- Pico 2 platform abstraction layerinc/vl53l7cx_api.h
- ST VL53L7CX API (modified for Pico)src/vl53l7cx_api.c
- ST VL53L7CX implementation
- Address: 0x29 (configured for your sensor)
- Speed: 400 kHz
- Pins: SDA=4, SCL=5
- Check I2C connections (SDA=4, SCL=5)
- Verify 3.3V power supply
- Ensure pull-up resistors are present
- Check I2C address (should be 0x29)
- Ensure Pico SDK is properly installed
- Check CMake version (3.13+)
- Verify ARM GCC toolchain is available
- Wait 2 seconds after programming for USB initialization
- Check USB cable connection
- Verify correct serial port (
/dev/cu.usbmodem23101
)
The project includes several example programs:
main_st_driver.c
- Full ST driver example (recommended)vl53l7cx_driver.c
- Custom driver implementationtest_serial.c
- Serial communication testsimple_blink.c
- Basic LED blink test
This project includes the official STMicroelectronics VL53L7CX driver, which is licensed under ST's terms. See LICENSE.txt
files for details.
If you see the 8x8 distance grid output, congratulations! You have successfully implemented a professional-grade multizone ToF sensor system with your Pico 2.