Using the VL53L4CX with Arduino involves wiring up the sensor to your Arduino-compatible microcontroller, installing the STM32duino VL53L4CX library and running the provided example code.
Wiring
Wire as shown for a 5V board. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the VL53L4CX VIN.
Here is an Adafruit Metro Express wired up to the VL53L4CX using the STEMMA QT connector:
-
Board 5V to sensor VIN (red wire)
-
Board GND to sensor GND (black wire)
-
Board SCL to sensor SCL (yellow wire)
- Board SDA to sensor SDA (blue wire)
Here is an Adafruit Metro Express wired up using a solderless breadboard:
-
Board 5V to sensor VIN (red wire)
-
Board GND to sensor GND (black wire)
-
Board SCL to sensor SCL (yellow wire)
- Board SDA to sensor SDA (blue wire)
Library Installation
You can install the VL53L4CX library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for VL53L4CX, and select the STM32duino VL53L4CX library:
Load Example
Open up File -> Examples -> STM32duino VL53L4CX -> VL53L4CX_Sat_HelloWorld and upload to your Arduino wired to the sensor.
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You should see the values from the sensor being printed out. The values read in the example are:
Count
- number of readings sent to the Serial MonitorObjs
- Number of objects in front of the sensorstatus
- Range status of the sensorD
- Measurement of distance of an object from the sensor in millimetersSignal
- Rate of the signal from the sensorAmbient
- Ambient noise around the sensor
Text editor powered by tinymce.