Home Security Email Alert System using Raspberry Pi




In this tutorial we will look at how to setup up your raspberry pi to take picture of the intruder who enters your home and send an email to you whenever you are not at your home.

Step 1: What You’ll Need

  1. Raspberry Pi running Raspbian
  2. USB Camera
  3. PIR Sensor
  4. USB Wi-Fi Module for internet access ( optional, if you connect your Ethernet cable for internet, USB Wi-Fi Module is not needed )
  5. Power Adapter to power the Rsapberry Pi

Step 2: Setting up your raspberry pi with Raspbian

First you need to install Raspbian on your micro sd card that you will be using in your Raspberry Pi.

You can download the latest image of Raspbian from Raspberry Pi website at:

http://www.raspberrypi.org/downloads/

You will need to use an image writing tool to install the image on your SD card. You can find the steps to do that at:

http://www.raspberrypi.org/documentation/installat…Home Security Email Alert System using Raspberry Pi

Step 3: Install OpenCV and Required Libraries

There are lots of methods to do this. But I would prefer using the simplest method that is available in OpenCV website at http://docs.opencv.org/doc/tutorials/introduction/…

Open the terminal of your raspberry pi and execute the following commands…

Install compiler

$ sudo apt-get install build-essential

Install required packages

$ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

Install optional packages

$ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

Now download OpenCV to wherever you want to compile the source.

$ mkdir xxx

$ cd xxx

$ git clone https://github.com/Itseez/opencv.git

Create and build directory and onfigure OpenCV with cmake. Don’t forget the .. part at the end of

$ cd OpenCV-2.4.*

$ mkdir build

$ cd build

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

Now compile it

$ make

And finally install OpenCV

$ sudo make install

Step 4: Python code

Use the attached Python code after editing the following lines

gmail_user = “[email protected]” #Sender email address

Enter your email address in the above line using which the Photo captured will be sent

gmail_pwd = “xxxx” #Sender email password

Enter the password of the sender email address

to = “[email protected]” #Receiver email address

Enter the email address to which the email with the picture captured will be sent…Home Security Email Alert System using Raspberry Pi schematic

Step 5: Make necessary connections and test the setup

Now connect the USB camera and PIR sensor to the Raspberry Pi.

Using three female-to-female jumper cables, you’ll need to connect each of the PIR sensor’s connectors to the appropriate pins on the Raspberry Pi.

Connect the top one labelled VCC on the PIR sensor to the 5V pin on the Raspberry Pi, connect the middle one labelled OUT to GPIO pin 4, and connect the bottom one labelled GND to a ground pin also marked GND.

Now you run the python code with sudo to check the setup. Whenever there is a movement it detected by the PIR sensor, an image is captured and email is set the to email address you entered as the receivers email address.

 

For more detail: Home Security Email Alert System using Raspberry Pi


© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top