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!
- Raspberry Pi B/B+ or 2 and basic peripherals: SD card, keyboard, mouse, etc. (This should work on Raspberry Pi 3 as well)
- An LED and 220Ohm resistor.
- PIR motion sensor.
- 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:
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
Low cost PCB at PCBWay - only $5 for 10 PCBs and FREE first order for new members
PCB Assembly service starts from $30 with Free shipping all around world + Free stencil
Extra 15% off for flex and rigid-flex PCB