Remarks

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

The Parallax PIR detects motion via infrared. It emits a high signal over the data pin when motion is detected. The pin returns to a low state when motion stops.

Code Example

ParallaxPir parallaxPir;

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

    parallaxPir = new ParallaxPir(Device.CreateDigitalInputPort(Device.Pins.D05, InterruptMode.EdgeBoth, ResistorMode.Disabled));

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

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Purchasing

The parallax PIR sensor is available from Parallax Inc:

The following application creates a ParallaxPIR object and attaches interrupt handlers to the OnMotionStart and OnMotionEnd events:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    ParallaxPIR parallax;

    public MeadowApp()
    {
        parallax = new ParallaxPIR(Device.Pins.D13);

        parallax.OnMotionStart += ParallaxMotionStarted;
        parallax.OnMotionEnd += ParallaxMotionEnded;
    }

    void ParallaxMotionEnded(object sender)
    {
        Console.WriteLine("Motion stopped.");
    }

    void ParallaxMotionStarted(object sender)
    {
        Console.WriteLine("Motion detected.");
    }
}

Sample projects available on GitHub

Wiring Example

The Parallax PIR sensor requires only three connections, power, ground and motion detection signal:

Characteristic Locus
Inheritance System.Object > ParallaxPir
Namespace Meadow.Foundation.Sensors.Motion
Assembly ParallaxPir.dll

Syntax

public class ParallaxPir : object

Constructors

ParallaxPir(IDigitalInputController, IPin, InterruptMode, ResistorMode)

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

Declaration
public ParallaxPir(IDigitalInputController device, IPin pin, InterruptMode interruptMode, ResistorMode resistorMode)

Parameters

Type Name Description
IDigitalInputController device
IPin pin
InterruptMode interruptMode
ResistorMode resistorMode

ParallaxPir(IDigitalInputController, IPin, InterruptMode, ResistorMode, TimeSpan, TimeSpan)

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

Declaration
public ParallaxPir(IDigitalInputController device, IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration, TimeSpan glitchFilterCycleCount)

Parameters

Type Name Description
IDigitalInputController device
IPin pin
InterruptMode interruptMode
ResistorMode resistorMode
TimeSpan debounceDuration
TimeSpan glitchFilterCycleCount

ParallaxPir(IDigitalInputPort)

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

Declaration
public ParallaxPir(IDigitalInputPort digitalInputPort)

Parameters

Type Name Description
IDigitalInputPort digitalInputPort

Events

OnMotionEnd

Event raised when the PIR indicates that there is not longer any motion.

Declaration
public event ParallaxPir.MotionChange OnMotionEnd

Event Type

Type Description
ParallaxPir.MotionChange

OnMotionStart

Event raised when motion is detected.

Declaration
public event ParallaxPir.MotionChange OnMotionStart

Event Type

Type Description
ParallaxPir.MotionChange