Introduction: Old PC Accessories + Raspberry PI = DoorCam & Surveillance Kit **updated 2016**


This project has been made with old tech accessories that i don't use and was in a cardboard box stored in my basement flat.

Have you got an old webcam, a couple of PC audio speakers, a composite monitor ? If yes, you have to perform following instructions to create a complete surveillance kit, IOS and Android compatible.

Excluded cost of a Raspberry Pi, for this project i have spent only $2 to buy a relay. After assembled it, you'll have:

  • Door cam with automatic display switching on at motion detection;
  • Cloud photo and video storing;
  • IP camera stream on your mobile phone or PC browser;
  • Acoustic alerts activated by motion detection;
  • Automatic photo and video email sending.



Step 1: You Will Need

Picture of You Will Need
  • Raspberry PI B (this project is based on B+ model)
  • 5V Raspberry PI power supply
  • A couple of PC speakers
  • TV/Monitor with composite input and its power supply
  • 3.5mm jack to RCA A/V cable
  • Compatible webcam (see at:
  • Three female/female jumpers
  • Relay 1 channel 5V PIC ARM AVR DSP

To make something easy, my webcam is conencted directly to Raspberry PI usb port. To do this i have simply drilled the wall. Everything is connected directly to the LAN network to contain costs.

Step 2: How It Works

Picture of How It Works

My first need was to check who is outside my home door. To do this Raspberry PI has been programmed as follow:

at a motion detection in webcam area

  • turn on monitor for 40"
  • send email with snapshot & public IP URL
  • send email with timelapse video & public IP URL(*)
  • sound alert

obviously, snapshot and video are chronological order stored in your gmail messages.

when my public IP changes, system sends an email with updated IP.

(*) on IOS mobile devices video file can be played with Ace Player app.

Step 3: Initial Settings & Packages Installation

Initial settings

Create two GMAIL accounts, one for store jpeg files and one for mjpeg files.

On your RPI enable access directly to graphical interface:

$ sudo raspi-config

choose option:

Desktop Log in as user 'pi' at the graphical desktop

Then reboot.

Install sendEmail (OBSOLETE)

Download sendEmail tar file:

$ wget <a href=""></a>

extract it:

$ tar -zxvf sendEmail-v1.56.tar.gz

copy to correct path:

$ sudo cp -a sendEmail-v1.56/sendEmail /usr/local/bin

make it executable

$ chmod +x /usr/local/bin/sendEmail

Install TLS support for Gmail (OBSOLETE)

$ sudo apt-get install libnet-ssleay-perl libio-socket-ssl-perl

after installing, change it as follow:

$ sudo nano /usr/share/perl5/IO/Socket/

with CTRL-W find the line with this argument:


and change it to:


save and exit

try to send an email with the command line:

$ sendEmail -f -t -u "OBJECT" -m "MESSAGE TEXT" -xu -xp YOURPASSWORD -o tls=yes -s

Install SSMTP

$ sudo apt-get update<strong><br></strong>
$ sudo apt-get install ssmtp<br>
$ sudo apt-get install mailutils

now edit SSMTP config file

$ sudo nano /etc/ssmtp/ssmtp.conf

add or modify extistings lines

hostname=raspberrypi # you can use one of two accounts created to send email

Save and exit

$ sudo apt-get install mpack

Install Chromium Browser

$ sudo apt-get install chromium-browser 

set now Chromium browser autostart kiosk mode:

$ sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

(if you haven't NOOBS : sudo nano /etc/xdg/lxsession/LXDE/autostart)

#@lxpanel --profile LXDE
#@pcmanfm --desktop --profile LXDE
#@xscreensaver -no-splash
# auto run the browser
@xset s off@xset -dpms
@xset s noblank
@chromium --kiosk --enable-kiosk-mode --enabled --touch-events --touch-events-ui --disable-ipv6 --allow-file-access-from-files --disable-java --disable-restore-session-state --disable-sync --disable-translate --disk-cache-size=1 --media-cache-size=1 http://localhost:YOURWEBCAMPORT

now reboot

Install MP3 PLAYER

$ sudo apt-get install mpg123

Install Motion

$ sudo apt-get install motion

modify configuration file:

$ sudo nano /etc/motion/motion.conf

Basically, i've changed these options:

#start as
daemon on
# Rotate image
rotate 90 (my webcam is 270° rotated)
# Image width
width 640 (check your webcam resolution)
# Image height
height 480 (check your webcam resolution)
# Maximum number of frames
framerate 2
# Threshold
threshold 15000
# Picture frames must contain motion
minimum_motion_frames 2
# Specifies the number of pre-captured
pre_capture 5
# Codec to used by ffmpeg for the video compression
ffmpeg_video_codec mpeg4
# The mini-http server listens
webcam_port 8080 (selected your preferred port)
# TCP/IP port for the http server to listen on
control_port 8081 (select different port by webcam port)
# Restrict webcam connections to localhost only
webcam_localhost off
# Command to be executed when an event starts.
on_event_start mpg123 -m --gain 70 /home/pi/testsound.mp3 ;
# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)
on_picture_save sendEmail -f -t -u "Motion detected!" -m "http://"`curl -s|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`":8080" -xu -xp YOURGMAILPSSWD -o tls=yes -s -a %f (OBSOLETE)

on_picture_save mpack -s "MOTION DETECTED!" %f

# Command to be executed when a movie file (.mpg|.avi) is created.

on_movie_start sendEmail -f -t -u "Motion timelapse" -m "http://"`curl -s|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`":8080" -xu -xp YOURGMAILPSSWD -o tls=yes -s -a %f (OBSOLETE)

on_movie_start sleep 10 && mpack -s "http://"`curl`":8080" %f

Final settings

add following lines at rc.local file:

$ sudo nano /etc/rc.local

before "exit" add:

sudo mkdir /var/run/motion
sudo chmod a+rwxt /var/run/motion
sudo motion
sleep 60

save and exit


create now a script that check if public IP has been changed (OBSOLETE)

$ nano

add this script:

CURRENT_IP=$(curl -s | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
if [ -f $IPFILE ]; then
if [ "$CURRENT_IP" != "$KNOWN_IP" ]; then
sendEmail -f -t -u "your IP is changed!" -m $CURRENT_IP -xu -xp YOURGMAILPASSWORD -o tls=yes -s

save and exit

$ chmod 700

if you want to check every five minutes:

$ sudo nano /etc/crontab
*/5 * * * * pi bash /home/pi/

save and exit

Step 4: Composite TV/Monitor

Picture of Composite TV/Monitor

Change video output configuration file as follow( using NOOBS Configuration):

$ sudo nano /boot/config.txt
# NOOBS Auto-generated Settings: (i'm using PAL composite monitor 270° rotated)

save, exit and reboot.

Step 5: Relay

Picture of Relay

To automate your composite monitor startup, you have to check if your display can do this option.

Turn it on, unplugs the power, re-plugs and then check if it turn automatically on. If yes, you can proceed with this step.

Connect display as show on image.

Relay to Raspberry PI

VCC to PIN 1 3.3volts
IN1 to PIN 15 GPIO 22

12V DC to Relay

cut your positive cable and connect one end at COM relay port and the other to NC (normally closed) relay port

now in your terminal:

$ sudo nano /etc/rc.local

add these lines before "exit 0"

sudo echo "22" > /sys/class/gpio/export
sudo echo "out" > /sys/class/gpio/gpio22/direction
sudo echo "1" > /sys/class/gpio/gpio22/value

save & exit

create following script in your home directory:

$ nano

then add:

sudo echo "0" > /sys/class/gpio/gpio22/value
sleep 40
sudo echo "1" > /sys/class/gpio/gpio22/value

save and exit

with this script, after modified Motion configuration file as below, when a motion detection event starts, your display turn on for 40 seconds. Then power off. Change "sleep" value at your needs.

Modify Motion configuration file for this step:

$  sudo nano /etc/motion/motion.conf

at the line:

# Command to be executed when an event starts.
on_event_start mpg123 -m --gain 30 /home/pi/testsound.mp3 ;

change as follow:

on_event_start bash /home/pi/ & mpg123 -m --gain 70 /home/pi/testsound.mp3 ;

change "--gain" value to increase volume.

save and exit

Step 6: Audio

Picture of Audio

A word about audio. I've connected two PC audio speakers to RPi. My idea was to create two different situations:

1. when we are at home

2. when we are out for holiday

in the first case i use a Geiger counter audio file that alert me if there is some moving detection outside the home door. In the second case i use a Neapolitan mastiff bark sound alert, with increased volume, to deter "unwanted people".

Save your file inside your home directory under the name


Step 7: Door Cam on Browser

To view your webcam from a PC inside your domestic net, you have to use Firefox or Safari browsers just typing the URL:


It seems work on Ipad too. Open Safari with above mentioned URL and, if image freeze, try reloading the page.

If you want to view from outside your domestic net, you need to open the relating port on your modem. I cannot explain how can do because each modem brand has different parameters to set. When you have open modem port, from outside your domestic net, you can simply type the URL in Firefox or Safari browsers:


My TP-Link modem support dinamic DNS service NOIP (FREE) and, once you are registered to that, you'll be able to access to your webcam from outside your domestic net, just typing domain name given by NOIP always adding


Step 8: Door Cam on Your Mobile Phone

Picture of Door Cam on Your Mobile Phone

Opening modem port is useful to view your webcam over your domestic net.

For this feature, on IOS, i can use two different apps available on APP Store for free.

The fisrt one that i prefer is Cu4GE and, in the first image, you find parameter settings.

The second Monitor Bee. In the second image you can see parameters.

On Android OS exists an easy app named Mjpeviewer.

Free and very easy, only URL:PORT adding needed.

Step 9: Final Considerations

Following this project step by step, you can see that it's very easy.

Thank you in advance and sorry for my poor English.


zmahimi (author)2015-06-29

Great project, just had one question, is there by any chance can i connect more than one camera for just for surveilliance purpose, no motion detection needed
Thank you

Acmecorporation (author)zmahimi2015-06-29

Only one usb webcam supported.
If you have an IP cam, you can manage it by Motion software.

F22-Raptor (author)2015-03-23

What OS did you use for the PI? Can you provide a link?

Thanks for sharing.

i'm currently using Debian Wheezy 3.12.35+ #730 with NOOBS. It's not the newest.

You can find new versions at the following link:

rondacosta (author)2015-03-23

Great instructable. My question is primarily for other posters perhaps. Does anyone know of a similar project done with an Arduino? I am talking about the video surveillance part as it may not have all the e-communication capabilities that the RPi has.

I would like to learn Arduino. It's one of my next targets.

Egindy (author)2015-03-22

Can I have a final of the cost

Acmecorporation (author)Egindy2015-03-23

First reason of this project is: reuse.

Anyway, here are approx costs for brand new products:

RPI $35 - Power supply $5 - Relay $1,5 - PS3 Eye Toy $11 - PC speakers $8 - Monitor $25 - Jumpers and RCA cable $2 = $87,5

Bverysharp (author)2015-03-23

excellent instructable. Lots of useful information, and very well laid out. Congrats!

anjoze (author)2015-03-23

Thanks for sharing.

I have found this amazing free software too:

It's better than a professional software!!

xotan135 (author)2015-03-19

This is really awesome!! Another thing that you might look at doing is purchase a cheap domain name of your choosing. Most cheap ones can be gotten for 3 bucks a year. You then go register with Its a free dynamic DNS service. It will eliminate the need for you to send an email everytime your public IP changes. Then instead of http://YOUR_PUBLIC_IP:YOURWEBCAMPORT You could put

leonidk (author)xotan1352015-03-23

1. No need to buy domain. your can use existing domains and create your 3rd level domain, which you can choose from big list of domains.

for example for you can use

2. Try to find free alternatives with dynamic dns with 3rd level domains. for example 2.1 if you have d-link at home you can use

hpdobrica (author)xotan1352015-03-22

or you can use and get it all for free! <3 :D

Acmecorporation (author)xotan1352015-03-19

i confirm what you are writing. I've got a NOIP domain completely for free from several months.

soundlounger (author)2015-03-22

What are you talking about dude. Your English and grammar is better than most native English speaking people I'm friends with. Awesome project. Thank you for sharing

jwilker2 (author)2015-03-22

This is an excellent 'Instructable', thanks for taking the time. Gmail comms and Ipchangecheck are particularly helpful.

mark_sprague (author)2015-03-22

I made something like it, I didn't have the relay...I put it on a solar powered battery and call it my portaPi! Nice 'able...

berserkyard (author)2015-03-20


amberrayh (author)2015-03-18

Wow! Great surveillance kit. Have you caught any interesting footage with it yet?

Thanks for your comment. A lot of footages are stored on the dedicated Gmail account, it has been working for almost a year . Till now (fortunately) no thieves, kidnappers or terrorists have knocked my door!

tomatoskins (author)2015-03-18

This is awesome! I've always wanted to build a little survalence camera build.