DIY Security Camera

by CJA3D in Circuits > Arduino

73204 Views, 328 Favorites, 0 Comments

DIY Security Camera

5591509450e1b6956a00053d.jpeg
559177f12e7fb629110002fb.jpeg
Screen Shot 2015-06-29 at 12.55.18 PM copy.png

This instructable show you how build your own DIY Security Camera, which takes a picture of the person at the door and send an email with the picture to your email box, so that you'll know if it's some you know or its an intruder..

The DIY Security Camera uses

  • an Arduino Yun as it's brain, which is connected to your home WiFi network
  • a PIR sensor to detect some one approaching the door
  • and a USB webcam to take a picture which is then send in an email
  • In addition 3D Print the enclosure using the STL files attached and to house the electronic components .

Components You'll Need to Complete the Build

IMG_7285.JPG
5591787d45bceb08a4000095.jpeg
IMG_7287.JPG

Here are the electronics components you'll need

  • Arduino Yun
  • PIR sensor, in my case i am using one which I purchased at Radioshack
  • LED to aid in testing
  • *USB web cam(i am using Logitech c270 webcam)
  • Female to male breading boarding wire
  • Micro SD card
  • Micro B USB cable

3D printer to print the STL files attached , in my case I am using

  • Printrbot Simple Metal
  • Hatchbox 1.75mm black PLA

In addition you'll also need the

  • Pliers
  • Screw drivers
  • Screws - (6-32 X 1/2 in (at least 5) and 6-32 X 1 in(at least 4))
  • Mount mechanism to mount the camera , in my case i am using a simple door hinge.

Note*: To check if your USB Webcam will be compatible check the following Wiki link ,i am using Logitech c270 webcam.

Setting Up the Arduino Yun

Screen Shot 2015-06-24 at 5.40.04 PM.png
Screen Shot 2015-06-24 at 5.43.20 PM copy.png
Screen Shot 2015-06-24 at 5.43.29 PM.png

To get started, configure the onboard WiFi on the Arduino Yun using the following steps

- Connect the Micro USB able to a power outlet or your computer USB.

- Connect your computer to the Yun's Wifi , in the Wifi setting of your computer , basically once you power up the Yun in a few second you should see Wifi called "ArduinoYun-XXXXXXXXXXXX" in your network setting .

- Using a browser enter http://yun.local as shown in the picture above

- A web should display asking you for the password , here enter "arduino"

- Now a configure button will appear

- Once you hit the configure, select your WiFi router name and enter the password as shown in the second screen shot above

- Now you may choose to change your Arduino Yun name, password and play around with the other setting.

- Once done hit the Configure and Restart button, this will connect your Yun to your home WiFi.

For more details refer to the guide on the Arduino website at the following link

https://www.arduino.cc/en/Guide/ArduinoYun#toc9

Connecting the PIR Sensor and Test

IMG_7267.JPG
Screen Shot 2015-06-28 at 5.00.55 PM.png
Screen Shot 2015-06-28 at 4.55.55 PM.png

Now to Upload sketches to the Yun you will need the latest version on the Arduino IDE, basically Arduino IDE 1.5.4 installer or later.

Connect the PIR sensor to the Arduino Yun

  • Connect VCC on the PIR to 5V
  • GND to GND
  • And Out on the PIR to pin#2 on the Yun
  • In addtion connect an LED to PIN 13 , so that you can see it from far away while testing

Download the Basic PIR testing sketch and upload it to the Yun. Before hitting the upload button in the board section select Arduino Yun as shown in the second screen shot.

SSH Into the Arduino Yun

5590ae83deafa434f70002e0.jpeg
Screen Shot 2015-06-29 at 12.40.41 AM.png

SSH into you Arduino Yun using the Terminal on your Mac, or using a tool like Putty if you are using a windows machine

ssh root@yun.local

Note: if you are not able to resolve the IP for yun.local, find out the IP address of your Yun and use the IP address instead (like ssh root@192.168.1.8)

Accept the RSA key by typing in Yes

Now you can run a few of your favorite shell commands like ls,df etc..

For more details on using command line communication using SSH refer the following link

https://www.arduino.cc/en/Tutorial/LinuxCLI

Installing Fswebcam and Test Your Camera

IMG_7271.JPG
Screen Shot 2015-06-29 at 12.48.26 AM copy.png

Connect the Yun to the USB webcam and insert the micro SD card.

Now at the SSH prompt of your Yun type in the following command to install the fswebcam package which will help us take pictures

start with updating the package manager

opkg update

install the UVC drivers for the webcam

opkg install kmod-video-uvcfinally 

install the fswebcam utility

opkg install fswebcam

Now to take a picture , you'll have to first mount the SD card

cd /mnt/sda1

to take a picture

fswebcam PicturefromWebCam.png

to check if the picture was taken

ls -l

Note*: To check if your USB Webcam will be compatible check the following Wiki link ,i am using Logitech c270 webcam.

Uploading Python Code Using FTP Client

FTP-openSHH-blog.png
Screen Shot 2015-06-24 at 5.48.08 PM.png
filezillaoptions.png

To access the files and upload python code to your Arduino Yun's SD card, you can use a FTP client like FileZilla ,WinSCP.

Start by installing SFTP server on your Yun using the following commands

opkg update
opkg install vsftpd openssh-sftp-server<br>

Now download and install an FTP client like FileZilla from https://filezilla-project.org/

Once installed open FileZilla and go to File --> Site Manager -->click on New Site.

  • Enter the following detailsHost : Protocol: select SFTP
  • Logon Type: select Normal
  • User: root
  • Password: xxxxxxxx

Note: the default password is arduino, if you have not reset it as part of the setup process

Click the connect button which will take you to the main screen, where you can access the root folder as shown in the picture above , in my case I using the SD card from my Camera, because of which you see quite a few folders.

For more features refer to the FileZilla wiki

Upload the Sketch Attached to the Yun

IMG_7270.JPG
Screen Shot 2015-06-29 at 3.06.48 AM.png
Screen Shot 2015-06-29 at 3.06.28 AM.png
55915281937ddbe19a0005a4.jpeg

Download the Sketch attached and Upload it to the Arduino Yun via the USB cable.

And since the Yun is connected to WiFi you can also upload the sketches via Wifi.

Now once motion is detected you''ll receive an email as shown in the screen shot above , with the picture taken by the web cam.

Note : To upload sketches to the Arduino Yun you will need the latest version on the Arduino IDE, basically Arduino IDE 1.5.4 installer or later.

3D Print the STL Files Attached

IMG_7280.JPG
IMG_7262.JPG
Screen Shot 2015-06-28 at 3.57.40 PM.png
IMG_7261.JPG
IMG_7252.JPG

Download the STL file attached and load it in your printer software and slice the file, based on your printer setting,the webcam Holder

  • Slicing the STL file should take about 8-9 Seconds
  • And the print time should be about 10- 15 mins

3D print the fake Antena

  • Slicing the STL file should take about 5-6 Seconds
  • And the print time should be about 12- 15 mins

Download and 3D print the from of the security camera which holds the PIR sensor and webcam

  • Slicing the STL file should take about 4-5 Seconds
  • And the print time should be about 25-30 mins

In addition I wanted to give a shout out francisperea who create and awesome bare minimum bumper case(YunCase.stl) which you can find at : Arduino Yún Bumper - created by francisperea

In my case I am using the Printrbot Simple Metal and Hatchbox black 1.75 mm PLA

3D Print the STL Files Attached With Support

IMG_7278.JPG
IMG_7246.JPG
Screen Shot 2015-06-28 at 4.15.06 PM.png
IMG_7259.JPG

Now to 3D print these parts you'll have to change the slicer setting to print with support as shown in the second picture above.

3D print the Bottom Yun holder

  • Slicing the STL file should take about 25-30 Seconds
  • And the print time should be about 55- 60 mins

Download and 3D print the top case

  • Slicing the STL file should take about 20-25 Seconds
  • And the print time should be about 45- 50 mins

Putting It All Together

IMG_7292.JPG
IMG_7296.JPG
IMG_7332.JPG
IMG_7300.JPG
IMG_7304.JPG
IMG_7324.JPG

Now once you have 3D printed your part putting the electronic components together is pretty self explanatory

Attach the Yun to the bumper and added it to the bottom part of the case using screws

Attach the PIR sensor to the front 3D printed part using the longer screws and nuts.

Complete the circuit using bread boarding wire, here

  • Connect VCC on the PIR to 5V
  • GND to GND
  • And Out on the PIR to pin#2 on the Yun

Now add a screw to the webcam holder and snap it to the webcam and then attach it to the top case using a nut.

Now attach the fake Antenna using a screw and neatly tuck the web cam wire.

Installing It the Security Cam

IMG_7326.JPG
IMG_7339.JPG
IMG_7368.JPG
IMG_7349.JPG

The 3D printed case has two mounting options, one using a hinge type mechanism at the top of the housing and the second is for a swirl type mechanism at the bottom.

I am plan on using the hinge type mechanism which is simple of the two, which fits perfectly on back door.

A tip here when selecting the mechanism is to take the 3D printed part with you to the hardware store like a Home Depot and select the mechanism that suit your mounting point for the DIY security camera.

And in addition since the Arduino Yun is powered by a USB cable you'll have to find a way to tunnel your USB cable to power socket.