loading

NEW VERSION

https://www.instructables.com/id/New-Door-Cam/

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.

TESTED ON:

LINUX RASPBERRYPI 3.18.7+ #755

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:

m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))$}i

and change it to:

m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))}i

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

root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthUser=YOUREMAIL1@gmail.com # you can use one of two accounts created to send email
AuthPass=TheGmailPassword
FromLineOverride=YES
UseSTARTTLS=YES

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

OBSOLETE

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

$ nano ipchangecheck.sh

add this script:

#!/bin/bash
IPFILE=~/ipaddress
CURRENT_IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
if [ -f $IPFILE ]; then
KNOWN_IP=$(cat $IPFILE)
else
KNOWN_IP=
fi
if [ "$CURRENT_IP" != "$KNOWN_IP" ]; then
echo $CURRENT_IP > $IPFILE
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)
#hdmi_force_hotplug=1
#config_hdmi_boost=4
sdtv_mode=2
sdtv_aspect=2
overscan_left=24
overscan_right=24
overscan_top=16
overscan_bottom=40
disable_overscan=0
display_rotate=1

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
GND to PIN 39 GND

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:

#!/bin/bash
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

testsound.mp3

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:

http://RASPBERRYPI_IP_ADDRESS:YOURWEBCAMPORT

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:

http://YOUR_PUBLIC_IP:YOURWEBCAMPORT

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

http://YOURNOIPDOMAIN:YOURWEBCAMPORT

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.

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<br>Thank you
Only one usb webcam supported.<br>If you have an IP cam, you can manage it by Motion software.
<p>What OS did you use for the PI? Can you provide a link?</p><p>Thanks for sharing.</p>
<p>i'm currently using Debian Wheezy 3.12.35+ #730 with NOOBS. It's not the newest.</p><p>You can find new versions at the following link: </p><p><a href="http://www.raspberrypi.org/help/noobs-setup/" rel="nofollow">http://www.raspberrypi.org/help/noobs-setup/</a></p>
<p>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. </p>
<p>I would like to learn Arduino. It's one of my next targets.</p>
Can I have a final of the cost
<p>First reason of this project is: reuse.</p><p>Anyway, here are approx costs for brand new products:</p><p>RPI $35 - Power supply $5 - Relay $1,5 - PS3 Eye Toy $11 - PC speakers $8 - Monitor $25 - Jumpers and RCA cable $2 = $87,5</p>
<p>excellent instructable. Lots of useful information, and very well laid out. Congrats!</p>
<p>Thanks for sharing.</p><p>I have found this amazing free software too: </p><p><a href="https://github.com/ccrisan/motionPie/wiki" rel="nofollow">https://github.com/ccrisan/motionPie/wiki</a></p><p>It's better than a professional software!!</p>
<p>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 <a href="http://your_public_ip:YOURWEBCAMPORT/" rel="nofollow">http://YOUR_PUBLIC_IP:YOURWEBCAMPORT</a> You could put http://your_domain.net:Your_Webcam_Port.</p>
<p>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.</p><p>for example for noip.com you can use</p><p><a href="http://yourname.no" rel="nofollow">http://yourname.</a>dvrcam.info:yourwebcamport<br><br>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 <a href="http://www.dlinkddns.com" rel="nofollow"> www.dlinkddns.com </a> <br>2.2 afraid.org<br>read more at http://lifehacker.com/the-best-free-alternatives-to-dyndns-1561556205</p>
<p>or you can use duckdns.org and get it all for free! &lt;3 :D</p>
<p>i confirm what you are writing. I've got a NOIP domain completely for free from several months. </p>
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
<p>This is an excellent 'Instructable', thanks for taking the time. Gmail comms and Ipchangecheck are particularly helpful. </p>
<p>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...</p>
<p>Calme</p>
<p>Wow! Great surveillance kit. Have you caught any interesting footage with it yet?</p>
<p>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!</p>
<p>This is awesome! I've always wanted to build a little survalence camera build.</p>

About This Instructable

58,373views

768favorites

License:

More by Acmecorporation:New Door Cam RF Sheep Tracker - Keep your sheep in sight! TEMPO - The handy timer switch - Attiny85 & DS3231 RTC based ** V. 1.7 more features ** 
Add instructable to: