PiCam CCTV Camera

Project Brief

To build a device that runs from 5V USB power, take photos and store them for later collection.

The Plan

The housing for this device will be a dummy CCTV camera. It will contain a Raspberry Pi, battery pack, powered USB hub, WiFi dongle and a webcam.

The battery pack must be accessible for daily changing. The WiFi will allow me to connect to the device and collect the day's photos.

As there is no mains power available the device must be energy efficient and run for a day on batteries.

The Making

To begin with I open up the CCTV case to allow full access inside.

I then put the case on my Raspberry Pi which was very easy and it looks real smart too.

I then glued in a plastic shelf for the battery pack to sit on, next I arranged the Raspberry Pi, USB hub and the battery pack into the case.

I used the glue gun to secure the USB hub and Raspberry Pi in place, the battery pack will remain loose as it will need to be changed daily.

Once this was complete and the glue had set I moved onto mounting the webcam. Again I used the glue gun to glue the webcam to the front of the case.

Once this was done I started to put the case back together including plugging in the WiFi and USB stick.

The Tech Bits

Now its all in the case and powered up I can begin programming it. I will be using SSH to communicate to the Raspberry Pi via WiFi.

I used this tutorial to set up the WiFi hotspot

After I have connected I installed a program called 'fswebcam' which allows me to use a webcam - Link to fswebcam

Now I have the software I can begin making my own program. I will be using shell scrips and python in this project.

The Programming

To mount the USB stick on boot up I added this like to the crontab file.

@reboot sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usb

The following shell script will contain the code to take and save the photo, this file will be called on later via python.

#Get the date and time
DATE=$(date +"%Y-%m-%d_%H%M")
#Take photo and save
fswebcam -r 1280x720 /media/usb/$DATE.jpg

Now its time to write the main program, this program will control when the photos will be taken.

import subprocess
import time
while True:

Finally I add this python script to the crontab file so it will run on boot.

@reboot cd /home/pi/PiCam && python runPiCam.py

Product Images

Inside mounting of Raspberry Pi, Battery and USB hub ​​​​​​​    Mounting of webcam​​​​​​​