You are on page 1of 17

HOME SECURITY AND SAFETY SYSTEM

Presented by:
Abbas Abdul Jabbar
Ammar Samir
Waddah Ahmed
2nd Stage (Evening Study)

Dr. Omar Youssef


HOME SECURITY AND SAFETY SYSTEM

Introduction:

Crime rates are escalating on a daily basis and thieves seem to

generate new techniques of robbing people of their property

worldwide. On another note with living standards becoming

expensive by the day due to inflation, everyone wants to protect their

property from threats. Security system products on the market are

expensive to setup due to the relative price of the controllers used

and they are also subject to monthly subscriptions since they are

monitored by security service companies. These products give an

alert by only sounding an alarm, which implies a remote home owner

will not be alerted by the system when there is an outbreak. However,

it simply triggers an alarm. Burglar alarm system include

sophisticated components such as environmental sensors for motion,

beam detection, vibration sensors, glass break detection and many

more. Yet, it has a high cost. Though surveillance Digital Video

Recorder (DVR) and Network Video Recorder (NVR) consoles now have

streaming and motion detection recording features they are

expensive to install (online DVR prices average $100 on online

1|P a g e
shops). Recordings from these systems are normally lost due to

damage by thieves or burnt in cases of a fire. This project seeks to

integrate intrusion and surveillance camera using a Raspberry-pi

microcontroller, which alerts the user by sending an E-mail. This

project incorporates all these features into one entity and adds extra

functionalities such picture and E-mail notifications. This system will

detect the presence of Intruder and quickly alert the user by sending

him a alert mail. This mail will also contain the Picture of the Intruder,

captured by Pi camera. Raspberry Pi is used to control the whole

system. This system can be installed at the main door of your home

or office and you can monitor it from anywhere in the world using

your Email over internet.

Home Safety and Security System:

System integration is basically the process of connecting

different subsystems into a single entity with a simplified and

centralized management. The lagging behind in the integration of

such systems was on the basis of their design requirements. Design

requirements for detection systems are proceeds of design regulation

2|P a g e
and security systems design considerations. Tamper protection is a

key feature of consideration for security system design hence having

their controllers in locations of public access is a security threat. To

our knowledge the hindrance to having a single system monitoring

safety and security was biased towards businesses and is not

considerate of home owners. For households, design is less regulated

allowing for a creative and flexible approach towards low cost

solutions. Security detection systems discussed above only give the

user an alert but do not portray the status-quo. Available surveillance

cameras are linked to the system. There is therefore, no direct

correlation between the detection systems and surveillance system.

Monitoring of recorded content is done by human beings physically

who can make mistakes due to many reasons. This manual work done

by security personnel also implies additional cost on the owners. The

Arduino system stresses this point, as it effectively alerts a remote

user of intrusion and fire through an SMS. The system incorporates

both smoke and heat parameters to detect fire. However, it does not

provide substantial evidence of how detection incidents unfolded.

Surveillance camera solutions available are Network Video Recorder

(NVR) and Digital Video Recorder (DVR). These two solutions store

3|P a g e
surveillance records locally in a hard-drive. These records are

susceptible to loss in occurrence of a fire or damage during break-

ins. This loss of information makes the system futile as there will be

no evidence for crime investigations. It is also difficult to succeed in

insurance claims when there is no concrete proof of the legitimacy of

fire causes. These systems continuously record videos, a feature

which is not economic in terms of memory preservation. It is

therefore, imperative that work can still be done on remote recording

and cohesion of information from fire and security alert systems into

a more robust surveillance camera system. The overhead in this

project is unnecessary as the raspberry-pi is capable of handling

these functionalities without an Arduino. The security system which

is also based on the raspberry pi was capable of motion detection and

alerting a remote user through email. However, the project could not

archive video uploading into the internet. It also has motion tracking

functionality which is necessary. There is therefore a need to develop

a system that is capable of sending pictures online. The systems

discussed above are separate systems for motion detection. The

system captures images upon detection and emails them to the user.

Email is however an internet based which has limited coverage. There

4|P a g e
is therefore need to develop an integrated motion, surveillance

system which will result in lower maintenance cost since there is only

a single central controller. There is also potential energy saving as

the power that could have been exhausted by distinct dedicated

microcontrollers is relatively less.

Hardware Components:

Pi-Camera:

Raspberry has a Pi-cameras which can be included into their

systems. This camera connects to the microcontroller through a

ribbon connector. The ribbon connector attaches to a customized

connector in the raspberry-pi.

5|P a g e
Passive Infrared Sensor (PIR):

Passive infrared motion sensors (PIR) operate by detecting levels

of infrared radiation. PIR’s are small, inexpensive and low power

devices, just the properties that render them attractive for motion

sensing. In order to enlarge the coverage of the sensor a plastic lens

is used which basically condenses the room into small area. The lens

used is termed Fresnel lens and it works as a radiation condenser.

Figure 1 PIR sensor

Figure 2 PIR sensor

6|P a g e
Bread Board:

Figure 3 breadbord

LEDS & 1k ohm Resistor:

Figure 4 leds

Figure 5 resistor

7|P a g e
Working Explanation:

Working of this Project is very simple. A PIR sensor is used to detect

the presence of any person and a Pi Camera is used to capture the

images when the presence it detected.

Whenever anyone or intruder comes in range of PIR sensor, PIR Sensor

triggers the Pi Camera through Raspberry Pi. Raspberry pi sends

commands to Pi camera to click the picture and save it. After it,

Raspberry Pi creates a mail and sends it to the defined mail address

with recently clicked images. The mail contains a message and picture

of intruder as attachment. Here we have used the message “Please

find the attachment”, you can change it accordingly in the Code given

at the end.

Here the pictures are saved in Raspberry Pi with the name which itself

contains the time and date of entry. So that we can check the time

and date of intruder entry by just looking at the Picture name.

8|P a g e
Figure 6 example
Figure 7 example2

You can also adjust the detection range or distance of this system

using PIR sensor’s potentiometers.

Circuit Description:

In this Intruder Alert System, we only need to connect Pi Camera

module and PIR sensor to Raspberry Pi 3. Pi Camera is connected at

the camera slot of the Raspberry Pi and PIR is connected to GPIO pin

18. A LED is also connected to GPIO pin 17 through a 1k resistor.

9|P a g e
Figure 8 implementation

10 | P a g e
Raspberry Pi Configuration and Programming Explanation:

We are using Python language here for the Program. Before

coding, user needs to configure Raspberry Pi. After successfully

installing Raspbian OS on Raspberry Pi, we need to install Pi camera

library files for run this project in Raspberry pi. After it, user needs

to enable Raspberry Pi Camera by using Raspberry Pi Software

Configuration Tool (raspi-config). Then select Enable camera and

Enable it.

Figure 9 enabling cam

11 | P a g e
Then user needs to reboot Raspberry Pi, by issuing sudo reboot, so

that new setting can take. Now your Pi camera is ready to use.

Now after setting up the Pi Camera, we will install software for

sending the mail. Here we are using ssmtp which is an easy and good

solution for sending mail using command line or using Python Script.

We need to install two Libraries for sending mails using SMTP:

sudo apt-get install ssmtp

sudo apt-get install mailutils

After installing libraries, user needs to open ssmtp.conf file and edit

this configuration file as shown in the Picture below and then save

the file. To save and exit the file, Press ‘CTRL+x’, then ‘y’ and then

press ‘enter’. We can also test it by sending a test mail by issuing

below command, you shall get the mail on the mentioned email

address if everything is working fine:

echo "Hello User" | mail -s "Testing..." yourEmail@gmail.com

The Python Program of this project plays a very important role to

perform all the operations. First of all, we include required libraries

for email, initialize variables and define pins for PIR, LED and other

12 | P a g e
components. For sending simple email, smtplib is enough but if you

want to send mail in cleaner way with subject line, attachment etc.

then you need to use MIME (Multipurpose Internet Mail Extensions).

Then we have created def sendMail(data) function for sending mail.

Function def capture_image() is created to capture the image of

intruder with time and date. Then we initialized the Picamera with

some of its settings. And now in last, we have read PIR sensor output

and when its goes high Raspberry Pi calls

the capture_image() function to capture the image of intruder and

send a alert message with the picture of intruder as an attachment.

We have used sendmail() insdie capture_image() function for sending

the mail. So this how this Raspberry Pi Security System works, you can

also use Ultrasonic sensor or IR sensor to detect the presence of

burglar or intruder.

Here is the code for everything mentioned above:

13 | P a g e
CODE: mail['To'] = toaddr

import RPi.GPIO as gpio mail['Subject'] = "Attachment"

import picamera body = "Please find the attachment"

import time

led=17

import smtplib pir=18

from email.MIMEMultipart import HIGH=1

MIMEMultipart LOW=0

from email.MIMEText import gpio.setwarnings(False)


MIMEText
gpio.setmode(gpio.BCM)
from email.MIMEBase import
gpio.setup(led, gpio.OUT)
MIMEBase
#initialize GPIO Pin as outputs
from email import encoders
gpio.setup(pir, gpio.IN)
from email.mime.image import #initialize GPIO Pin as input
MIMEImage
data=""

fromaddr = "user@gmail.com"
def sendMail(data):
#change the email address
accordingly mail.attach(MIMEText(body,
'plain'))
toaddr = "userr@gmail.com"
print data

dat='%s.jpg'%data
mail = MIMEMultipart()
print dat

attachment = open(dat, 'rb')


mail['From'] = fromaddr

14 | P a g e
sendMail(data)
image=MIMEImage(attachment.read(
))
gpio.output(led , 0)
attachment.close()
camera = picamera.PiCamera()
mail.attach(image)
camera.rotation=180
server =
smtplib.SMTP('smtp.gmail.com', 587) camera.awb_mode= 'auto'

server.starttls() camera.brightness=55

server.login(fromaddr, "your while 1:

password") if gpio.input(pir)==1:

text = mail.as_string() gpio.output(led, HIGH)

server.sendmail(fromaddr, toaddr, capture_image()


text)
while(gpio.input(pir)==1):
server.quit()
time.sleep(1)

def capture_image():
else:
data=
gpio.output(led, LOW)
time.strftime("%d_%b_%Y|%H:%M:%S")
time.sleep(0.01)
camera.start_preview()

time.sleep(5)

print data

camera.capture('%s.jpg'%data)

camera.stop_preview()

time.sleep(1)

15 | P a g e
16 | P a g e

You might also like