0% found this document useful (0 votes)
14 views

Programming Raspberry Pi to PIR Sensor

The document outlines a project aimed at programming a Raspberry Pi to detect motion using a PIR sensor. It includes objectives such as understanding GPIO pins, studying the PIR sensor, and writing a Python program for motion detection. The document also provides a circuit diagram, GPIO pin connections, and a sample Python code for interfacing the PIR sensor with a buzzer.

Uploaded by

indalkaranuja2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Programming Raspberry Pi to PIR Sensor

The document outlines a project aimed at programming a Raspberry Pi to detect motion using a PIR sensor. It includes objectives such as understanding GPIO pins, studying the PIR sensor, and writing a Python program for motion detection. The document also provides a circuit diagram, GPIO pin connections, and a sample Python code for interfacing the PIR sensor with a buzzer.

Uploaded by

indalkaranuja2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Raspberry Pi for motion detection using PIR sensor

AIM: Programming Raspberry Pi to detect motion using PIR Sensor

OBJECTIVES:
a. To understand the basics of the GPIO Pins of Raspberry Pi.
b. To study the basic of PIR sensor.
c. To write a python program to detect any human motion using PIR Sensor.

CIRCUIT/ BLOCK DIAGRAM:

Note: Either Buzzer or LED can be interfaced to GPIO 20 pin. Both cannot be connected simultaneously.

1|Page
GPIO Pin Connection for PIR, Buzzer and LED:

Pin on Kit Pins on Raspberry Pi


GPIO Pins Pin Nmber
Buzzer/ LED GPIO 20 38
PIR Sensor GPIO 21 40
+ 3.3V - 1
+ 5V - 2
GND - 6

Procedure:

Note: The Raspbian operating system comes with Python already installed in it.

1. Setting up the circuit:


a. Turn OFF the Raspberry Pi while building/connecting the circuit board/components
according to diagram.
b. Then turn the Raspberry Pi and check the Raspbian OS loaded properly or not. If not
then check the circuit connection again.

2. Python Programming: Python via IDLE

a. Start Raspberry Pi in desktop mode, open the Applications Menu in the top left of
your screen, and navigate to Programming > Python 3 (IDLE) /. This will open the
Python shell.

2|Page
b. Write a program for PIR sensor and Buzzer interfacing with raspberry pi and save as
with pir.py

Program: # PIR sensor and Buzzer interfacing with raspberry pi


importRPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) #choose GPIO
GPIO.setwarnings(False)

PIR_input=21 #read PIR Output


BUZZ=20 #BUZZ for signaling motion detected

GPIO.setup(PIR_input, GPIO.IN)
GPIO.setup(BUZZ, GPIO.OUT)
GPIO.output(BUZZ, GPIO.LOW)

while True:
#when motion detected turn on BUZZ
if(GPIO.input(PIR_input)):
GPIO.output(BUZZ, GPIO.HIGH)
else:
GPIO.output(BUZZ, GPIO.LOW)

Steps to execute Program

1. Make connections as given above


2. Open ‘PIR_BUZZER.py’ file in python 3 IDE
3. Select Run from top menu and click Run Module

3|Page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy