# sparkfun/sparkfun_vl53l5cx_arduino_library architecture

> Architecture diagram of the GitHub repository sparkfun/sparkfun_vl53l5cx_arduino_library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sparkfun/sparkfun_vl53l5cx_arduino_library
- Repository: https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library

## Overview

This is an Arduino library for SparkFun’s VL53L5CX multizone time-of-flight sensor. Sketches configure the sensor and start ranging through the SparkFun API; the ST driver and platform layer communicate over I²C, and readings are exposed to the sketch. The repository also provides threshold, motion-indicator, and crosstalk features plus a Processing 3D depth-map application. The README documents up-to-8×8 ranging; that visualization’s connection to the library is not established by the sampled source.

Main entry points: [`src/vl53l5cx_api.cpp`](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_api.cpp) (ST ranging API), [`src/SparkFun_VL53L5CX_Library.cpp`](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_Library.cpp) (SparkFun API), [`src/SparkFun_VL53L5CX_IO.cpp`](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_IO.cpp) (I²C transport), [`src/platform.cpp`](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/platform.cpp) (Platform adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Arduino client"]
  node_sketch["Arduino sketch"]
end

subgraph group_facade["Library interface"]
  node_sparkfun["SparkFun API"]
  node_constants["API settings"]
end

subgraph group_driver["Sensor driver"]
  node_i2c["I²C transport"]
  node_platform["Platform adapter<br/>[platform.cpp]"]
  node_stapi["ST ranging API<br/>[vl53l5cx_api.cpp]"]
  node_buffers["Firmware buffers<br/>[vl53l5cx_buffers.h]"]
end

subgraph group_features["Ranging features"]
  node_thresholds["Detection thresholds"]
  node_motion["Motion indicator"]
  node_xtalk["Crosstalk calibration"]
end

subgraph group_visualization["Depth visualization"]
  node_depthmap["3D depth map"]
end

node_sensor[("VL53L5CX sensor")]

node_sketch -.->|"configures and ranges"| node_sparkfun
node_sparkfun -->|"calls ranging API"| node_stapi
node_sparkfun -->|"uses transport"| node_i2c
node_platform -->|"adapts I²C"| node_i2c
node_stapi -.->|"reads and writes"| node_platform
node_stapi -->|"uses buffers"| node_buffers
node_i2c -->|"transfers registers"| node_sensor
node_thresholds -.->|"uses driver API"| node_stapi
node_motion -.->|"uses driver API"| node_stapi
node_xtalk -->|"uses driver API"| node_stapi
node_depthmap -.->|"visualizes ranging"| node_sensor

click node_sketch "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/examples/Example1_DistanceArray/Example1_DistanceArray.ino"
click node_sparkfun "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_Library.cpp"
click node_constants "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_Library_Constants.h"
click node_i2c "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_IO.cpp"
click node_platform "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/platform.cpp"
click node_stapi "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_api.cpp"
click node_buffers "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_buffers.h"
click node_thresholds "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_plugin_detection_thresholds.cpp"
click node_motion "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_plugin_motion_indicator.cpp"
click node_xtalk "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_plugin_xtalk.cpp"
click node_depthmap "https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/processingApp/SparkFun_VL53L5CX_3D_Depth_Map/SparkFun_VL53L5CX_3D_Depth_Map.pde"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sketch toneBlue
class node_sparkfun,node_constants,node_sensor toneAmber
class node_i2c,node_platform,node_stapi,node_buffers toneMint
class node_thresholds,node_motion,node_xtalk toneRose
class node_depthmap toneIndigo
```

## Components

### Arduino client

- [Arduino sketch](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/examples/Example1_DistanceArray/Example1_DistanceArray.ino): `examples/Example1_DistanceArray/Example1_DistanceArray.ino`

### Library interface

- [SparkFun API](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_Library.cpp): `src/SparkFun_VL53L5CX_Library.cpp`
- [API settings](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_Library_Constants.h): `src/SparkFun_VL53L5CX_Library_Constants.h`

### Sensor driver

- [I²C transport](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/SparkFun_VL53L5CX_IO.cpp): `src/SparkFun_VL53L5CX_IO.cpp`
- [Platform adapter](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/platform.cpp): `src/platform.cpp`
- [ST ranging API](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_api.cpp): `src/vl53l5cx_api.cpp`
- [Firmware buffers](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_buffers.h): `src/vl53l5cx_buffers.h`

### Ranging features

- [Detection thresholds](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_plugin_detection_thresholds.cpp): `src/vl53l5cx_plugin_detection_thresholds.cpp`
- [Motion indicator](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_plugin_motion_indicator.cpp): `src/vl53l5cx_plugin_motion_indicator.cpp`
- [Crosstalk calibration](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/src/vl53l5cx_plugin_xtalk.cpp): `src/vl53l5cx_plugin_xtalk.cpp`

### Depth visualization

- [3D depth map](https://github.com/sparkfun/sparkfun_vl53l5cx_arduino_library/blob/main/processingApp/SparkFun_VL53L5CX_3D_Depth_Map/SparkFun_VL53L5CX_3D_Depth_Map.pde): `processingApp/SparkFun_VL53L5CX_3D_Depth_Map/SparkFun_VL53L5CX_3D_Depth_Map.pde`

### Other components

- **VL53L5CX sensor**

## Connections

- Arduino sketch → SparkFun API: configures and ranges
- SparkFun API → ST ranging API: calls ranging API (evidence: `src/SparkFun_VL53L5CX_Library.cpp`)
- SparkFun API → I²C transport: uses transport (evidence: `src/SparkFun_VL53L5CX_Library.cpp`)
- Platform adapter → I²C transport: adapts I²C (evidence: `src/platform.cpp`)
- ST ranging API → Platform adapter: reads and writes
- ST ranging API → Firmware buffers: uses buffers (evidence: `src/vl53l5cx_api.cpp`)
- I²C transport → VL53L5CX sensor: transfers registers (evidence: `src/SparkFun_VL53L5CX_IO.cpp`)
- Detection thresholds → ST ranging API: uses driver API
- Motion indicator → ST ranging API: uses driver API
- Crosstalk calibration → ST ranging API: uses driver API (evidence: `src/vl53l5cx_plugin_xtalk.cpp`)
- 3D depth map → VL53L5CX sensor: visualizes ranging
