Raspberry Pi Motion Sensor using a PIR Sensor

In this tutorial we’re building a Raspberry Pi motion sensor that makes use of a PIR sensor (Passive Infrared Sensor). Also to make this project a little more interesting we will also be using a piezo speaker whenever motion is detected. Both these devices will need to be hooked up to the GPIO pins in order to work.raspberry pi motion sensor using-a pir sensor


In order to do this project, you will need some equipment this includes a Raspberry Pi PIR sensor and a piezo speaker.
Raspberry Pi

SD Card (8 GB+ Recommended) or Micro SD Card if you’re using a Raspberry Pi 2, 3 or B+

PIR Sensor

Piezo speaker

1x 100-ohm resistor


Ethernet Cord or Wifi dongle (These are only required if you plan on remotely controlling the Pi)

GPIO Breakout Kit Assembled


Breadboard Wire/Jumper Cables

Whilst the breakout board, breadboard and the wire are optional I do highly recommend using these as they will make your life a lot easier. Also be sure to check out some of the best Raspberry Pi cases you’re able to get.

Raspberry Pi PIR Sensor Hardware Setup

We will be putting together a simple circuit that makes use of a PIR sensor and also a piezo speaker.

A PIR sensor is most commonly seen in security systems to detect movement before sending the alarm off. They detect motion whenever there is a change of infrared temperature in their field of view.

Most PIR sensors have some adjustable screws on them that will allow you to adjust both the time and sensitivity of them. The time will allow you to set a delay before it will go off (Send a high signal). (About 2-4 seconds). The sensitivity is how much movement needs to occur before it will go off.

The piezo buzzer is a simple speaker that outputs a sound whenever a current is run through it. In this circuit the buzzer will give a loud beep whenever the motion detector circuit is triggered.

A breadboard isn’t necessarily required for this project but I would highly recommend using one. They make prototyping and building circuitry a lot easier.

You don’t have to use a breadboard like I am you can just simply hook these straight up to the Raspberry Pi.circuit raspberry pi motion sensor using a pir sensor

To construct the circuit simply do the following.

  1. Run a ground pin to the ground/negative rail on the breadboard.
  2. Run a 5v pin to the positive rail on the breadboard.
  3. Connect the piezo buzzer to pin 7 (Red wire) and the negative rail (Black wire).
  4. Run a wire from pin 11 to the breadboard. Place a 100-ohm resistor at the end of the wire. Then connect this up to the yellow wire of the PIR sensor.
  5. Now for the PIR sensor run the red wire to the 5v line and the black wire to the ground rail on the breadboard.

For more detail: Raspberry Pi Motion Sensor using a PIR Sensor

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:

Leave a Comment

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

Scroll to Top