You are on page 1of 5

2012

PIR sensor with Raspberry Pi

Author: Praveen Kumar

Introduction:
The Raspberry Pi is a credit-card sized computer board that plugs into a TV and a keyboard. Its a miniature ARM-based PC which can be used for many of the things that a desktop PC does, like spread sheets, word-processing and games. It also plays High-Definition video. In this lesson, we will concentrate on sensing movement and controlling led.

Real-time application:
Using this concept we will build on this security sensing to have the Pi use a digital output to control the power to an electrical appliance when movement is detected. Alaram system Robot sensing system Controlling Electrical Appliance Prerequisites Raspberry Pi 512 MB USB cable micro 8SD card class 4 PIR Sensor PIR sensor PIR sensor

# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085, Email: info@tenettech.com, Phone: 080 - 26722726

Passive Infra-Red (PIR) sensors basically detect temperature changes between sections of a viewing range. This means if a person (a source of heat) moves between two sectors within the sensors field of vision this is detected as movement. PIR sensors are well used in alarm sensors. The great thing about being based on temperature is that they work in the dark and ideally suited for sensing people. The overlap with security systems can be annoying. I found fairly good selection of PIR sensors which would work within the 3.3v-5v range the Pi can support. They come in a few varieties, but each has a fairly decent range (2.5-10m). Step 1: Open the LXterminal and the type the following command. Step 2: Enter the following command to open a nano window with the filename. sudo nano pir.py Step 3: So heres the Python script I wrote, using the RPi.GPIO library . Type the following program

# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085, Email: info@tenettech.com, Phone: 080 - 26722726

Circuit Connection:

The red lead goes to 5V, the black to GND and the yellow to GPIO Pin.

# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085, Email: info@tenettech.com, Phone: 080 - 26722726

Step 4:

Run the program as superuser using the command:


Sudo python pir.py

For queries: info@tenettech.com For placing an order: http://www.tenettech.com/product/2184/tenet-technetronicsraspberry-pi http://www.tenettech.com/product/2583/pir-sensor-standard-motion-detection-module

# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085, Email: info@tenettech.com, Phone: 080 - 26722726