loading

One of my first Instructables was a sourveillance kit Raspberry Pi based

https://www.instructables.com/id/Old-PC-Accessories-Raspberry-PI-DoorCam-surveillan/

I'm now back with an update that changes the form not the substance.

It's a WIFI door cam with the following features:

  • TFT shield to show who's at the door
  • automat LED lighting
  • camera stream on mobile and desktop browsers (Firefox, Safari, Chrome)
  • email alert with snapshot attached
  • audio motion alert on a remote Raspberry Pi client

For this project, it was very important to reuse a battery spotlight found inside my unused stuff box. It is a OSRAM DOT-IT battery spotlight (with an inappropriate colour!).

This project also include my first Instructables https://www.instructables.com/id/LEGOLED/ , but it can be easly replaced by a portable speaker.

Step 1: Parts Needed

Raspberry Pi B+

Raspberry Pi with speaker (remote) or portable speaker (built-in)

Protective case

Micro SD 8GB

5V 2A power supply

WiFi dongle

Raspberry Pi Camera+flat cable

TFT shied

F/F jumpers

1KOhm resistor

general purpose NPN transistor TIP120 (or similar)

pcb scrap

Osram Dot It

Single Row Male 90 Degree Right Angle 3 Pin Header

5 x small screws

2 x 2cm screws

thin carton pressed sheet

Tools:

Solder

Dremel

Drill

Screwdriver

Step 2: How It Works

At system starts, Web camera interface run in background and let you able to watch camera stream on a remote device, mobile phone or remote desktop PC.

When motion is detected, TFT and camera led lights turns on so you can watch on Raspberry Pi display who's at the door. At the same time starts a command to a remote Raspberry Pi (or to portable speaker) to activate an acustic alert. A snapshot is stored inside SD card and starts video recording.

When motion detect ends, the snapshot is sent by email to your favourite address, video recording ends and is stored inside SD card, TFT and outside led lights turns off.

My configuration provides that the acoustic alert is played by the project LEGOLED that is on at all times inside my house main room, but New Door Cam can be implemented with a speaker module or a common portable speaker.

Step 3: DOT IT Hack

Digging through some unused things i've found what really is needed for this project.

Removing some plastics and part of the electronic circuit i've otained something that was perfectly made for my purpose. As you can see in the last photos, two holes are devotes to leds and one to camera lens.

The original spotlight circuit consists in three white leds and a pushbutton. One of three led and pushbutton have been removed.

Removing pushbutton implies that led ground will be permanently disconnected, so i've soldered a jumper as showed in photo.

A small circuit added consist of a general purpose NPN transistor and a resistor to drives the leds.

I've added also three layers of thin pressed cardboard to increase basement thickness, then i've created a slot for camera and led cables.

The small led drive circuit has three pins: +5V, signal, GND. Connect signal pin to PIN 40, GND to PIN 39 and +5V to PIN 2.

DOT IT is finally screwed outside the door with two 2cm, at least, screws and i've also placed two small screws on the outer edges to ensure DOT-IT frame.

Green cable to to PIN 40, GND to PIN 39, POSITIVE to PIN 2

Step 4: System Setup

Prerequisites:

Raspbian GNU/Linux 7 (wheezy)

WIFI dongle and TFT (*) module already installed and configured.

Set static IP on Raspberry, a lot of tutorial shows how to do it.

Launch sudo raspi-config and:

  • enable deskotp as user pi
  • expand filesystem
  • enable pi camera

then reboot

now:

sudo apt-get update

and

sudo apt-get dist-upgrade

sudo apt-get install chromium-browser

Once you launch chromium, a preference (inside /home/pi/config/chromium/Default) file is created. Inside the file there needs to set correct zoom to fit video stream on TFT display. It needs to be added after "per_host_zoom_levels"

My configuration is: "localhost": -0.55, also showed into Preferences file attached

If you have a different TFT size, feel free do modify it.

Remember that, to modify Chromium Preferences file you must first close the browser.

Now launch:

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

and modify file as follow:

#@lxpanel --profile LXDE
#@pcmanfm --desktop --profile LXDE
#@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@chromium --noerrdialogs --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:80/index.php




(*) based on a 3.5 inch TFT 480x320

Step 5: Web Camera Interface

It's time to install the main program. Thanks to silvanmelchior user for this very good web interface.

git clone  https://github.com/silvanmelchior/RPi_Cam_Web_Int...
cd RPi_Cam_Web_Interface
chmod u+x RPi_Cam_Web_Interface_Installer.sh
./RPi_Cam_Web_Interface_Installer.sh install

then configure webserver password and port.

Inside the file /etc/raspimjpeg change value as follow:

  • motion_detection true
  • motion_external false #(i'd rather internal motion detection)

Internal motion detection adopt macros to launch activities. I've created two macros, one at video recording starts, ona at recording ends. These two macros write 1 or 0 inside a txt file, depend from video recording activity. Then this file is periodically read by a python script as explained in the step 7.

sudo nano /var/www/macros/start_vid.sh

add

echo "1" >/var/www/testmacro.txt

exit, save and give permissions as follow

sudo chmod 777 /var/www/macros/start_vid.sh
sudo chown www-data:www-data /var/www/macros/start_vid.sh

This is second macro:

sudo nano /var/www/macros/end_vid.sh

add

echo "0" >/var/ww/testmacro.txt

exit, save and give permissions as follow

sudo chmod 777 /var/www/macros/end_vid.sh
sudo chown www-data:www-data /var/www/macros/end_vid.sh

Photo shows my motion and scheduling configurations.

I've also make some changing inside /var/www/index.php file to fit web page on TFT screen.

Rename file "index" to "index.php" and paste into /var/www directory.

Step 6: Acustic Alert

As said, when motion is detected an alert sound is played on a remote Raspberry Pi device. This can easly optained using SSH client, SSHPASS on New Door Cam and MPG123 player on the remote Raspberry Pi device. If you want connect a speaker directly to Raspberry Pi headphone plug, you need only to install MPG123 player on New Door Cam device.

sudo apt-get install sshpass

assuming that on the remote device is already installed MPG123 and there's example.mp3 file into pi directory, try it launching:

sshpass -p REMOTERPIPASSWORD ssh pi@REMOTEIPADDRESS -p22 mpg123 -m /home/pi/example.mp3

if it works, go ahead.

For a New Door Cam with built-in speaker install only:

sudo apt-get install mpg123

other changes will be showed in the next steps

Step 7: What Macros Does

Files attached to be copied into /home/pi directory

The file newDC.py handles :

  • turning on/off TFT screen
  • send email with snapshot at motion ending
  • send ssh command to activate acustic alert to the remote Raspberry Pi (*)

add your parameters to

  • fromaddr = email address sender
  • toaddr = email address receiver
  • server.login(fromaddr, "YOURPASSWORD") = email password
  • os.system("sshpass -p 'REMOTERPI_PASSWORD' ssh pi@IP_REMOTERPI -p22 mpg123 -m /home/pi/example.mp3") = remote Raspberry Pi IP and password

The file led.py handles leds turning on/off

Give permissions to these files:

sudo chmod 777 /home/pi/led.py
sudo chmod 777 /home/pi/newDC.py

for autorun:

crontab -e

add

@reboot sudo python /home/pi/led.py
@reboot python /home/pi/newDC.py

(*) for a built in speaker change line inside file newDC.py as follow:

os.system("sshpass -p 'REMOTERPI_PASSWORD' ssh pi@IP_REMOTERPI -p22 mpg123 -m /home/pi/example.mp3")

to

os.system("mpg123 -m /home/pi/example.mp3")

P.S. at seveth line of the file newDC.py has been considered that TFT display value is ":0"

Check your display value using command line

echo $DISPLAY

Step 8: WIFI Troubleshooting

Sometimes could appens that Raspberry Pi loses WIFI connection.

At specific interval wifi_rebooter.sh file check if there's connection between Raspberry Pi and Google DNS server. If not, it stop and start wireless interface to try reconnecting.

Copy the file into /home/pi directory, rename to wifi_rebooter.sh and give permissions:

sudo chmod 0644 /home/pi/wifi_rebooter.sh

after that, set checking time in crontab

crontab -e

add

*/10 * * * * sudo bash /home/pi/wifi_rebooter.sh >/dev/null

this command check connection every 10 minutes

Step 9: Modem Configuration

To watch video stream and control webcam from outside your network, you have to open port on your modem.

Normally you have to open port 80 for TCP protocol. After that you'll be able to watch stream writing following URL

http://YOURPUBLICIP:80/index.php

If would be good having a static IP or a DDNS address.

Step 10: Final Considerations

My first Door Cam instructables was a success for me. After more than a year, it still interest Instructables community.

I hope this instructables will do the same.

The next step is to change Raspberry Pi camera (the one used to test is a NOIR)

Shortly i'll develope new version that will include:

  • external pushbutton to emulate various doorbell sounds
  • sounds played on a remote speaker using Bluetooth technology

Bye

<p>Cool </p>
<p>I should make this and combine it with my digital doormat</p>

About This Instructable

3,858views

74favorites

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: