Remarks

HY-SRF05
Status Not working
Source code GitHub
NuGet package Not published

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

Wiring Example

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

Characteristic Locus
Inheritance System.Object > Hysrf05
Namespace Meadow.Foundation.Sensors.Distance
Assembly HYSRF05.dll

Syntax

public class Hysrf05 : IRangeFinder

Constructors

Hysrf05(IDigitalOutputPort, IDigitalInputPort)

Create a new HYSRF05 object and hook up the interrupt handler HSSRF05 must be running the default 4/5 pin mode 3 pin mode is not supported on Meadow

Declaration
public Hysrf05(IDigitalOutputPort triggerPort, IDigitalInputPort echoPort)

Parameters

Type Name Description
IDigitalOutputPort triggerPort
IDigitalInputPort echoPort

Hysrf05(IIODevice, IPin, IPin)

Create a new HYSRF05 object with a IO Device HSSRF05 must be running the default 4/5 pin mode 3 pin mode is not supported on Meadow

Declaration
public Hysrf05(IIODevice device, IPin triggerPin, IPin echoPin)

Parameters

Type Name Description
IIODevice device
IPin triggerPin
IPin echoPin

Fields

echoPort

Echo Pin.

Declaration
protected IDigitalInputPort echoPort

Field Value

Type Description
IDigitalInputPort

tickStart

Declaration
protected long tickStart

Field Value

Type Description
System.Int64

triggerPort

Trigger Pin.

Declaration
protected IDigitalOutputPort triggerPort

Field Value

Type Description
IDigitalOutputPort

Properties

CurrentDistance

Returns current distance detected in cm.

Declaration
public float CurrentDistance { get; }

Property Value

Type Description
System.Single

MaximumDistance

Maximum valid distance in cm (CurrentDistance returns -1 if above).

Declaration
public float MaximumDistance { get; }

Property Value

Type Description
System.Single

MinimumDistance

Minimum valid distance in cm (CurrentDistance returns -1 if below).

Declaration
public float MinimumDistance { get; }

Property Value

Type Description
System.Single

Methods

MeasureDistance()

Sends a trigger signal

Declaration
public void MeasureDistance()

Events

DistanceDetected

Raised when an received a rebound trigger signal

Declaration
public event EventHandler<DistanceEventArgs> DistanceDetected

Event Type

Type Description
System.EventHandler<DistanceEventArgs>