Meadow.Foundation.Sensors.Distance.Sfsr02
Sfsr02 | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
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");
}