Skip to main content

Meadow.Foundation.Sensors.Distance.Vl53l0x

Vl53l0x
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Distance.Vl53l0x

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:

Vl53l0xMeadow Pin
GNDGND
SCLD08 (SCL)
SDAD07 (SDA)
VCC3V3

It should look like the following diagram: