Remarks

PIRMotionSensor
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Grove.Sensors.Motion.PIRMotionSensor

Code Example

PIRMotionSensor motionSensor;

public override Task Initialize()
{
    motionSensor = new PIRMotionSensor(
        Device.CreateDigitalInputPort(
            Device.Pins.D13, 
            InterruptMode.EdgeBoth, 
            ResistorMode.Disabled));

    motionSensor.OnMotionStart += (sender) => 
    { 
        Console.WriteLine($"Motion start  {DateTime.Now}"); 
    };

    motionSensor.OnMotionEnd += (sender) => 
    { 
        Console.WriteLine($"Motion end  {DateTime.Now}"); 
    };

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

PIRMotionSensor Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00
Characteristic Locus
Inheritance System.Object ParallaxPir > PIRMotionSensor
Inherited Members ParallaxPir.OnMotionStart ParallaxPir.OnMotionEnd
Namespace Meadow.Foundation.Grove.Sensors.Motion
Assembly PIRMotionSensor.dll

Syntax

public class PIRMotionSensor : ParallaxPir

Constructors

PIRMotionSensor(IDigitalInputPort)

Creates a PIRMotionSensor driver

Declaration
public PIRMotionSensor(IDigitalInputPort digitalInputPort)

Parameters

Type Name Description
IDigitalInputPort digitalInputPort

PIRMotionSensor(IPin, InterruptMode, ResistorMode, TimeSpan, TimeSpan)

Creates a PIRMotionSensor driver

Declaration
public PIRMotionSensor(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration, TimeSpan glitchDuration)

Parameters

Type Name Description
IPin pin

The pin connected to the PIR sensor

InterruptMode interruptMode

The interrupt mode of the pin

ResistorMode resistorMode

The resistor mode of the pin

TimeSpan debounceDuration

The debounce duration

TimeSpan glitchDuration

The glitch duration (can typically be set to zero)