nanoFramework.Iot.Device.Vl53L0X 1.2.662

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Vl53L0X --version 1.2.662                
NuGet\Install-Package nanoFramework.Iot.Device.Vl53L0X -Version 1.2.662                
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.662" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.Iot.Device.Vl53L0X --version 1.2.662                
#r "nuget: nanoFramework.Iot.Device.Vl53L0X, 1.2.662"                
#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.
// Install nanoFramework.Iot.Device.Vl53L0X as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Vl53L0X&version=1.2.662

// Install nanoFramework.Iot.Device.Vl53L0X as a Cake Tool
#tool nuget:?package=nanoFramework.Iot.Device.Vl53L0X&version=1.2.662                

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.704 85 12/18/2024
1.2.696 76 12/16/2024
1.2.673 117 10/23/2024
1.2.662 103 10/11/2024
1.2.631 134 8/28/2024
1.2.590 115 7/17/2024
1.2.570 120 6/14/2024
1.2.560 130 5/29/2024
1.2.548 128 5/15/2024
1.2.436 276 11/10/2023
1.2.416 144 11/8/2023
1.2.329 179 5/26/2023
1.2.313 170 5/12/2023
1.2.297 176 5/3/2023
1.2.212 359 1/5/2023
1.2.203 325 12/28/2022
1.2.159 387 11/14/2022
1.2.153 385 11/5/2022
1.2.141 401 10/25/2022
1.2.122 452 10/12/2022
1.2.114 383 10/8/2022
1.2.95 439 9/22/2022
1.2.87 507 9/15/2022
1.2.73 423 9/8/2022
1.1.116.8772 474 6/24/2022
1.1.113.2032 468 6/23/2022
1.1.97.17326 442 6/13/2022
1.1.92.53000 455 6/8/2022
1.1.58.10097 465 5/23/2022
1.1.7 470 4/18/2022
1.1.1 467 4/14/2022
1.0.300 506 4/3/2022
1.0.277-preview.125 130 3/25/2022
1.0.277-preview.116 114 3/22/2022
1.0.277-preview.99 131 3/10/2022
1.0.277-preview.32 134 1/27/2022
1.0.277-preview.15 132 1/21/2022
1.0.277-preview.1 136 1/11/2022
1.0.259 349 12/9/2021
1.0.218 204 10/18/2021
1.0.155 355 8/31/2021
1.0.144 376 7/21/2021
1.0.136 425 7/17/2021
1.0.135 171 7/16/2021
1.0.134 181 7/15/2021
1.0.133 218 7/14/2021
1.0.130 201 7/6/2021
1.0.125 200 7/5/2021
1.0.121 207 6/29/2021
1.0.119 239 6/28/2021
1.0.99 210 5/28/2021
1.0.53 223 5/25/2021