Skip to main content

Meadow.Foundation.Sensors.Motion.Hcsens0040

Hcsens0040
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet 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

private Hcsens0040 sensor;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

sensor = new Hcsens0040(Device.CreateDigitalInterruptPort(Device.Pins.D05, Meadow.Hardware.InterruptMode.EdgeBoth));
sensor.OnMotionDetected += Sensor_OnMotionDetected;

return Task.CompletedTask;
}

private void Sensor_OnMotionDetected(object sender)
{
Resolver.Log.Info($"Motion detected {DateTime.Now}");
}

Sample project(s) available on GitHub

Wiring Example

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

Hcsens0040Meadow Pin
GNDGND
TriggerOutD05
VCC3V3

Class Hcsens0040

Create a new Hscens0040 object

Assembly: Hcsens0040.dll
View Source
Declaration
public class Hcsens0040 : IDisposable

Implements:
System.IDisposable

Properties

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Events

OnMotionDetected

Event raised when motion is detected

View Source
Declaration
public event Hcsens0040.MotionChange OnMotionDetected
Event Type

Meadow.Foundation.Sensors.Motion.Hcsens0040.MotionChange

Implements

  • System.IDisposable