Meadow.Foundation.Sensors.Distance.Vl53l0x
Vl53l0x | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Vl53l0x sensor;
public override Task Initialize()
{
Resolver.Log.Info("Initializing hardware...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
sensor = new Vl53l0x(i2cBus);
sensor.Updated += Sensor_Updated;
return Task.CompletedTask;
}
public override Task Run()
{
sensor.StartUpdating(TimeSpan.FromMilliseconds(250));
return Task.CompletedTask;
}
private void Sensor_Updated(object sender, IChangeResult<Length> result)
{
if (result.New == null) { return; }
if (result.New < new Length(0, LU.Millimeters))
{
Resolver.Log.Info("out of range.");
}
else
{
Resolver.Log.Info($"{result.New.Millimeters}mm / {result.New.Inches:n3}\"");
}
}
Sample project(s) available on GitHub
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: