PIR Motion Sensor Using Raspberry Pi4 | Interfacing Tutorial

Introduction: PIR Motion Sensor Using Raspberry Pi4 | Interfacing Tutorial

Today in this project I will show you how to interface PIR sensor using Raspberry Pi ,when the PIR Sensor detects any human motion, a buzzer is activated with a Relay Activate

For this project you have to need know about PIR sensor and Raspberry Pi

What is is PIR sensor:

PIR sensors allow you to sense motion, almost always used to detect whether a human has moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and don’t wear out. For that reason they are commonly found in appliances and gadgets used in homes or businesses. They are often referred to as PIR, “Passive Infrared”, “Pyroelectric”, or “IR motion” sensors

what is Raspberry :

The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. It’s capable of doing everything you’d expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games. What’s more, the Raspberry Pi has the ability to interact with the outside world, and has been used in a wide array of digital maker projects, from music machines and parent detectors to weather stations and tweeting birdhouses with infra-red cameras. We want to see the Raspberry Pi being used by kids all over the world to learn to program and understand how computers work

Step 1: Circuit Diagram

Components Required

  1. Raspberry Pi 4 Model B
  2. PIR Sensor
  3. 5V Buzzer
  4. Connecting Wires
  5. Breadboard
  6. Power Supply
  7. BC547
  8. Relay Module

Circuit Design

Connect the VCC and GND pins of the PIR Motion Sensor to +5V and GND pins of the Raspberry Pi. Connect the DATA Pin of the PIR Sensor to GPIO24 of the Raspberry Pi. A 5V Buzzer is connected to GPIO20 i.e. and BC547 base Connected toGPIO 21 and Emitter Connected to GND and Collector connected to relay signal pin of the Raspberry Pi. The other pin of the buzzer and LED is connected to GND.

The Programming part of the project is implemented using Python. The following is the Python Script for the PIR Motion Sensor using Raspberry Pi

import RPi.GPIO as GPIO
import time

sensor = 24
buzzer = 20


print ("Initialzing PIR Sensor......")
print ("PIR Ready...")
print (" ")

   while True:
      if GPIO.input(sensor):
          print ("Motion Detected")
          while GPIO.input(sensor):
          print ("Motion Not Detected")

except KeyboardInterrupt:

Step 2:

Be the First to Share


    • Soup & Stew Speed Challenge

      Soup & Stew Speed Challenge
    • Rocks, Gems, and Stones Speed Challenge

      Rocks, Gems, and Stones Speed Challenge
    • Retro Tech Challenge

      Retro Tech Challenge