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.

Please note, the Arduino driver for this chip does not support 'small memory' boards like the ATmega328 - you'll need a SAMD21, SAMD51, ESP, etc chip with 50K of flash memory available!

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.

Note: this is only the loop in the screenshot.

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 Monitor
  • Objs - Number of objects in front of the sensor
  • status - Range status of the sensor
  • D - Measurement of distance of an object from the sensor in millimeters
  • Signal - Rate of the signal from the sensor
  • Ambient - Ambient noise around the sensor

This guide was first published on May 04, 2022. It was last updated on May 04, 2022.

This page (Arduino) was last updated on May 28, 2022.

Text editor powered by tinymce.