How to Interface a PIR Motion Sensor With Raspberry Pi GPIO

This tutorial will show you to interface a PIR motion sensor with the Raspberry Pi and how to use the GPIO pins on it. The GPIO pins on the Raspberry Pi are critical when it comes to making a hardware project. May it be a robot, home automation system, or whatever crazy creation you come up with. In all these cases you will have to use the GPIO (General Purpose Input/Output) pins on the Raspberry Pi. With this simple tutorial, you will be able to learn how to control the output on the GPIO pins. and read inputs through them. Moreover, you will get to read the output from a PIR motion sensor and write a simple code to blink an LED. If you’re not familiar with the Rasbperry Pi terminal, check out this tutorial on Basic Linux Commands. If you are a true beginner, you can always use our free eBook on Raspberry Pi and Arduino to get started from step 0. So gear up and get ready to have some fun with the Raspberry Pi GPIOs!how to interface a pir motion sensor with raspberry pi gpio

Required Materials

  1. Raspberry Pi B/B+ or 2 and basic peripherals: SD card, keyboard, mouse, etc. (This should work on Raspberry Pi 3 as well)
  2. An LED and 220Ohm resistor.
  3. PIR motion sensor.
  4. Breadboard.
  5. Male to male and Female to Male jumper wires.

How Does it Work?

The Raspberry Pi GPIO can be accessed through a python program. You will get to know how to access these pins and the commands required to do that later in this tutorial. Each pin on the Raspberry Pi is named based on its order (1,2,3,..) as shown in the diagram below:diagram how to interface a pir motion sensor with raspberry pi gpio

Here, we are using a PIR motion sensor. PIR stands for Passive InfraRed. This motion sensor consists of a fresnel lens, an infrared detector, and supporting detection circuitry. The lens on the sensor focuses any infrared radiation present around it toward the infrared detector. Our bodies generate infrared heat, and as a result, this heat is picked up by the motion sensor. The sensor outputs a 5V signal for a period of one minute as soon as it detects the presence of a person. It offers a tentative range of detection of about 6-7 meters and is highly sensitive. When the PIR motion sensor detects a person, it outputs a 5V signal to the Raspberry Pi through its GPIO and we define what the Raspberry Pi should do as it detects an intruder through the python coding. Here we are just printing: “Intruder detected”.

For more detail: How to Interface a PIR Motion Sensor With Raspberry Pi GPIO


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top