Introduction: DIY Security Camera

Picture of DIY Security Camera

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 .

Step 1: Components You'll Need to Complete the Build

Picture of Components You'll Need to Complete the Build

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.

Step 2: Setting Up the Arduino Yun

Picture of Setting Up the Arduino Yun

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

Step 3: Connecting the PIR Sensor and Test

Picture of Connecting the PIR Sensor and Test

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.

Step 4: SSH Into the Arduino Yun

Picture of SSH Into the Arduino Yun

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

Step 5: Installing Fswebcam and Test Your Camera

Picture of Installing Fswebcam and Test Your Camera

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.

Step 6: Uploading Python Code Using FTP Client

Picture of Uploading Python Code Using FTP Client

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

Step 7: Upload the Sketch Attached to the Yun

Picture of Upload the Sketch Attached to the Yun

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.

Step 8: 3D Print the STL Files Attached

Picture of 3D Print the STL Files Attached

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

Step 9: 3D Print the STL Files Attached With Support

Picture of 3D Print the STL Files Attached With Support

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

Step 10: Putting It All Together

Picture of Putting It All Together

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.

Step 11: Installing It the Security Cam

Picture of Installing It the Security Cam

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.

Comments

SonikaJAnand (author)2015-07-02

Carmelito this looks fairly simple to make and would you know how much it cost. I like the feature that you get email alerts with picture. Great ible

Thanks for the comment .. Considering you can print the 3D printed parts at a library or a local maker space,it should cost around 100$ for the electronic components.

ReikoJ (author)2015-11-18

can we use an arduino uno r3 for this project?

PrimaA (author)2015-08-24

hi.. nice project.

is it possible if use Arduino UNO?

i have made human detection with PIR also. and i plan use pc for do image capturing to webcam. could you help me to explain more? how integrate between arduino to PC to take capture from webcam when motion is detected?

CarmelitoAndrade (author)PrimaA2015-08-24

Thanks for the comment ! I used the Arduino Yun here which has an USB port and also runs a version of linux,basically OpenWrt which has the advantage of hosting python programs.My suggestion would be to research on Arduino+Processing or post in the forms at https://www.instructables.com/community?categoryGroup=forums&category=tech

About This Instructable

26,783views

301favorites

License:

Bio: Born as a farmer , studied electronics ,working as a Consultant and a 3D printing enthusiast by night..
More by CarmelitoAndrade:BOSEbuild Speaker Beat CubeBOSEbuild Speaker Beats CubeIoT Globe
Add instructable to: