Turn your Pi into a low-cost HD surveillance cam

Local government CCTV is awful, and it’s everywhere in the UK. But I’m much happier about surveillance in the hands of private people – it’s a matter of quis custodiet ipsos custodes? (Who watches the watchmen?), and I’m pleased to see the Raspberry Pi bring the price of networked motion-sensitive HD surveillance cameras down to be affordable by consumers. Off the shelf, you’re looking at prices in the hundreds of pounds. Use a Pi to make your own HD system, and your setup should come in at under £50, with a bit of shopping around. This is a great use case for the value bundle our distributors are offering at the moment, where a camera board and a Model A Raspberry Pi with an SD card is coming in at $45.

Christoph Buenger has used a Pi and a camera board as the guts of his project, and, in a stroke of sheer genius, has waterproofed the kit by housing it in one of those fake CCTV shells you can buy to fool burglars. The fakes are head-scratchingly cheap – I just found one that looks pretty convincing on Amazon for £6.24.

Christoph’s camera, snug inside its housing

Christoph has made build instructions and code available so you can set your own camera up. It does more than just film what’s in front of it: he’s added some motion-detection capability to run in the background, so if the camera spots something moving, it’ll start recording for a set period.

At the moment, Christoph saves video to a Windows shared folder (you can, of course, save it wherever you like if you’re not a Windows person). The live stream is also available to be viewed online if you configure your local network.

A live (and topical) frame from the camera’s video feed

Christoph’s looking at adding more functionality to the setup. He says:

There are a thousand things you can do with such a surveillance cam basic setup now. How about sending Growl notifications when some motion was detected? This guide explains how to add this functionality easily.

Or you could easily add a temperature-sensor to the cam. It’s only a few bucks and can be integrated very easily.

We’re currently working on integrating the live stream into MediaPortal server so that we can switch to a TV channel to see the live stream from the cam in our office.

If you want extra security, you could also add a battery pack to the camera. Be sure to buy one that is able to charge simultaneously while powering the Raspberry. This would enable you to detect if some bad guy cuts the power strips of your camera and send some alert messages to you (i.e. SMS or email) including the video of the disturber.

Let us know if you set up your own security camera with the Pi. We’d love to see what adaptations you come up with!

78 comments

Avatar

Great idea about the housing.

Avatar

It’s such a simple idea, but it’s a very clever one. I like his discussion on whether or not to allow the LED light to show: it depends on whether you want the camera to be a visible deterrent, or a hidden watcher.

Avatar

Very clever indeed… I think that having the LED showing would be best – deterring criminals is better than having to hunt them down when they have nicked your stuff (Raspberry Pis)!

The Raspberry Pi Guy

Avatar

Great idea :) Altho the one you linked too would be too small to fit a pi inside wouldn’t it? Might need a slightly larger one unless there’s a way to run the camera cable out of the housing and back inside.

Avatar

I’m putting one inside a birdhouse…I can get the prefabbed birdhouses for about five dollars

Avatar

Funnily enough a type a pi and camera arrived for me today for which I planned to do exactly the same although I am going to experiment with the housing as a halogen floodlight. I wanted to experiment to see if I can maintain the function of the light somehow so it could see in the dark.

How did you power it?

Can it see in the dark?

Avatar

I have am running a pi pointing down my driveway in the UK. It is current providing useful images from about 7am to 6pm in natural light. I too am looking at using a flood light for night images. I would be interested to know the wattage and distance are usable by the pi camera.

I am currently just using a simple loop generating 15min time-lapse videos.
“raspivid -t 900000 -o $filename -fps 2 -b 2000000”

2fps uses about 1MB per minute so I just let it run all day, every day.

Avatar

I use 2 x 150 watt motion activated floodlights which light up my driveway like a movie set. There work brilliantly.

Avatar

CORRECTION… they are 250 watt halogen floodlights.

Avatar

Nice, it something similar what I have done on my project :)

Well done, would be great to get emails or else to alert the owner

Avatar

In an attempt to discover what sort of nocturnal intruder was defecating outside my front door I set up an old webcam connected to my Pi running Motion. Was fairly simple to get this taking a pic every few seconds, saving it and streaming images live on the web.

Avatar

You clearly weren’t the only person in that scenario running motion. (Badoom tish.)

Avatar

I second that E-motion

Avatar

can anyone recommend a fake dome camera case ? to hold a rpi camera and rpi ?

Avatar

They sell them in pound land/99p shops.

Avatar

Can you suggest some compatible cams with good night capture?

Avatar

The housing is great. I made similar device using webcam (720p) and installation of Motion on the Pi. I also split the SD card, so 4GB are utilized for data and picture storage. The device has a web frontend with the ability to visualy browse the daily logs on phones, tablets, browsers etc and the ability to connect to VPN.
I love what possibilities the Pi brings.

Avatar

I want to build something similar to what you are describing. I want a system for surveying gutters etc. I want to be able to record. I was thinking of using a bullet cam of some kind with wireless capability, possibly to stream to the PI and record. Also thought about being able to have an Android UI perhaps using the WIFI direct functionality. Any thoughts?

Avatar

element 14 have sold out of A + camera kits now, eta 30 days and i need to gather evidence on my landlord who’s been illegally entering my flat & harrasing me – can you rustle up some more kits quick smart please? ;)

eben

Looks like it’s in stock at RS though. Commiserations about your landlord.

Avatar

I’m in the middle of a surveillance camera project where I’ll also wire the Pi to control a color-settable high-intensity LED floodlight.

The idea is for intruders to see police-light lights when they’re up to no good.

http://midnightyell.wordpress.com/2013/09/04/nohonoramongthieves/

Avatar

“With some luck, the thief will look towards the strobing light – and my camera – as I take full-exposure pictures.” -If you use the R-Pi camera, it takes up to a second for the auto-exposure to work, so a strobe light may not give you good images. The idea might work, if not too many stray cats/dogs set off the strobes by mistake.

Avatar

never mind – ordered from rs now :)

Avatar

Hi everyone.

I used exactly the same case on week ago also for survilance camera with a pi-cam, except i used in addition an wideangle objective snap-on from smartphones to increase the viewing angel.(Available on Amazone) And i use the pi for streaming to a Linux Server where Zoneminder (a surveillance software for Linux) is running. I wrote a tutorial 2 month agon. Maybe someone is interrested. Here is the link. http://www.zoneminder.com/forums/viewtopic.php?f=10&t=21254&sid=4fd3582b0079256c503f8703a6723332
I’m using now allready 2 pi-cam’s for this purpose.
1 is allready up since 1 1/2 month. Maybe it is helpfull for someone.

Markus

Avatar

How are you guys delivering power to your pi in these lofty positions?

Avatar

The Pi does not have PoE (Power over Ethernet) built in, but it’s relatively simple to add it. You just need a pair of PoE splitters on each end of the ethernet cable, plus a 12V (or 24V) power source on one end and a DC-DC converter to 5V on the other end. They are cheap, for example
http://www.ebay.com/itm/DC-DC-HRD-12V-24V-36V-Step-Down-to-DC-5V-3A-Car-Power-Converter-Regulator-Module-/200819052861
http://www.ebay.com/itm/121100493562

Avatar

I think Ethernet (and PoE) is the traditional and best solution in this application, but if you’re using a Model A with USB Wifi then you just need to get +5V, so run a wire to the closest outlet where you can plug in your 5V AC adaptor.

Avatar

But moddel A has no ethernet port (?)

Avatar

sorry, i see that is what you are saying.

Avatar

Hold on a minute! These images are far too clear to be security camera images! ;)

Avatar

Does anyone know how to maximise the field of view without having to capture a full resolution frame? Reducing the size just results in capturing a small square at the centre of the frame for me

Avatar

You could try a jelly lens for a mobile phone very cheap and give a wide angle there are some examples of them being used on youtube being used on the MD80 type mini cameras

Avatar

If I’m understanding you correctly you want to keep the full optical frame but record fewer pixels?
Rather than specify say an 1280×720 video that is a crop of the centre of the optical field of view?

I’m not sure you can do that as such. What you could do is take a 1920×1080 feed but specify a low bitrate.

Avatar

You could grab the full frame and then use ImageMagick (the command line image editor) to process the image. It’s available in the Raspbian repositories and you can do just about anything to images with it. It can easily crop an image to the area or aspect ratio you want, or just as easily resize a full-res image to something more web friendly.

Avatar

I am halfway through a security camera project right now! I’m running into one problem: the JPG files that are uploaded to my server via WPUT are blank & can’t be opened in Photoshop. Here is one of the captured pictures: http://jonathangraft.com/assets/img/security_camera_example.jpg

Any advice? I am forcing upload over binary.

Avatar

I’ve opened a post about it on StackExchange here: http://raspberrypi.stackexchange.com/questions/10127/wput-is-uploading-pictures-captured-by-motion-over-ftp-but-jpgs-are-blank

If anybody has any input, I’d greatly appreciate it.

Avatar

Have you confirmed that you are getting valid JPEG files from Motion, eg. by checking the files before they are sent up via wput? If they are good before the transfer, then maybe your remote FTP server is slow, and the connection is timing out before the complete file is transmitted? If so try a very small size file, see if that makes a difference.

Avatar

In my day job i’m involved in next door neighbour boundary dispute resolution. IMHO the law of un-intended consequences often comes into play when people install CCTV. Please think long and hard before doing so or you might find yourself jumping out of the frying pan and into the fire.

Avatar

A little detail would work wonders.

Avatar

Bantammenace, are you referring to situations where a camera’s field of view includes part of a neightbour’s property, so the owner ends up inadvertantly spying on the neighbour? I imagine that being a big problem in densely-populated areas.

Avatar

Exactly that. If you already have a deteriorating relationship with your neighbours and you put up CCTV are subsequently considered to be potentially taking images of their grand-children playing in the garden for instance, then things can turn nasty very quickly.

Avatar

Yep that’s definitely worth thinking about, although those kinds of cases can often be cured by mutual cranio-percussive attitude realignment therapy (MC-PART) if they’re caught early enough.

Avatar

Did a similar project. components were ;
rPi + Wifi + Python + motion + Google Drive. No local storage, almost instantly uploads the video to a server outside my home. So even if burglar gets access to the box, he could do little to prevent the upload.

In addition to that I have used the GPIO pins to sense temperature. Soon I will add controls to operate my A/C automatically.

Will be more than happy to share if any one needs the code.

Thanks
Salih

Avatar

Yes please, I’d love to see your python code for uploading to Google drive. I’m only able to drop files into the root directory of Google drive – very messy very fast.
Can you publish the code to upload to a specific folder on Google Drive?

Avatar
Avatar

I used picamera python lib capture_sequence and save the files to /var/www
Then wrote a javascript that loops through the images – so I can browse to the pi and see the images.

Avatar

Is there any way to get more than 2fps?

What about night recording?

Avatar

If you use ethernet and a lower res it is possible.

Night recording does not perform very well. The -ISO flag is not implemented yet in raspivid so the image gets dark very fast.

Avatar

That’s an excellent project, and the housing is genius indeed. The only thing I’d be wary of is using a wireless connection for the video. Low-powered radio signals are extremely easy to jam, so a well-prepared thief (or just a passing van containing poorly-shielded equipment) could disable the feed wihtout coming in range of the camera. I’d be inclined to use USB-ethernet, and have any potentially useful pictures copied straight to a remote server.

Avatar

Guys, would the Pi not overheat in the case? Especially on a hot summer day in direct sunlight?

Avatar

I live in South Florida, sub-tropical weather with lots of hot sunshine. I have two builds of this project, one with PiCam and one with PiCamNoIR. The housing on my first build is similar to the one in photo above. My RPi is over-clocked to 1GHz. Current outdoor temp is 76F, CPU on RPi reports 156.2F, No heat-sinks and no fans. Hardware is performing very well in this environment. I will be adding heat-sinks.

Avatar

Would be so great, if there was a complete webcam distribution including an easy to use webinterface to put on the sd-card.

Avatar

We have 2 easy to follow projects on how to create a web cam surveillance system including:
– motion detection (using motion)
– email alerts
– use motion to trigger the PrivateEyePi alarm system

Avatar

Using the fake CCTV is pure genius and it saves you money.

Avatar

Would be nice if someone add some extra code to use the GPIO to turn on the alarms when an intruder is detected :-)

Avatar

I like that this sort of project can be done cheaply and effectively with the marvelous Pi.

But two popular assumptions have to be challenged.

1) “Security lighting” is good. No, don’t light up the street and the sky with your damned light pollution – addressed to the “how many watts is your floodlight?” people. And yes, I know everyone of them will say their’s don’t shine where they are not supposed to, etc.

2) No, CCTV UK is not necessarily a *bad* thing. Which is better? Some paranoid internet ranters blathering on about their “privacy”? Or, capturing and prosecuting the yobs that rule night-time town centres and beat-up and rob old ladies during broad daylight?

Avatar

I have to Rasperry Pi model B devices running motion as security cameras in the interior of my house. The system is turned off and on via a Python script. I’ve modified the /etc/init.d/motion script to mount a directory (one per device) on my iMac via sshfs. The folder itself is a Dropbox folder so steal the iMac and I still have the images. Current limitations – the cameras are useless at night. They are regular USB cameras and need to be IR for night use. Future developments – integrate an IR sensor so the cameras only run once the system is armed and motion is detected via the IR sensor. And finally integrate ZWave to turn lights on when motion is detected and the system is armed (this hopefully scares the baddies away thinking someone is home). Problem: where to put the IR sensor? Inside? It doesn’t help security much if someone runs away *after* breaking in. Also I don’t want the system to be tripped every time a deer wanders into the yard so I’m going to have to do some recognition to determine there is an actual human present and not a passing car, deer, etc.

Avatar

Ok gonna nerd out a bit here … being a photographer I notice a few camera hobbyists create InfraRed images by peeling off the InfraRed layer of the cameras CCD sensors …

So what abut going with the ‘Halogen Light Housing’ idea and replacing the halogen with InfraRed lighting instead? This could be a cool pure Night Vision surveillence system? …

Could even go as far as switching 2 web cams (night & day), with a timer sequence running on the RPi …

Just a thought ;) …

Avatar

Love it!

If you need this remote I make some nice solar battery packs and 7 day timers for year round power in hard to reach places

http://Www.cottonpickersplace.com

Avatar

I am just so amazed with all the things you can do with the Raspberry Pi! I bought one a couple of months ago because I was so intrigued by all you can do with it. This definitely proves my point that there are endless possibilities!

Avatar

Can anyone provide information on what kind of image quality and FPS are possible with motion detection and streaming to NFS running? with or without a live view being streamed to a vlc client.

Thanks.

Avatar

I come from the other side. All I need is a (dome) housing…

http://youtu.be/g5iid1o3eOU

Avatar

People asking about night time recording, the Pi NoIR is now out (No Infra Red filter). I working on using it in a remote location running off batteries (cells)! I’ve ordered 2x 50,000 mAh batteries for Hong Kong and some infra red LEDs. Trouble is I don’t want to power the LEDs during the day and I plan to leave the Pi on it’s own for days on end. Any suggestions?

Avatar

You could attach a relay to the GPIOs on the Raspberry Pi. Then you could have Cron job running, which turn the relay on at a specific time of the day (or make a script to read out the light intensity from the camera to be more adaptive).
If you dont want to mess with wires or solder, you could buy the PiFace board, which includes relays.

Avatar

Light Sensor, breadboard with a small circuit between RPi and IR-LEDs, Software (Python) to turn LEDs on and off based on value from the light sensor. I plan to build on soon.

Avatar

Did you insert/place the date at the lower right hand corner or did that come natively from the camera? If you did it, can you share how? I am interested in placing dynamic text over an mpg4…

Avatar

Would this work with more then one?

Avatar

I was wondering if this system can also make the Housing move? I mean does the housing come with a motor to move the camera 180 degrees? Can that also be programmatically and remotely controlled through the internet?

Avatar

Hi, I am looking to build something like this to try and catch a criminal who keeps knocking off wing mirrors on my street. Could you tell me exactly what you used and where to find your code? It would be much appreciated,

Thanks

Avatar

Hi, I’m wodreing about the sealing of this factice camera case :/

At the moment I’m looking for an IP65 case for the Raspberry Pi in order to extend my video system for an outside usage.

Well, here is a complete exemple using multiple Raspberry Pi cameras : http://www.magdiblog.fr/domotique/systeme-de-tele-surveillance-abordable-avec-des-raspberry-pi/

Avatar

Hi there, I read through the comments and got interested in these kind of projects. I would like to have a rpi take a timelapse. Like every minute 1 picture, then upload this frame via internet to an FTP google drive etc. where I can download it and make a video file. Any idea on how to?

Cheers ralf

Avatar

Yes – there is a tutorial in our resources section for doing that. (You may have to look in the documentation section too if you’re not already comfortable with FTP.) See http://www.raspberrypi.org/learning/timelapse-setup/

Avatar

See the documentation page on time-lapse: http://www.raspberrypi.org/documentation/usage/camera/raspicam/timelapse.md

Also see pages on FTP, rsync, etc.

Avatar

There’s a great library called motion that can create time lapse videos using a webcam and Raspberry Pi. It can also upload that to google drive and email you when it’s done.

I wrote a blog about using motion as part of a CCTV project: RPi Motion Detection Security blog post that could help you get started.

Avatar

Great project guys

Can this be setup so it records to a NAS storage device, i dont want to have to leave a PC on if i can help it

Can it be setup so that after the drive space is full its starts to overwrite the space. i have 250gb free space which i can dedicate to this.

Cheers

Avatar

This is my version of a RPi CCTV camera using a webcam, wifi connection and the motion library. It is triggered by motion sensed through the webcam, then uploads a video to google drive and emails me a notification and link.

RPi Motion Detection Security blog post

Leave a Comment

Comments are closed