nanoFramework.Iot.Device.Vl53L0X 1.2.436

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Vl53L0X --version 1.2.436
NuGet\Install-Package nanoFramework.Iot.Device.Vl53L0X -Version 1.2.436
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.436" />
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.436
#r "nuget: nanoFramework.Iot.Device.Vl53L0X, 1.2.436"
#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.436

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

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.436 232 11/10/2023
1.2.416 113 11/8/2023
1.2.329 151 5/26/2023
1.2.313 141 5/12/2023
1.2.297 148 5/3/2023
1.2.212 329 1/5/2023
1.2.203 292 12/28/2022
1.2.159 359 11/14/2022
1.2.153 355 11/5/2022
1.2.141 371 10/25/2022
1.2.122 422 10/12/2022
1.2.114 355 10/8/2022
1.2.95 406 9/22/2022
1.2.87 470 9/15/2022
1.2.73 390 9/8/2022
1.1.116.8772 442 6/24/2022
1.1.113.2032 432 6/23/2022
1.1.97.17326 408 6/13/2022
1.1.92.53000 422 6/8/2022
1.1.58.10097 424 5/23/2022
1.1.7 435 4/18/2022
1.1.1 437 4/14/2022
1.0.300 472 4/3/2022
1.0.277-preview.125 115 3/25/2022
1.0.277-preview.116 100 3/22/2022
1.0.277-preview.99 115 3/10/2022
1.0.277-preview.32 122 1/27/2022
1.0.277-preview.15 119 1/21/2022
1.0.277-preview.1 121 1/11/2022
1.0.259 320 12/9/2021
1.0.218 181 10/18/2021
1.0.155 315 8/31/2021
1.0.144 357 7/21/2021
1.0.136 393 7/17/2021
1.0.135 150 7/16/2021
1.0.134 161 7/15/2021
1.0.133 196 7/14/2021
1.0.130 182 7/6/2021
1.0.125 180 7/5/2021
1.0.121 185 6/29/2021
1.0.119 217 6/28/2021
1.0.99 186 5/28/2021
1.0.53 200 5/25/2021