Skip to main content

Meadow.Foundation.Sensors.Distance.Sfsr02

Sfsr02
StatusStatus badge: in-progress
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Distance.Sfsr02

The SF-SR02 ultrasonic sensor uses sonar to determine distance to an object (like bats). It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package.

Sample projects available on GitHub### Code Example

Sfsr02 sFSR02;

public override Task Initialize()
{
sFSR02 = new Sfsr02(Device, Device.Pins.D03);
sFSR02.DistanceUpdated += SFSR02_DistanceUpdated;

return Task.CompletedTask;
}

public override async Task Run()
{
while (true)
{
Console.WriteLine("Measure Distance:");

sFSR02.MeasureDistance();
await Task.Delay(1500);
}
}

private void SFSR02_DistanceUpdated(object sender, IChangeResult<Meadow.Units.Length> e)
{
Console.WriteLine($"{e.New.Centimeters}cm");
}

Sample project(s) available on GitHub