DIY Security Camera





Introduction: DIY Security Camera

About: Born as a farmer, studied electronics ,working as a Consultant and a 3D printing enthusiast by night..

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

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

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

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

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@

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

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

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

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

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

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

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

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

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.



    • Casting Contest

      Casting Contest
    • Planter Challenge

      Planter Challenge
    • Make it Move Contest

      Make it Move Contest

    We have a be nice policy.
    Please be positive and constructive.




    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

    1 reply

    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.


    - like the idea - would this be usable with - 1 pre-made case?, - 2 case cut from sheet acrylic?, - 3 wood case? - 4 sheet aluminum? - (I guess, camera is 'independent' of any case - 'cause I have no 3d printer) - and I'd prefer to hide it if at all possible. Like some matching material of the home/surround. --- Then, I want, and recommend to others (home and businesses) to mount a (hidden) camera at about chest high (and out at the curb/mailbox/cash register/entry-exit door) to capture faces -and- license plates outside the home or business.

    can we use an arduino uno r3 for this project?

    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?

    1 reply

    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