What is a motion sensor? How does it work? How do you use it?

Introduction

A Passive Infrared (PIR) motion sensor is an electronic sensor that measures infrared light emitted by objects within its field of view.

PIR sensors are commonly used in security alarms and automatic lighting applications.

PIR sensors detect general motion but do not provide information about who or what moved. For that, an imaging IR sensor is required.

We created a project using the PIR sensor in an anti-intrusion alarm system for your home!

How does the sensor detect motion?

All objects with a temperature above absolute zero emit thermal energy in the form of electromagnetic radiation. Normally, this radiation is not visible to the human eye because it is emitted at infrared wavelengths, but it can be detected by the motion sensor.

How does the sensor work?

The motion sensor has two slots, each made of a special material sensitive to infrared. When the sensor is inactive, both slots detect the same amount of IR, the ambient radiation emitted by the room. When a warm body like a human or animal passes by, it first intercepts one half of the motion sensor, causing a positive differential change between the two halves. When the warm body leaves the detection area, the opposite occurs, generating a negative differential change. These change pulses are what the sensor detects.

Motion sensor pins

The pins of the motion sensor:

Vcc: Connect to the 5V pin on the Arduino board
Signal: Connect to one of the Arduino’s digital input pins
GND: Connect to ground (GND)

Detection with the serial monitor

Now let’s see how to display motion detection on the serial monitor.

Light alert with motion detection

Let’s see how to turn on an LED when the sensor detects motion.

You can replace the LED with a bulb connected through a relay to turn on a room’s light when someone enters.

Sound alert with motion detection

Now let’s see how to turn on a buzzer when the sensor detects motion.