nanoFramework.Iot.Device.Vl53L0X 1.2.864

Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Vl53L0X --version 1.2.864
                    
NuGet\Install-Package nanoFramework.Iot.Device.Vl53L0X -Version 1.2.864
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.Vl53L0X" Version="1.2.864" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Vl53L0X" Version="1.2.864" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Vl53L0X" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.Vl53L0X --version 1.2.864
                    
#r "nuget: nanoFramework.Iot.Device.Vl53L0X, 1.2.864"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.Vl53L0X@1.2.864
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.Vl53L0X&version=1.2.864
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Vl53L0X&version=1.2.864
                    
Install as a Cake Tool

VL53L0X - distance sensor

The VL53L0X sensor is a Time-to-Flight sensor measuring precisely distances. The sensor allows you to get precise short distance measurement (from 5 millimeters to 2 meters) as well as long distance measurement (up to 8 meters but with a decreased precision). This sensor is a laser ranging sensor. It is using laser pulses to measure the distances.

Documentation

VL53L0X datasheet

You will find this device as "Distance Sensor" or "Adafruit VL53L0X Time of Flight Distance Sensor - ~30 to 1000mm"

Board

VL53L0X

Usage

Important: make sure you properly setup the I2C pins especially for ESP32 before creating the I2cDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);

For other devices like STM32, please make sure you're using the preset pins for the I2C bus you want to use.

All calibration and all setup of the sensor is done fully transparently for you. Just create a class and read either once the distance, either using the continuous measurement method.

Vl53L0X vL53L0X = new Vl53L0X(I2cDevice.Create(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
Debug.WriteLine($"Rev: {vL53L0X.Information.Revision}, Prod: {vL53L0X.Information.ProductId}, Mod: {vL53L0X.Information.ModuleId}");
while (true)
{
    try
    {
        Debug.WriteLine($"Distance: {vL53L0X.Distance}");
    }
    catch (Exception ex)
    {
        Debug.WriteLine($"Exception: {ex.Message}");
    }
    Thread.Sleep(500);
}

Be aware that when reading a distance using the Continuous or Single measurement feature, you can get an exception, you should trap it.

You can as well get a single measurement, in this case, the precision can be lower. Use the property MeasurementMode to change the mode.

You can adjust the type of measurement you want. By default, the sensor is put into long range. This does allow to have a quite accurate (+-5%) precision within 2 meters but still can measure distances up to 8 meters (accuracy much less correct). You can switch to short range using the SetPrecision function. If you want to setup your own mode, you should use in conjunction the SetSignalRateLimit and the SetVcselPulsePeriod functions plus the HighResolution property like in the below example:

HighResolution = false;
SetSignalRateLimit(0.25);
SetVcselPulsePeriod(VcselType.VcselPeriodPreRange, PeriodPulse.Period14);
SetVcselPulsePeriod(VcselType.VcselPeriodFinalRange, PeriodPulse.Period10);

Please refer to the documentation to understand the impact of changing the various pulses as well as using the high resolution precision measurement. The sensor can't be precise in long range and in general, the longer it can see, the less precise are the data. High resolution will return a more precise measurement but mainly in short distance.

Changing the default I2C address

You can adjust the I2C address used for this sensor. Here is a code snippet explaining how to:

// Code snippet to change the address of a sensor
byte newAddress = 0x28; // You can change for any valid supported address
I2cDevice connectionToCurrentAddress = I2cDevice.Create(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress));
Vl53L0X.ChangeI2cAddress(connectionToCurrentAddress, newAddress);
I2cDevice connectionToChangedAddress = I2cDevice.Create(new I2cConnectionSettings(1, newAddress));
using Vl53L0X vlWithChangedAddress = new(connectionToChangedAddress);
// Do what you'd like to do here
// Soft reset the device to setup the default address again
vlWithChangedAddress.Reset();
// Now the address is reset to the default one
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.864 211 4/2/2025
1.2.852 229 3/11/2025
1.2.822 150 2/26/2025
1.2.775 149 2/4/2025
1.2.772 137 2/4/2025
1.2.755 150 1/31/2025
1.2.737 132 1/13/2025
1.2.704 150 12/18/2024
1.2.696 142 12/16/2024
1.2.673 172 10/23/2024
1.2.662 151 10/11/2024
1.2.631 177 8/28/2024
1.2.590 158 7/17/2024
1.2.570 165 6/14/2024
1.2.560 173 5/29/2024
1.2.548 171 5/15/2024
1.2.436 300 11/10/2023
1.2.416 166 11/8/2023
1.2.329 229 5/26/2023
1.2.313 224 5/12/2023
1.2.297 231 5/3/2023
1.2.212 416 1/5/2023
1.2.203 381 12/28/2022
1.2.159 442 11/14/2022
1.2.153 443 11/5/2022
1.2.141 459 10/25/2022
1.2.122 511 10/12/2022
1.2.114 441 10/8/2022
1.2.95 496 9/22/2022
1.2.87 565 9/15/2022
1.2.73 484 9/8/2022
1.1.116.8772 539 6/24/2022
1.1.113.2032 536 6/23/2022
1.1.97.17326 508 6/13/2022
1.1.92.53000 522 6/8/2022
1.1.58.10097 536 5/23/2022
1.1.7 539 4/18/2022
1.1.1 535 4/14/2022
1.0.300 576 4/3/2022
1.0.277-preview.125 201 3/25/2022
1.0.277-preview.116 185 3/22/2022
1.0.277-preview.99 200 3/10/2022
1.0.277-preview.32 208 1/27/2022
1.0.277-preview.15 203 1/21/2022
1.0.277-preview.1 209 1/11/2022
1.0.259 422 12/9/2021
1.0.218 278 10/18/2021
1.0.155 428 8/31/2021
1.0.144 449 7/21/2021
1.0.136 501 7/17/2021
1.0.135 245 7/16/2021
1.0.134 253 7/15/2021
1.0.133 292 7/14/2021
1.0.130 275 7/6/2021
1.0.125 275 7/5/2021
1.0.121 280 6/29/2021
1.0.119 313 6/28/2021
1.0.99 284 5/28/2021
1.0.53 298 5/25/2021