How to Make a £59 Fully Featured Raspberry Pi Home Security Camera – Newbie Guide

This tutorial will explain how to create your own CCTV IP Webcam using a Raspberry Pi Zero Wireless £9 computer!

It uses the excellent RPi Web Cam Interface open source software, which offers a near real-time live video stream via a web interface for the Raspberry Pi camera module, as well as motion detection video recording.

It can be used for a wide variety of applications including surveillance, dvr recording and time lapse photography. It is highly configurable and can be extended with the use of macro scripts. It can be opened on any browser (smartphones included) and contains the following features:

  • View, stop and restart a live-preview with low latency and high framerate. Full sensor area available.
  • Control camera settings like brightness, contrast, … live
  • Record full-hd videos and save them on the sd-card packed into mp4 container while the live-preview continues
  • Do timed or continuous video recording with splitting into fixed length segments
  • Take single or multiple (timelapse) full-res pictures and save them on the sd-card (live-preview holds on for a short moment)
  • Preview, download and delete the saved videos and pictures, zip-download for multiple files
  • Trigger captures by motion detection using internal or external detection processes.
  • Trigger captures by many scheduling-possibilities
  • Circular buffer to capture actions leading up to motion detection
  • Control Pan-Tilt or Pi-Light
  • Shutdown/Reboot your Pi from the web interface
  • Show annotations (eg timestamp) on live-preview and taken images/videos
  • Supports selection from 2 cameras when used with a compute module

The software is fully functional with a Pi Zero Wireless, offering a small footprint that operates over wifi and only requires a power source.

The example here uses a 160 degree fisheye camera module that gives a much better field of view than the standard official camera (and is fully compatible). If you don’t need a better viewing angle, the official Pi Zero case fully integrates the official camera into a very neat little package!

You can also buy a 160 degree fisheye IR (infrared) camera that comes with IR LED lights which are powered and attached to the camera board. There are also many more camera options at Modmypi, such as a 222 degree fisheye, and an IR on/off camera.

SHOPPING LIST

Total: £59.54

INSTALLING THE SOFTWARE

Write an Image onto the SD Card
We will be using the lite version of Raspberry Pi’s official operating system as the base for our security camera.

  1. Download RASPBIAN JESSIE LITE from
    https://www.raspberrypi.org/downloads/raspbian/

    Screen Shot 2017-07-01 at 17.17.55 v2

  2. Download Etcher which we will use to burn the image to an SD card (this supports Windows, OSX, and Linux, and is really easy to use):
    https://etcher.io

    Screen Shot 2017-07-01 at 17.18.41

  3. Insert your microSDXC card into your computer
  4. Run Etcher and press the Select Image button
    Screen Shot 2017-07-01 at 17.19.42

  5. Find your previously saved 2017-06-21-raspbian-jessie-lite.zip file from step 1 (or whichever version is the latest)
    Screen Shot 2017-07-01 at 17.21.26

  6. Your SD card may already be automatically detected, but if not press the Change link to select the card.
  7. Press the Flash button
    Screen Shot 2017-07-01 at 17.29.06

  8. Once finished, Etcher will automatically unmount the SD card. However, remove and plug the card back in so that we can copy some files to the SD card.
  9. Given that the Pi Zero W has limited ports, performing an initial configuration such as connecting to wifi or enabling SSH would require a keyboard and monitor. This can be avoided by putting two text files in the top-level directory of the SD card, one to enable SSH and the other to set up wifi by including details within the text file.
    1. The inserted SD card should be labelled boot and contain files called bootcode.bin, config.txt, etc.
    2. Create a new text file in the same location as the previously mentioned files called “ssh”. Note that it’s not called ssh.txt, and obviously don’t include the quotes (“”). This text file can be empty as it’s just the file name which enables ssh.
    3. Create another new text file called “wpa_supplicant.conf”. This file does need some information contained within, so open the file with a text editor such as notepad. Paste in the following lines of text and update the ssid and psk lines with your local wifi details.
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      country=GB
      network={
      	ssid="enter_your_wifi_name_here"
      	psk="enter_your_wifi_password_here"
      	key_mgmt=WPA-PSK
      }
    4. Your SD card should now have the above two mentioned files as seen below. Once you’ve finished, properly eject the SD card from your computer.
      Screen Shot 2017-07-01 at 18.25.25
  10. Put your SD card into the Pi Zero and then assemble the ribbon cable, case, and camera. Don’t power the Pi on just yet though…

    Determine the IP address

  11. When the Pi powers up, it will obtain an IP address automatically from your router. You will want to know what this IP is, but unless you plug in your Pi to a monitor (which is an option via the HDMI port), you need to determine the IP another way. This is where a very useful local network scanning utility called Fing comes in. Fing is an iOS or Android app that will show you all devices on your network and their IP address.
    1. Download Fing from the Appstore (or find more details from their website https://www.fing.io/)
    2. Run Fing and let it scan your network. If you already have any Raspberry Pi devices, make a note of their IP so you can discount them when you turn the Pi on.
    3. Turn on your Raspberry Pi Zero and give it 3 or so mins to boot.
    4. Scan your network using Fing again, and all being well you should hopefully see a new Raspberry Pi entry with it’s IP address! The hostname will be called “raspberrypi”
    5. If a new IP doesn’t appear, double check your wifi settings by inserting the SD card back into your computer and looking at or editing wpa_supplicant.conf. If that method still doesn’t work, plug the Pi into your monitor or TV via the HDMI port (you may need a mini to normal HDMI converter).
  12. If you’re using Windows, you will need a way to SSH to your Pi for remote access to install the software. Download Putty (putty-64bit-0.69-installer.msi) from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html and install. If you’re using macOS, just open Terminal (press cmd+space and type in Terminal to find it).
    1. For Putty instructions, please follow this guide:
      https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md
    2. For macOS, at the terminal simply type (replacing 192.168.0.2 with your Pi’s IP address).
      ssh pi@192.168.0.2
    3. The default password is raspberry
  13. You should now be at your Pi’s command prompt:
    pi@raspberrypi:~ $

    Update the Pi and Enable the Camera

  14. Let’s update the software by running the following lines one at a time:
    sudo apt-get update
    sudo apt-get upgrade
  15. Let’s change the password:
    passwd
  16. It’s a good idea to give the Pi a static IP address. This excellent tutorial covers how to do this:
    http://raspberrypituts.com/raspberry-pi-static-ip-address-simple-tutorial/
  17. We now need to enable the camera and set the timezone. This can be done by running:
    sudo raspi-config
    1. Select Interfacing Options from the menu
      Screen Shot 2017-07-02 at 17.42.49

    2. Select Camera and then Yes and then Ok
    3. Back at the main menu, select Localisation Options and then Change Timezone
    4. As an example for the UK, select the following:
      Europe -> London
  18. Now close the window by selecting Finish, and press Yes to reboot
  19. SSH back into the Pi using Putty or terminal.

    Install RPi Web Cam Interface

  20. If you aren’t there already, cd into your home directory
    cd ~
  21. Install git (because this isn’t included with Jessie Lite by default)
    sudo apt-get install git vim
  22. Run the following (either a line at a time or all at once is ok)
    git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
    cd RPi_Cam_Web_Interface
    chmod u+x *.sh
    ./install.sh
  23. You should now be presented with the Configuration Options screen. To navigate this page, pressing tab will jump between the options window and the Ok/Cancel buttons. When in the options window, use the arrow keys to move up and down.
    Screen Shot 2017-07-02 at 18.36.53
    Cam subfolder – best leave this at the default html. You would only need to change this if you were hosting multiple sites on the same Pi
    Autostart – Leave it at Yes so that the software starts automatically after a reboot
    Server – Leave this at Apache. There are other options, but for ease of use Apache is the best choice.
    Webport – If you are thinking of accessing the camera from outside your home, it is best this port is changed to something between 1024 and 65535. Make a note of the number if it’s something other than 80.
    User – Set a username. You could leave this empty if you’re only ever going to access the camera from within your network, but it’s advised to set a user and pass for extra security.
    Password – Set a password
    jpglink – Leave this set to no, it’s for backwards compatibility

  24. Press Ok when you have set your desired options
  25. Press Yes to Start Now.

    Accessing the Web Interface

  26. All being well, you should now be able to enter your Pi’s IP address into a web browser. e.g
    http://192.168.1.5/html/

    If you used a different port, enter this as follows:

    http://192.168.1.5:2244/html/
  27. Hopefully you can now see a live stream from your camera
    Screen Shot 2017-07-02 at 19.01.25

  28. Let’s change a few key options at this point. Notice how the camera is upside down? This can be rotated in 90 degree intervals from the “Rotation, default 0:” option within Camera Settings. In this case we will choose Rotate_180:
    Screen Shot 2017-07-02 at 19.04.01

  29. The default resolution is 1080p, but you loose a lot of the sensor with this, so within Camera Settings -> Resolution, from the Load Preset drop-down menu, choose Max View 972p 4:3
    Screen Shot 2017-07-02 at 19.07.04

  30. If the annotation text along the top of the video feed (showing date/time) blends too much into a white background, change Camera Settings -> Annotation -> Background (drop-down menu) to On.
    Screen Shot 2017-07-02 at 19.12.23

    Enabling Motion Detection

  31. Change Motion Detect Mode (within Camera Settings) to Internal
    Screen Shot 2017-07-03 at 16.54.51

  32. Adjust the parameters such as Noise Level, Threshold, etc within motion Settings. Full details on what these do can be found here:
    http://elinux.org/RPi-Cam-Web-Interface#Motion_Detection

That is it! Feel free to explore the Wiki http://elinux.org/RPi-Cam-Web-Interface, and if you have any questions there’s an active support forum here: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=63276

Advanced Guides

If you would like to see what else is possible with these cameras, please have a look at some of my other guides:

Advertisements

2 thoughts on “How to Make a £59 Fully Featured Raspberry Pi Home Security Camera – Newbie Guide

  1. Thanks for this wonderful tutorial. I’m part way through following it – and hopefully I can get it to work. I have some comments which I’ll add as I see them. The first is this ——– No forum is actually given:

    “and if you have any questions there’s an active support forum here: – “

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s