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




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

About: come visit me!



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

  • 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: http://elinux.org/RPi_USB_Webcams)
  • 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

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="http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz"> http://caspian.dotconf.net/menu/Software/SendEmai...</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/SSL.pm

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 YOUREMAIL1@gmail.com -t YOUREMAIL2@gmail.com -u "OBJECT" -m "MESSAGE TEXT" -xu YOUREMAIL1@gmail.com -xp YOURPASSWORD -o tls=yes -s smtp.gmail.com:587

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

AuthUser=YOUREMAIL1@gmail.com # 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 YOUREMAIL1@gmail.com -t YOUREMAIL1@gmail.com -u "Motion detected!" -m "http://"`curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`":8080" -xu YOUREMAIL1@gmail.com -xp YOURGMAILPSSWD -o tls=yes -s smtp.gmail.com:587 -a %f (OBSOLETE)

on_picture_save mpack -s "MOTION DETECTED!" %f YOUREMAIL1@gmail.com

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

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

on_movie_start sleep 10 && mpack -s "http://"`curl icanhazip.com`":8080" %f YOUREMAIL2@gmail.com

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 ipchangecheck.sh

add this script:

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

save and exit

$ chmod 700 ipchangecheck.sh

if you want to check every five minutes:

$ sudo nano /etc/crontab
*/5 * * * * pi bash /home/pi/ipchangecheck.sh

save and exit

Step 4: 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

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 monitor.sh

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/monitor.sh & mpg123 -m --gain 70 /home/pi/testsound.mp3 ;

change "--gain" value to increase volume.

save and exit

Step 6: 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

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.

Pi/e Day Contest

Participated in the
Pi/e Day Contest

Be the First to Share


    • Hot Glue Speed Challenge

      Hot Glue Speed Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Build a Tool Contest

      Build a Tool Contest



    2 years ago

    This is very awesome my friend keep up with the good work


    7 years ago

    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


    Reply 7 years ago

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


    7 years ago on Introduction

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

    Thanks for sharing.


    7 years ago on Introduction

    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.


    7 years ago

    Can I have a final of the cost


    Reply 7 years ago on Introduction

    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


    7 years ago on Introduction

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


    7 years ago on Introduction

    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 noip.com. 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 http://your_domain.net:Your_Webcam_Port.


    Reply 7 years ago on Introduction

    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 noip.com 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 www.dlinkddns.com
    2.2 afraid.org
    read more at http://lifehacker.com/the-best-free-alternatives-to-dyndns-1561556205


    Reply 7 years ago on Introduction

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


    Reply 7 years ago on Introduction

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


    7 years ago

    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


    7 years ago on Step 3

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


    7 years ago on Introduction

    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...


    7 years ago on Introduction

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