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

motion sensor raspberry Pi

The document outlines a project for programming a Raspberry Pi to detect motion using a PIR sensor. It includes objectives such as understanding GPIO pins and writing a Python program for motion detection, along with a circuit diagram and step-by-step instructions for setting up the hardware and software. The program provided interfaces a buzzer with the PIR sensor to signal when motion is detected.

Uploaded by

samsonpillai1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

motion sensor raspberry Pi

The document outlines a project for programming a Raspberry Pi to detect motion using a PIR sensor. It includes objectives such as understanding GPIO pins and writing a Python program for motion detection, along with a circuit diagram and step-by-step instructions for setting up the hardware and software. The program provided interfaces a buzzer with the PIR sensor to signal when motion is detected.

Uploaded by

samsonpillai1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Raspberry Pi for motion detection

using PIR sensor


Aim: Programming Raspberry Pi todetect 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:
PA rderfsce

GPIO2 SOAIRC GPIOZ1


GND
GPIO3SCLI I2C GPIO20

GPID4 Raspberry Pi 3 GPIO16

GPIO1 Model B v1.2 GPIOL2


+5V
GPI027 ID_SC I2C ID EEPROM
GPIO22 GPIO7 SPIO CELN
GIPO10 SPID_MOSI GPO8 SPD CEO N
GPIO9 SPID MISO GPIO2S
Buzzer
GPIO11 SPID SCLK GPIO24 RI
ID SD I2C D EEPROM GPI023

GPIOS GPIO18 PCM CLK


GPIO5 GPIO15 UARTO RXD
GPIO13 GPIO14 UARTO TXD
GPIO19
To GPIO 20
GPIO26
LED

R2

Note: Either Buzzer or LED can be interfaced to GPIO 20 pin. Both cannot be connected
simultaneously.
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
(Already Connected)
+ 5V
(Already Connected)
GND
(Already Connected)
1
Procedure:

Note: The Raspbianoperating 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 Piand check the Raspbian OS loaded properly or not. If
not then check the circuit connection again.
2. Python Programnming: 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 willopen
the Python shell.

Office Gesny Programrner's Editor


nternet Greefoot Jave IDE
Games > Mthernat:ca

AoCessories
Graphncs PytoH 2(0.E)

Hip
Scratch
Preferences
Scrath 2
Run..

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.0UT)
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 2

You might also like