Remarks

Hcsens0040
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Hcsens0040

The HCSENS0040 is a microwave motion detector commonly found on the RCWL-0516 board. It detects relative motion using the doppler effect. It uses a single GPIO pin to notify Meadow when motion is detected.

Code Example

Hcsens0040 sensor;

public override Task Initialize()
{
    Console.WriteLine("Initialize...");

    sensor = new Hcsens0040(Device.CreateDigitalInputPort(Device.Pins.D05));
    sensor.OnMotionDetected += Sensor_OnMotionDetected;

    return Task.CompletedTask;
}

private void Sensor_OnMotionDetected(object sender)
{
    Console.WriteLine($"Motion detected {DateTime.Now}");
}

Sample project(s) available on GitHub

Wiring Example

To wire a Hcsens0040 to your Meadow board, connect the following:

Hcsens0040 Meadow Pin
GND GND
TriggerOut D05
VCC 3V3
Characteristic Locus
Inheritance System.Object > Hcsens0040
Namespace Meadow.Foundation.Sensors.Motion
Assembly Hcsens0040.dll

Syntax

public class Hcsens0040 : object

Constructors

Hcsens0040(IDigitalInputController, IPin)

Create a new Parallax PIR object connected to an input pin and IO Device.

Declaration
public Hcsens0040(IDigitalInputController device, IPin inputPin)

Parameters

Type Name Description
IDigitalInputController device

The device connected to the sensor

IPin inputPin

The input pin

Hcsens0040(IDigitalInputPort)

Create a new Parallax PIR object connected to a interrupt port.

Declaration
public Hcsens0040(IDigitalInputPort digitalInputPort)

Parameters

Type Name Description
IDigitalInputPort digitalInputPort

Events

OnMotionDetected

Event raised when motion is detected.

Declaration
public event Hcsens0040.MotionChange OnMotionDetected

Event Type

Type Description
Hcsens0040.MotionChange