Using a PIR sensor

You are all radioactive!!! No.. just kidding…

Humans and other animals emit radiation all the time. This is nothing to be concerned about, though, as the type of radiation we emit is infra-red radiation (IR), which is pretty harmless at the levels at which it is emitted by humans. In fact, all objects at temperatures above absolute zero (-273.15C) emit infra-red radiation.

A PIR sensor detects changes in the amount of infra-red radiation it receives. When there is a significant change in the amount of infra-red radiation it detects. Then a pulse is triggered. This means that a PIR sensor can detect when a human (or any animal) moves in front of it.

What I used:

Setting up

We will assume that you have your raspberry pi setup and ready to go. If you need help with this visit our blog.

Wiring a PIR sensor

When a PIR detects motion, the pulse is emitted and needs to be amplified. Power is also provided. There are three pins on the PIR. These labels are sometimes concealed beneath the Fresnel lens (the white cap). You can temporarily remove this dome to see the pin labels. Connect the Vcc to the + gutter, the Gnd to the – Gutter and the Out to one of your GPIO pins (eg. GPIO20).

Tuning a PIR

Most PIR sensors have two potentiometers on them. The first controls the sensitivity. The second controls the period of time for which the PIR will signal when motion is detected is controlled by the second.

Detecting motion

The PIR detects motion by using the code below:

from gpiozero import MotionSensor
pir = MotionSensor(20)

while True:
        print("You moved")