nanoFramework.Iot.Device.LidarLiteV3
1.0.277-preview.77
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.LidarLiteV3 --version 1.0.277-preview.77
NuGet\Install-Package nanoFramework.Iot.Device.LidarLiteV3 -Version 1.0.277-preview.77
<PackageReference Include="nanoFramework.Iot.Device.LidarLiteV3" Version="1.0.277-preview.77" />
paket add nanoFramework.Iot.Device.LidarLiteV3 --version 1.0.277-preview.77
#r "nuget: nanoFramework.Iot.Device.LidarLiteV3, 1.0.277-preview.77"
// Install nanoFramework.Iot.Device.LidarLiteV3 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.LidarLiteV3&version=1.0.277-preview.77&prerelease // Install nanoFramework.Iot.Device.LidarLiteV3 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.LidarLiteV3&version=1.0.277-preview.77&prerelease
LidarLiteV3 - LIDAR Time of Flight Sensor
This device belongs to a class of sensors known as time-of-flight, which measures distances by calculating the time delay between signal transmission and reception of the signal as it bounces off the subject. Unlike the popular sonar-based HC-SR04, this device uses a low-power laser. The advantage is longer distances (up to 40m) but more prone to errors when the subject is reflective.
Documentation
Official Manual and Technical Spec
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.
Simple usage:
using (var llv3 = new LidarLiteV3(CreateI2cDevice()))
{
// Take 10 measurements, each one second apart.
for (int i = 0; i < 10; i++)
{
Length currentDistance = llv3.MeasureDistance();
Debug.WriteLine($"Current Distance: {currentDistance.Centimeters} cm");
Thread.Sleep(1000);
}
}
I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, LidarLiteV3.DefaultI2cAddress);
return I2cDevice.Create(settings);
}
Power Modes
Power can be controlled to the device via a GPIO pin. Use the optional constructor parameters to specify the GPIO controller and a power enable pin number (numbering scheme depends on GpioController).
int powerEnablePin = 13;
using (var llv3 = new LidarLiteV3(CreateI2cDevice(), new GpioController(), powerEnablePin))
{
// Power off the device.
llv3.PowerOff();
// Device is completely turned off.
Debug.WriteLine("Device is off.");
Thread.Sleep(5000);
// Power on the device, device is ready in ~22ms.
Debug.WriteLine("Device is on.");
llv3.PowerOn();
// Sleep 50ms.
Thread.Sleep(50);
// Get a reading.
Length currentDistance = llv3.MeasureDistance();
Debug.WriteLine($"Current Distance: {currentDistance.Centimeters} cm");
}
It's also possible to disable the receiver circuit (saving 40 mA) or put the device to sleep (saving 20 mA). However, it's recommended to use the power enable pin instead since the initialization time is only 2 ms shorter.
using (var llv3 = new LidarLiteV3(CreateI2cDevice()))
{
llv3.PowerMode = PowerMode.Sleep;
}
Repetition Mode
Instead of getting measurements on-demand, the device can be configure to repeat n number of times, or infinitely.
This is configured via SetMeasurementRepetitionMode
passing in a mode (Off
, Repeat
, or
RepeatInfinitely
), a loop count (if mode is Repeat
), and a delay between measurements (default to
10 hz). A delay of 20
is about 100 hz
.
With a repetition mode set, use Distance
to retrieve the current readings in Length
.
Use DifferenceBetweenLastTwoDistances
to get a velocity reading. Negative values
indicate that the object is moving toward the device, positive indicates it's moving away. The value
is dependent on the delay, and the default 10 hz is about 0.1 m/s.
using (var llv3 = new LidarLiteV3(CreateI2cDevice()))
{
llv3.SetMeasurementRepetitionMode(MeasurementRepetitionMode.RepeatIndefinitely);
while(true)
{
Thread.Sleep(5);
Length currentDistance = llv3.Distance;
Length currentVelocity = llv3.DifferenceBetweenLastTwoDistances;
}
}
Change the I2C Address
By default, the device has an address of 0x62
. It's possible to change this address to
resolve a conflict with another device or to run multiple devices.
Available addresses are 7-bit values with a 0 in the LSB order.
using (var llv3 = new LidarLiteV3(CreateI2cDevice()))
{
// Set device from default `0x62` to `0x68`
llv3.SetI2cAddressAndDispose(0x68);
}
// Connect to the device again with the new address.
var settings = new I2cConnectionSettings(1, 0x68);
var i2cDevice = I2cDevice.Create(settings);
using (var llv3 = new LidarLiteV3(i2cDevice))
{
// ...
}
Optimization
The default settings should work well, but several tweaks can be made to adjust the device. See the manual for more details.
Change Acquistion Count
To isolate the signal from the noise, the device performs a series of acquisitions and sums up the
result until a peak is found. The number of acquistions can be configured via
MaximumAcquisitionCount
(default: 128).
Less acquisitions result in faster measurements, but limits the max range and produces more erroneous readings. The number roughly correlates to an acquistion rate of n/count and n^(1/4).
using (var llv3 = new LidarLiteV3(CreateI2cDevice()))
{
llv3.MaximumAcquisitionCount = 100
}
Quick Termination Mode
Faster acquisition readings, but with slightly more chance of erroneous readings.
using (var llv3 = new LidarLiteV3(CreateI2cDevice()))
{
llv3.AcquistionMode |= AcquistionMode.EnableQuickTermination;
}
Detection Sensitivity
The threshold when a peak is found can be configured via AlgorithmByPassThreshold
. By default,
this is 0 which uses an internal algorithm to determine the threshold.
Recommended non-default values are 32 for higher sensitivity but higher erronenous readings and 96 for reduced sensitivity with fewer erroneous readings.
using (var llv3 = new LidarLiteV3(CreateI2cDevice()))
{
llv3.AlgorithmBypassThreshold = 32
}
MCU Wiring
The device communicates over I2C and while there's a PWN mode supported by the device, it is not implemented.
I2C Wiring on the MCU:
LidarLiteV3 Wire | MCU GPIO Pin (Physical Numbering) |
---|---|
5V (red) | 5V |
Ground (black) | Ground |
Power enable (orange) | Optional, an available IO pin |
Mode control (yellow) | Not used |
I2C SCL (green) | SCL |
I2C SDA (blue) | SDA |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.12.0-preview.9)
- nanoFramework.Runtime.Events (>= 1.10.0-preview.4)
- nanoFramework.System.Device.Gpio (>= 1.0.3-preview.10)
- nanoFramework.System.Device.I2c (>= 1.0.3-preview.8)
- UnitsNet.nanoFramework.Length (>= 4.121.0)
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.673 | 75 | 10/23/2024 |
1.2.662 | 73 | 10/11/2024 |
1.2.656 | 72 | 10/3/2024 |
1.2.639 | 92 | 9/6/2024 |
1.2.631 | 97 | 8/28/2024 |
1.2.613 | 102 | 8/9/2024 |
1.2.601 | 68 | 7/26/2024 |
1.2.590 | 92 | 7/17/2024 |
1.2.573 | 91 | 6/19/2024 |
1.2.570 | 86 | 6/14/2024 |
1.2.560 | 99 | 5/29/2024 |
1.2.548 | 103 | 5/15/2024 |
1.2.536 | 128 | 4/15/2024 |
1.2.514 | 124 | 3/22/2024 |
1.2.494 | 107 | 2/28/2024 |
1.2.474 | 131 | 1/24/2024 |
1.2.462 | 161 | 1/5/2024 |
1.2.458 | 131 | 12/20/2023 |
1.2.436 | 169 | 11/10/2023 |
1.2.416 | 124 | 11/8/2023 |
1.2.403 | 135 | 10/6/2023 |
1.2.396 | 125 | 9/27/2023 |
1.2.384 | 154 | 9/6/2023 |
1.2.378 | 162 | 8/16/2023 |
1.2.369 | 152 | 8/2/2023 |
1.2.363 | 152 | 7/28/2023 |
1.2.357 | 149 | 7/19/2023 |
1.2.354 | 150 | 7/14/2023 |
1.2.345 | 165 | 6/21/2023 |
1.2.341 | 163 | 6/14/2023 |
1.2.337 | 188 | 6/7/2023 |
1.2.335 | 166 | 6/2/2023 |
1.2.329 | 168 | 5/26/2023 |
1.2.313 | 165 | 5/12/2023 |
1.2.302 | 193 | 5/10/2023 |
1.2.297 | 194 | 5/3/2023 |
1.2.273 | 259 | 3/17/2023 |
1.2.267 | 279 | 3/10/2023 |
1.2.263 | 274 | 3/8/2023 |
1.2.259 | 281 | 2/27/2023 |
1.2.256 | 297 | 2/24/2023 |
1.2.253 | 307 | 2/22/2023 |
1.2.222 | 324 | 1/9/2023 |
1.2.212 | 336 | 1/5/2023 |
1.2.208 | 328 | 1/3/2023 |
1.2.203 | 304 | 12/28/2022 |
1.2.159 | 395 | 11/14/2022 |
1.2.153 | 400 | 11/5/2022 |
1.2.141 | 426 | 10/25/2022 |
1.2.122 | 467 | 10/12/2022 |
1.2.114 | 431 | 10/8/2022 |
1.2.95 | 471 | 9/22/2022 |
1.2.87 | 526 | 9/15/2022 |
1.2.73 | 455 | 9/8/2022 |
1.2.63 | 448 | 9/3/2022 |
1.2.47 | 459 | 8/15/2022 |
1.2.40 | 476 | 8/6/2022 |
1.2.38 | 464 | 8/5/2022 |
1.2.28 | 476 | 8/1/2022 |
1.2.13 | 478 | 7/24/2022 |
1.2.10 | 471 | 7/23/2022 |
1.1.142.3202 | 501 | 7/7/2022 |
1.1.133.52556 | 477 | 6/30/2022 |
1.1.121.35854 | 490 | 6/26/2022 |
1.1.116.8772 | 462 | 6/24/2022 |
1.1.113.2032 | 457 | 6/23/2022 |
1.1.102.51394 | 477 | 6/15/2022 |
1.1.99.36719 | 467 | 6/14/2022 |
1.1.97.17326 | 489 | 6/13/2022 |
1.1.92.53000 | 476 | 6/8/2022 |
1.1.72.29765 | 472 | 5/31/2022 |
1.1.64.21380 | 475 | 5/26/2022 |
1.1.54.28879 | 480 | 5/23/2022 |
1.1.40 | 472 | 5/5/2022 |
1.1.3 | 506 | 4/15/2022 |
1.1.1 | 495 | 4/14/2022 |
1.0.300 | 496 | 3/31/2022 |
1.0.277-preview.126 | 126 | 3/25/2022 |
1.0.277-preview.125 | 122 | 3/25/2022 |
1.0.277-preview.116 | 107 | 3/22/2022 |
1.0.277-preview.115 | 108 | 3/21/2022 |
1.0.277-preview.112 | 118 | 3/19/2022 |
1.0.277-preview.110 | 120 | 3/18/2022 |
1.0.277-preview.105 | 120 | 3/15/2022 |
1.0.277-preview.99 | 126 | 3/10/2022 |
1.0.277-preview.98 | 126 | 3/8/2022 |
1.0.277-preview.89 | 120 | 2/27/2022 |
1.0.277-preview.87 | 112 | 2/26/2022 |
1.0.277-preview.77 | 120 | 2/18/2022 |
1.0.277-preview.75 | 117 | 2/16/2022 |
1.0.277-preview.73 | 125 | 2/12/2022 |
1.0.277-preview.70 | 120 | 2/10/2022 |
1.0.277-preview.65 | 112 | 2/9/2022 |
1.0.277-preview.53 | 142 | 1/31/2022 |
1.0.277-preview.41 | 128 | 1/28/2022 |
1.0.277-preview.32 | 139 | 1/27/2022 |
1.0.277-preview.30 | 131 | 1/27/2022 |
1.0.277-preview.17 | 141 | 1/24/2022 |
1.0.277-preview.15 | 126 | 1/21/2022 |
1.0.277-preview.13 | 123 | 1/21/2022 |
1.0.277-preview.1 | 138 | 1/11/2022 |
1.0.272 | 500 | 1/10/2022 |
1.0.259 | 350 | 12/9/2021 |
1.0.258 | 338 | 12/7/2021 |
1.0.218 | 203 | 10/18/2021 |
1.0.157 | 371 | 9/4/2021 |
1.0.155 | 348 | 8/31/2021 |
1.0.153 | 372 | 8/14/2021 |
1.0.151 | 387 | 8/6/2021 |
1.0.146 | 349 | 7/22/2021 |
1.0.136 | 430 | 7/17/2021 |
1.0.135 | 169 | 7/16/2021 |
1.0.134 | 176 | 7/15/2021 |
1.0.133 | 199 | 7/14/2021 |
1.0.130 | 167 | 7/6/2021 |
1.0.129 | 174 | 7/6/2021 |
1.0.127 | 184 | 7/5/2021 |
1.0.125 | 199 | 7/5/2021 |
1.0.122 | 218 | 6/30/2021 |
1.0.121 | 204 | 6/29/2021 |
1.0.119 | 228 | 6/28/2021 |
1.0.111 | 182 | 6/14/2021 |
1.0.105 | 279 | 5/29/2021 |
1.0.104 | 242 | 5/29/2021 |
1.0.97 | 182 | 5/28/2021 |
1.0.63 | 174 | 5/26/2021 |
1.0.34 | 175 | 5/24/2021 |