skip to Main Content
(Archive) RPi Node-Red: PIR(motion) Sensor

(Archive) RPi Node-Red: PIR(motion) Sensor


Learn how to wire a passive infrared sensor and read it’s state in Node-Red.

What You Will Learn:

  • Basic Circuit Prototyping
  • Basic Node-Red Programming

What You Need To Know:

Parts List:

  • One PIR
  • Breadboard
  • Some Jumper Wires
  • One 100 Ohm Resistor

What is a PIR?

A passive infrared sensor or PIR is able to detect movement by measuring the change of infrared radiation.  This PIR comes in a 3 pin package, if you remove the diffusion cap you can see that the pins are labeled “VCC”, “OUT”, and “GND”.  VCC means “voltage at the common collector” and normally refers to a power rail within a circuit, this sensor requires 5 volts. OUT is the pin we will read information from.  GND is the ground connection.

Getting Started:

Setting up the Hardware

I encourage gently taking off the diffusion cap on the PIR to view the pins labels.  GND goes to ground, VCC goes to 5V, and OUT is connected to a 100 ohm resistor and then to GPIO20.  

Setting up Node-Red

Start Node-Red and navigate to  Drag a Raspberry Pi input node and a Debug node into the flow area.

Double click on the Raspberry Pi input node to open its configuration menu.  Set the Pin to GPIO20.  Name the node “PIR”.

The debug node can be left with it’s default settings, wire the button node to the debug node and deploy the flow.

If everything has been put together correctly, the state under the PIR node should change from a 0 to a 1 if movement has been detected and then back to 0 after a period of time, inspect the debug tab to view a log of these state transitions.  You may have noticed the two components under the PIR with a plus pattern on them. These are adjustable potentiometers, they control the sensitivity of the PIR and the duration of the activated state.

Whats Next?

Back To Top