VL53L9CX Time-of-Flight on the OpenMV N6: preview firmware

Hi all,

We’ve got the ST VL53L9CX time-of-flight sensor running on the OpenMV N6 with the PAG7936 + VL53L9CX dual sensor module, and we want to get it into your hands now. The driver is in review here: drivers/sensors: Add VL53L9CX ToF. by kwagyeman · Pull Request #3307 · openmv/openmv · GitHub. Until it’s merged, you can try it with the preview firmware below.

What it does

The VL53L9CX measures distance across a 54x42 grid of zones (2,268 depth points) per frame. On the N6 we’re getting about 29 FPS at full resolution. It streams over I3C, so it shares the bus with the color sensor without needing an interrupt pin.

  • Depth maps as GRAYSCALE or RGB565, with a depth color palette over a range you choose (0-4000 mm by default).
  • Raw planes for every zone: distance in mm, signal amplitude, and ambient light, read straight into a ulab array.
  • Amplitude is an IR image of the scene lit by the sensor, so it works in total darkness.
  • Binning: 54x42, 24x20, 18x14, 12x10, 8x6 or 4x4.
  • Precision mode for the best accuracy, or range mode to see farther.
  • hmirror, vflip, windowing and transpose, for both images and plane reads.
  • Triggered mode, so each loop captures exactly one paired frame from the color and depth sensors.

Color (PAG7936) on the left, VL53L9CX depth on the right, both live on the N6.

vl53l9cx_amplitude_depth

Left: amplitude (the IR image). Right: depth. About 30 FPS reading all three planes.

Depth blended over the color image.

Getting started

import csi, image

tof = csi.CSI(cid=csi.VL53L9CX, stream=True)
tof.reset()
tof.pixformat(csi.RGB565)
tof.framesize((54, 42))
tof.color_palette(image.PALETTE_DEPTH)
tof.ioctl(csi.IOCTL_VL53L9CX_SET_RANGE, 0, 4000)  # mm

while True:
    img = tof.snapshot()

To get the actual numbers per zone:

from ulab import numpy as np

planes = np.zeros((tof.height(), tof.width(), 3), dtype=np.uint16)
tof.ioctl(csi.IOCTL_VL53L9CX_READ_PLANES, planes)
depth_mm  = planes[:, :, 0]  # 0 = no valid return
amplitude = planes[:, :, 1]
ambient   = planes[:, :, 2]

Download

openmv_n6_vl53l9cx_pr3307.zip (1.3 MB)

The zip contains firmware.bin and six example scripts:

Example What it shows
vl53l9cx_depth.py Live depth map in the IDE
vl53l9cx_amplitude.py IR amplitude image, filtering out noisy zones
vl53l9cx_read_planes.py Per-zone distance/amplitude/ambient as numpy arrays
vl53l9cx_with_color_sensor_overlay.py Depth blended over the color image
vl53l9cx_with_color_sensor_side_by_side.py Color and depth on one canvas
vl53l9cx_with_color_sensor_triggered.py Frame-paired color + depth captures

To install: in OpenMV IDE, go to Tools → Run Bootloader (Load Firmware) and select firmware.bin. To go back, load the latest release firmware the same way.

This is a preview build. If you hit a problem, post it here with your script and we’ll take a look. We’d love to see what you build with it!