Introduction: Budget CCTV With Android and Rpi

This project is for an expandable CCTV system that you may be able to build out of things you have lying around space.

If you are have a RaspberryPi 2 or an old laptop spare then I recommend that you look at using zoneminder. Zoneminder is a bit much for the original RaspberryPi so here's a simple alternative if you are using an original RaspberryPi.

For this project you will need.

  • RaspberryPi
  • Old android phone (any smartphone is probably usable)

You may need:

  • Usb pen drive
  • Command 3m sticky pads

Step 1:

Install the IP Webcam app on your phone.

Step 2:

Set IP Webcam to start on boot.

Step 3:

Click on start server to make sure that IP Webcam is working.

Step 4:

Stick your phone where it has a good view of whatever it is that you want to keep an eye on. I'm using 3M command sticky pads but use whatever works for you.

You'll probably want to leave your phone plugged into a charger as well.

Step 5:

Install your OS of choice on your Raspberry, I'm using Raspbian.

Step 6:

Copy the cctv.py and cameras.conf files to the home directory of your Raspberry.

Make sure that you edit the cameras.conf file to replace:

[IP ADDRESS]

with the actual ip address of your camera as shown in IP Webcam.

Step 7:

The cameras.conf file allows you to specify the cameras in your CCTV network and should be kept in the same folder as cctv.py.

The cctv.py program can be configured to work with most network cameras, the parameters are as follows:

  • rootpath - This controls where the imagery from the cameras will be saved.
  • url - This should be set to whatever URL will return an image from the camera, in the case of IP Webcam this will be in the format http://[IP ADDRESS]/shot.jpg
  • every - This controls how often the program will try to save an image from the camera, this is measured in seconds. By default images will be saved at 20fps.
  • keep - How long to keep the images, this is measured in days. By default images will be saved for 31 days.
  • username and password - This feature only works if both parameters are set but should be used when the camera is password protected.
  • filetype - The image type that is returned by the camera, in the case of IP Webcam these are jpgs. By default jpg is assumed.

Look in example_cameras.conf for an example of how to configure multiple cameras.

Depeding on the number of cameras, how often you save an image and how long you want to keep the images you may need a significant amount of storage space to save the images.

Your results may vary but in my experience, 1 camera at 3fps for 31 days is approximately 15GB of space. I strongly recommend plugging a suitably sized USB pen drive into your RPi and setting the rootpath parameter to save on the pendrive instead.

Step 8:

Now that you've configued your cameras.conf file it's time to set your RPi to run the CCTV program automatically.

Open your crontab by typing:

crontab -e

into your terminal and add the following line to the end:

@reboot cd /home/pi && python3 cctv.py

save your crontab and reboot your RPi.

Step 9:

If everything is set up correctly then the folder your specified in your cameras.conf file will start to fill up with images from your camera. The images will be deleted after 31 days or whatever you specified using the keep parameter in your cameras.conf file.

The final step is to try and hide your RPi or at leave leave it somewhere unobtrusive.