Skip to main content


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

The HY-SRF05 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

Hysrf05 hYSRF05;

public override Task Initialize()
hYSRF05 = new Hysrf05(
device: Device,
triggerPin: Device.Pins.D05,
echoPin: Device.Pins.D06);
hYSRF05.DistanceUpdated += HYSRF05_DistanceUpdated;

return Task.CompletedTask;

public override Task Run()
while (true)
// Sends a trigger signal

return Task.CompletedTask;

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

Sample project(s) available on GitHub

Wiring Example

The HY-SRF05 sensor has 5 pins, but you’ll only connect 4: power, ground, echo and trigger (out isn’t used).