Remarks
Vl53l0x | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
<img src="https://img.shields.io/nuget/v/Meadow.Foundation.Sensors.Distance.Vl53l0x.svg?label=Meadow.Foundation.Sensors.Distance.Vl53l0x"
style="width: auto; height: -webkit-fill-available;" /></a> |
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
Vl53l0x sensor;
public MeadowApp()
{
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
sensor = new Vl53l0x(Device, i2cBus);
sensor.Updated += SensorUpdated;
sensor.StartUpdating();
}
private void SensorUpdated(object sender, Meadow.Peripherals.Sensors.Distance.DistanceConditionChangeResult e)
{
if (e.New == null || e.New.Distance == null)
{
return;
}
Console.WriteLine($"{e.New.Distance.Value}mm");
}
}
Wiring Example
To wire a Vl53l0x to your Meadow board, connect the following:
Vl53l0x | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
It should look like the following diagram:
Characteristic | Locus |
---|---|
Inheritance | System.Object FilterableChangeObservableBase<DistanceConditionChangeResult, DistanceConditions> > Vl53l0x |
Implements | System.IObservable<DistanceConditionChangeResult> IRangeFinder |
Inherited Members | FilterableChangeObservableBase<DistanceConditionChangeResult, DistanceConditions>._observers FilterableChangeObservableBase<DistanceConditionChangeResult, DistanceConditions>.NotifyObservers(DistanceConditionChangeResult) FilterableChangeObservableBase<DistanceConditionChangeResult, DistanceConditions>.Subscribe(IObserver<DistanceConditionChangeResult>) System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone() |
Namespace | Meadow.Foundation.Sensors.Distance |
Assembly | Vl53l0x.dll |
Syntax
public class Vl53l0x : FilterableChangeObservableBase<DistanceConditionChangeResult, DistanceConditions>, IObservable<DistanceConditionChangeResult>, IRangeFinder
Constructors
Vl53l0x(IIODevice, II2cBus, IPin, Byte, Vl53l0x.UnitType)
Declaration
public Vl53l0x(IIODevice device, II2cBus i2cBus, IPin shutdownPin, byte address = 41, Vl53l0x.UnitType units = Vl53l0x.UnitType.mm)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | |
II2cBus | i2cBus | I2C bus |
IPin | shutdownPin | |
System.Byte | address | VL53L0X address |
Vl53l0x.UnitType | units | Unit of measure |
Vl53l0x(IIODevice, II2cBus, Byte, Vl53l0x.UnitType)
Declaration
public Vl53l0x(IIODevice device, II2cBus i2cBus, byte address = 41, Vl53l0x.UnitType units = Vl53l0x.UnitType.mm)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | |
II2cBus | i2cBus | |
System.Byte | address | |
Vl53l0x.UnitType | units |
Fields
AlgoPartToPartRangeOffsetMm
Declaration
protected const byte AlgoPartToPartRangeOffsetMm = 40
Field Value
Type | Description |
---|---|
System.Byte |
AlgoPhasecalConfigTimeout
Declaration
protected const byte AlgoPhasecalConfigTimeout = 48
Field Value
Type | Description |
---|---|
System.Byte |
AlgoPhasecalLim
Declaration
protected const byte AlgoPhasecalLim = 48
Field Value
Type | Description |
---|---|
System.Byte |
CrosstalkCompensationPeakRateMcps
Declaration
protected const byte CrosstalkCompensationPeakRateMcps = 32
Field Value
Type | Description |
---|---|
System.Byte |
DefaultI2cAddress
Declaration
public const byte DefaultI2cAddress = 41
Field Value
Type | Description |
---|---|
System.Byte |
DynamicSpadNumRequestedRefSpad
Declaration
protected const byte DynamicSpadNumRequestedRefSpad = 78
Field Value
Type | Description |
---|---|
System.Byte |
DynamicSpadRefEnStartOffset
Declaration
protected const byte DynamicSpadRefEnStartOffset = 79
Field Value
Type | Description |
---|---|
System.Byte |
FinalRangeConfigMinCountRateRtnLimit
Declaration
protected const byte FinalRangeConfigMinCountRateRtnLimit = 68
Field Value
Type | Description |
---|---|
System.Byte |
FinalRangeConfigMinSnr
Declaration
protected const byte FinalRangeConfigMinSnr = 103
Field Value
Type | Description |
---|---|
System.Byte |
FinalRangeConfigTimeoutMacropHi
Declaration
protected const byte FinalRangeConfigTimeoutMacropHi = 113
Field Value
Type | Description |
---|---|
System.Byte |
FinalRangeConfigTimeoutMacropLo
Declaration
protected const byte FinalRangeConfigTimeoutMacropLo = 114
Field Value
Type | Description |
---|---|
System.Byte |
FinalRangeConfigValidPhaseHigh
Declaration
protected const byte FinalRangeConfigValidPhaseHigh = 72
Field Value
Type | Description |
---|---|
System.Byte |
FinalRangeConfigValidPhaseLow
Declaration
protected const byte FinalRangeConfigValidPhaseLow = 71
Field Value
Type | Description |
---|---|
System.Byte |
FinalRangeConfigVcselPeriod
Declaration
protected const byte FinalRangeConfigVcselPeriod = 112
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigRefEnStartSelect
Declaration
protected const byte GlobalConfigRefEnStartSelect = 182
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigSpadEnablesRef0
Declaration
protected const byte GlobalConfigSpadEnablesRef0 = 176
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigSpadEnablesRef1
Declaration
protected const byte GlobalConfigSpadEnablesRef1 = 177
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigSpadEnablesRef2
Declaration
protected const byte GlobalConfigSpadEnablesRef2 = 178
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigSpadEnablesRef3
Declaration
protected const byte GlobalConfigSpadEnablesRef3 = 179
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigSpadEnablesRef4
Declaration
protected const byte GlobalConfigSpadEnablesRef4 = 180
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigSpadEnablesRef5
Declaration
protected const byte GlobalConfigSpadEnablesRef5 = 181
Field Value
Type | Description |
---|---|
System.Byte |
GlobalConfigVcselWidth
Declaration
protected const byte GlobalConfigVcselWidth = 50
Field Value
Type | Description |
---|---|
System.Byte |
GpioHvMuxActiveHigh
Declaration
protected const byte GpioHvMuxActiveHigh = 132
Field Value
Type | Description |
---|---|
System.Byte |
HistogramConfigInitialPhaseSelect
Declaration
protected const byte HistogramConfigInitialPhaseSelect = 51
Field Value
Type | Description |
---|---|
System.Byte |
HistogramConfigReadoutCtrl
Declaration
protected const byte HistogramConfigReadoutCtrl = 85
Field Value
Type | Description |
---|---|
System.Byte |
I2CSlaveDeviceAddress
Declaration
protected const byte I2CSlaveDeviceAddress = 138
Field Value
Type | Description |
---|---|
System.Byte |
IdentificationModelId
Declaration
protected const byte IdentificationModelId = 192
Field Value
Type | Description |
---|---|
System.Byte |
IdentificationRevisionId
Declaration
protected const byte IdentificationRevisionId = 194
Field Value
Type | Description |
---|---|
System.Byte |
MsrcConfigControl
Declaration
protected const byte MsrcConfigControl = 96
Field Value
Type | Description |
---|---|
System.Byte |
MsrcConfigTimeoutMacrop
Declaration
protected const byte MsrcConfigTimeoutMacrop = 70
Field Value
Type | Description |
---|---|
System.Byte |
OscCalibrateVal
Declaration
protected const byte OscCalibrateVal = 248
Field Value
Type | Description |
---|---|
System.Byte |
PowerManagementGo1PowerForce
Declaration
protected const byte PowerManagementGo1PowerForce = 128
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigMinSnr
Declaration
protected const byte PreRangeConfigMinSnr = 39
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigSigmaThreshHi
Declaration
protected const byte PreRangeConfigSigmaThreshHi = 97
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigSigmaThreshLo
Declaration
protected const byte PreRangeConfigSigmaThreshLo = 98
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigTimeoutMacropHi
Declaration
protected const byte PreRangeConfigTimeoutMacropHi = 81
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigTimeoutMacropLo
Declaration
protected const byte PreRangeConfigTimeoutMacropLo = 82
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigValidPhaseHigh
Declaration
protected const byte PreRangeConfigValidPhaseHigh = 87
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigValidPhaseLow
Declaration
protected const byte PreRangeConfigValidPhaseLow = 86
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeConfigVcselPeriod
Declaration
protected const byte PreRangeConfigVcselPeriod = 80
Field Value
Type | Description |
---|---|
System.Byte |
PreRangeMinCountRateRtnLimit
Declaration
protected const byte PreRangeMinCountRateRtnLimit = 100
Field Value
Type | Description |
---|---|
System.Byte |
RangeStart
Declaration
protected const byte RangeStart = 0
Field Value
Type | Description |
---|---|
System.Byte |
ResultCoreAmbientWindowEventsRef
Declaration
protected const byte ResultCoreAmbientWindowEventsRef = 208
Field Value
Type | Description |
---|---|
System.Byte |
ResultCoreAmbientWindowEventsRtn
Declaration
protected const byte ResultCoreAmbientWindowEventsRtn = 188
Field Value
Type | Description |
---|---|
System.Byte |
ResultCoreRangingTotalEventsRef
Declaration
protected const byte ResultCoreRangingTotalEventsRef = 212
Field Value
Type | Description |
---|---|
System.Byte |
ResultCoreRangingTotalEventsRtn
Declaration
protected const byte ResultCoreRangingTotalEventsRtn = 192
Field Value
Type | Description |
---|---|
System.Byte |
ResultInterruptStatus
Declaration
protected const byte ResultInterruptStatus = 19
Field Value
Type | Description |
---|---|
System.Byte |
ResultPeakSignalRateRef
Declaration
protected const byte ResultPeakSignalRateRef = 182
Field Value
Type | Description |
---|---|
System.Byte |
ResultRangeStatus
Declaration
protected const byte ResultRangeStatus = 20
Field Value
Type | Description |
---|---|
System.Byte |
SoftResetGo2SoftResetN
Declaration
protected const byte SoftResetGo2SoftResetN = 191
Field Value
Type | Description |
---|---|
System.Byte |
SystemHistogramBin
Declaration
protected const byte SystemHistogramBin = 129
Field Value
Type | Description |
---|---|
System.Byte |
SystemIntermeasurementPeriod
Declaration
protected const byte SystemIntermeasurementPeriod = 4
Field Value
Type | Description |
---|---|
System.Byte |
SystemInterruptClear
Declaration
protected const byte SystemInterruptClear = 11
Field Value
Type | Description |
---|---|
System.Byte |
SystemInterruptConfigGpio
Declaration
protected const byte SystemInterruptConfigGpio = 10
Field Value
Type | Description |
---|---|
System.Byte |
SystemRangeConfig
Declaration
protected const byte SystemRangeConfig = 9
Field Value
Type | Description |
---|---|
System.Byte |
SystemSequenceConfig
Declaration
protected const byte SystemSequenceConfig = 1
Field Value
Type | Description |
---|---|
System.Byte |
SystemThreahHigh
Declaration
protected const byte SystemThreahHigh = 12
Field Value
Type | Description |
---|---|
System.Byte |
SystemThreshLow
Declaration
protected const byte SystemThreshLow = 14
Field Value
Type | Description |
---|---|
System.Byte |
VcselPeriodFinalRange
Declaration
protected const int VcselPeriodFinalRange = 1
Field Value
Type | Description |
---|---|
System.Int32 |
VcselPeriodPreRange
Declaration
protected const int VcselPeriodPreRange = 0
Field Value
Type | Description |
---|---|
System.Int32 |
VhvConfigPadSclSdaExtsupHv
Declaration
protected const byte VhvConfigPadSclSdaExtsupHv = 137
Field Value
Type | Description |
---|---|
System.Byte |
Properties
Conditions
Declaration
public DistanceConditions Conditions { get; protected set; }
Property Value
Type | Description |
---|---|
DistanceConditions |
CurrentDistance
Declaration
public float CurrentDistance { get; }
Property Value
Type | Description |
---|---|
System.Single |
IsSampling
Is the sensor sampling
Declaration
public bool IsSampling { get; protected set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsShutdown
Declaration
public bool IsShutdown { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaximumDistance
Maximum valid distance in mm (CurrentDistance returns -1 if above).
Declaration
public float MaximumDistance { get; }
Property Value
Type | Description |
---|---|
System.Single |
MinimumDistance
Minimum valid distance in mm.
Declaration
public float MinimumDistance { get; }
Property Value
Type | Description |
---|---|
System.Single |
Units
Declaration
public Vl53l0x.UnitType Units { get; set; }
Property Value
Type | Description |
---|---|
Vl53l0x.UnitType |
Methods
GetRange()
Returns the current distance/range
Declaration
protected Task<float> GetRange()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Single> | The distance in the specified Units. Default mm. Returns -1 if the shutdown pin is used and is off |
GetRawRangeData()
Declaration
protected Task<int> GetRawRangeData()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> |
GetSpadInfo()
Declaration
protected Tuple<int, bool> GetSpadInfo()
Returns
Type | Description |
---|---|
System.Tuple<System.Int32, System.Boolean> |
Initialize()
Initializes the VL53L0X
Declaration
protected Task Initialize()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
PerformSingleRefCalibration(Byte)
Declaration
protected void PerformSingleRefCalibration(byte vhvInitByte)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | vhvInitByte |
RaiseChangedAndNotify(DistanceConditionChangeResult)
Declaration
protected void RaiseChangedAndNotify(DistanceConditionChangeResult changeResult)
Parameters
Type | Name | Description |
---|---|---|
DistanceConditionChangeResult | changeResult |
Read()
Declaration
public Task<DistanceConditions> Read()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DistanceConditions> |
Read(Byte)
Declaration
protected byte Read(byte address)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | address |
Returns
Type | Description |
---|---|
System.Byte |
Read16(Byte)
Declaration
protected int Read16(byte address)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | address |
Returns
Type | Description |
---|---|
System.Int32 |
SetAddress(Byte)
Set a new I2C address
Declaration
public void SetAddress(byte newAddress)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | newAddress |
ShutDown(Boolean)
Set the Shutdown state of the device
Declaration
public Task ShutDown(bool state)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | state | true = off/shutdown. false = on |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
StartUpdating(Int32)
Declaration
public void StartUpdating(int standbyDuration = 1000)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | standbyDuration |
StopUpdating()
Declaration
public void StopUpdating()
Subscribe(IObserver<DistanceConditionChangeResult>)
Declaration
public IDisposable Subscribe(IObserver<DistanceConditionChangeResult> observer)
Parameters
Type | Name | Description |
---|---|---|
System.IObserver<DistanceConditionChangeResult> | observer |
Returns
Type | Description |
---|---|
System.IDisposable |
Update()
Read the sensor output and convert the sensor readings into acceleration values.
Declaration
public Task Update()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Events
Updated
Declaration
public event EventHandler<DistanceConditionChangeResult> Updated
Event Type
Type | Description |
---|---|
System.EventHandler<DistanceConditionChangeResult> |