This instructable describes how to build a surveillance cam based on a Raspberry Pi micro-computer which records HD video when something moves in the monitored area. Live picture can be viewed from any web browser, even from your mobile while you're on the road.
What you will get:
  • See live stream in any web browser from anywhere
  • Record any motion into video file
Usually, such a cam will cost you around US$1.000, but with the result from this instructable, you will get such a cam for only about US$120.

Step 1: Background

Have you ever heard of Raspberry Pi? It's a low-cost micro-computer that is able to run Linux and has endless extension possibilities. It cost only about US$35 and opens up endless possibilities of what you can build with it. The official website can be found at http://www.raspberrypi.org/

<p>To the users of the last few posts - this was posted in 2013, looks like things have come a long way since. </p><p>Check this: </p><p>http://www.instructables.com/id/The-BoBoBoT-5MP-1080-HD-Camera-Raspberry-Pi-Securi/</p><p>A whole OS devoted to this now...?</p>
Especially motioneyeos works pretty well: https://github.com/ccrisan/motioneyeos/wiki<br><br>We plan to update this article to reflect these new possibilities.
<p>Hi,</p><p>I've the same issue of TristanR19...what could be the problem ?</p><p>Thank's</p>
<p>Hi, </p><p>If I'd just rather save the files and not be concerned about the streaming side, how would I go about this? I've completed the steps as above, and I can see that the motoin.log has the fact the camera has been activated when motion is detected, but I can't find any of the .avi files it is generating. I've run a find command at the root of the pi but no results are returned. Thanks in advance guys!</p>
<p>I had an issue with Step 7, command: </p><p>sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev</p><p>Is there a reason this would be outdated or something? Thanks!</p>
<p>Thanks a lot for this awesome tutorial! </p><p>I had to add the below to rc.local for enabling dev/video0.</p><p>sudo modprobe bcm2835-v4l2</p><p>A shared folder in my MacMini is used for logging and motion detection upload. </p><p> /etc/fstab entry for that below </p><p>// /mnt/camshare cifs username=myusername,password=mypassword,uid=motion,gid=motion 0 0</p><p>had to set uid and gid to motion to enable user &quot;motion&quot; to write files to the shared folder. </p><p>sudo modprobe bcm2835-v4l2</p>
<p>Hi, I am using motion to get live stream, but stream is showing only black image and if any motions is detected that moving object is shown in either white or blue color, but i am not able to get normal color image stream, could you please tell which parameter I need to change in motion.conf file ? .. ( my camera supports color picture )</p>
<p>try this one dude<br>sudo modprobe bcm2835-v4l2</p>
<p>What if I want to save the video on an external disk drive connected to the pi?</p>
I did this as my first Instructable and my first experience with a Raspberry Pi. It took me about 20 minutes to get up and running with one USB camera. I then managed to get 3 USB cameras going at the same time. Great instructions, thank you. I'm going to get a Pi Camera next and try that. My plan is to make a completely wireless security camera for my carport.<br><br>I should mention that I am not a programmer or trained in any electronics and I was able to follow this Instructable without any problem.
<p>You motivate me - being a non-programmer. Good job dude!</p>
<p>hey. its a wonderful project. Do you have the circuit diagram? kindly upload. thank you.</p>
<p>I was inspired by this tutorial and wrote some fairly simple scripts to<br> do NFC activation/deactivation, LED status indicator, mobile <br>notifications. See <br>http://nathangraham.info/blog/motion-sensing-video-survallence-system-with-nfc-activation.html.</p>
<p>Ok, so thanks to those posting the libjpeg62-turbo-dev workaround, that worked for me. However, the install now stated that it cannot locate the following packages: libavformat53, libavcodec53 and libavutil51. Any ideas?</p>
<p>i recommend switching to MotionEyeOS. It's a super small (~44mb) download, purpose built (timelapse photography or surveillance) with built in Motion support, web interface by default, can upload to windows share, dropbox or google drive out of the box and can use the CSI camera interface or USB webcam.</p><p>This is a great instructable for DIY but I've found using MotionEyeOS waaaaay easier.</p>
<p>is it possible to use another camera like webcam camera logitech to run this project??</p>
<p>motion: error while loading shared libraries: libavformat.so.53: cannot open shared object file: No such file or directory</p>
<p>This guide is really quite good, especially for a linux beginner like me but I still cant get this to work. Im running a Raspberry Pi 2 with the dedicated camera module and the OS Raspbian Jessie. The only clear problem Ive run into is that some packages are missing, se below. </p><p>&quot;pi@raspberrypi ~ $ sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 l ibavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zli b1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev<br>L&auml;ser paketlistor... F&auml;rdig<br>Bygger beroendetr&auml;d<br>L&auml;ser tillst&aring;ndsinformation... F&auml;rdig<br>Note, selecting 'libjpeg62-turbo' instead of 'libjpeg62'<br>Package libjpeg62-dev is not available, but is referred to by another package.<br>This may mean that the package is missing, has been obsoleted, or<br>is only available from another source<br>However the following packages replace it:<br> libjpeg9-dev libjpeg8-dev libjpeg62-turbo-dev<br><br>E: Package 'libjpeg62-dev' has no installation candidate<br>E: Kunde inte hitta paketet libavformat53<br>E: Kunde inte hitta paketet libavcodec53<br>E: Kunde inte hitta paketet libavutil51&quot;</p><p>And Im unable to get any hints from the log file as its removed on each <br>reboot. Ive tried adjusting the &quot;/etc/default/rcS&quot; file regarding /tmp/ <br>management but it doesnt have any effect. So Im quite lost. Perhaps I <br>have to compile it from scratch but thats a bit beyond my skills for the<br> moment.</p><p>Trying to reach the web stream results in &quot;connection failed&quot; and the camera doesnt light up so the setup doesnt seem to work. Although if I check the service status I get the following response.</p><p>&quot;pi@raspberrypi ~ $ sudo service motion status<br>● motion.service - LSB: Start Motion detection<br> Loaded: loaded (/etc/init.d/motion)<br> Active: active (exited) since tor 2015-11-26 00:09:14 CET; 5min ago<br> Process: 3159 ExecStop=/etc/init.d/motion stop (code=exited, status=0/SUCCESS)<br> Process: 3327 ExecStart=/etc/init.d/motion start (code=exited, status=0/SUCCESS)<br><br>nov 26 00:09:14 raspberrypi systemd[1]: Started LSB: Start Motion detection.<br>nov 26 00:09:14 raspberrypi motion[3327]: Starting motion detection daemon: motion.&quot;</p><p>Any help with this is appreciated!</p>
<p>whew ! atlast successful doing this project ! 100% running streaming...i just skipped step 8 for shared folder... because im doing this for portable cctv / its like a &quot;gopro&quot;... +_+ well.. just for my final year project... thanks <br></p><p>-Raspberry PI 2 Model B<br>-Edimax wifi<br>-mobile data network(smartphone hotspot :P)<br>-powerbank 20,000 mah with 5v / 2.1A<br>-raspberry pi camera module<br>-noob casing because cctv casing is sold out in my area...<br>-sdhc sandisk 16gb class 6 or 10 already forgot for this one...<br>- keyboard,mouse,monitor (in my case = LCD TV ) for setup wifi only...after that all via SSH ( Wifi Hotspot ) :D</p>
Hello, <br><br>1 Are you able to password protect the stream? I am able to password protect the http access control but not stream.<br><br>2 how is the stream? My stream is lagging.<br><br>
<p>Good job mate ;), i'am about to start doing it with a raspberry PI 2 model B too, i've just gathered all the equipements and now time to build it up!!</p>
<p>good luck mate... may the force be with you.. :D</p>
Can I run more then one camera with the same raspberry li<br>
<p>This is an excellent project. Thank you for such detailed instructions. </p><p>I'm trying to make this work on a RaspPi 2 with Raspbian Jessie. I haven't encountered any errors any of the steps, but the motion detection isn't working. I'm not getting the red LED light at auto-start. I'm wondering whether I have to use Wheezy instead. There there any troubleshooting procedure that I could go through? Alternatively, what could be done to make this work on Jessie? Thanks!</p>
<p>Was impossible for me to get &quot;motion&quot; running.</p><p>My Raspberry is connected to a screen, so I used <a href="http://motiondetection.be" rel="nofollow">http://motiondetection.be</a> to do the motiondetection-part.</p><p>I also took a little subscription there, this lets me upload the images online.<br>When i'm away, I can see the images from home on my smartphone.</p>
<p>Did not work, Can anyone plz help </p>
<p>use libjpeg62-turbo-dev</p>
<p>same issues here; think something might have updated and now the libraries changed. Help? Out there anywhere?</p>
I am getting an error, please help
<p>You have merged two separate commands onto one line.</p><p>Run this first:</p><p>sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev</p><p>Then run the second command:</p><p>wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz</p>
<p>Same errors basically with mine too:</p><p>pi@PiCam ~ $ sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev</p><p>Reading package lists... Done</p><p>Building dependency tree </p><p>Reading state information... Done</p><p>Note, selecting 'libjpeg62-turbo' instead of 'libjpeg62'</p><p>Package libjpeg62-dev is not available, but is referred to by another package.</p><p>This may mean that the package is missing, has been obsoleted, or</p><p>is only available from another source</p><p>However the following packages replace it:</p><p> libjpeg9-dev libjpeg8-dev libjpeg62-turbo-dev</p><p>E: Package 'libjpeg62-dev' has no installation candidate</p><p>E: Unable to locate package libavformat53</p><p>E: Unable to locate package libavcodec53</p><p>E: Unable to locate package libavutil51</p>
<p>use libjpeg62-turbo-dev that looks like it is the replacement package for libjpeg62-dev...hope that helps if you havn't figured it out already</p>
<p>I got this error when I was using the latest Jessie raspbian. Using Wheezy solved this issue, since some packages aren't available on Jessie or have been renamed. </p>
<p>Can I transmitt continous video stream to any cloud server or IP without any motion detection feature. What would be the code and hardward required.</p>
<p>I have struggled with motion on the raspi and the easiest solution by far is motionpi:</p><p><a href="https://github.com/ccrisan/motionPie/releases" rel="nofollow">https://github.com/ccrisan/motionPie/releases</a></p><p>You just need to set up the ip information and the webserver interface is ready to go. I do not know the author or too much about motion so any questions should be directed towards them (if you have any - it's that simple!)</p>
<p>Instead of motion you can also use <a href="https://kerberos.io/" rel="nofollow">Kerberos.io</a>, it's also open-source and a lot more user friendly to install and configure. You can find more information on the website.</p>
motionEyeOS works great as well: https://github.com/ccrisan/motioneyeos/wiki
<p>Thanks, I'll give it a try tonight. :) </p>
<p>Thanks for this guide. </p><p>I've tried countless guides to get my old R-Pi B with 256MB of ram working with motion with the R-pi camera module to no avail. </p><p>Hopefully you can help me out?</p><p>I don't get any errors when starting up motion, so I'm guessing it's set up correctly. I can't access the webserver through port 8081 though. I just get &quot;connection refused&quot; when doing it. So I thought maybe the firewall is messing things up, so I installed motioneye, its webserver works 100% but it doesn't detect my cam. </p><p>Any help would be appreciated!</p>
I'm a bit new to much of the DIY electronics, but interested to learn. My question is why go through the time and trouble to build this cam for $120 when you can buy a complete 2 cam system with 250GB hard drive for under $200, or a 4 cam 500GB HD with mobile link up app for under $350?
<p>i signed up just to ask where did you see 1080 camera system for under $200?</p>
Hi Vladimir, I don't remember which website I found the previously mentioned setups on, but I did find this at Costco with a simple Google search: http://m.costco.com/Lorex-8-Channel-HD-Analog-DVR-with-2TB-HDD,-8-1080p-Cameras-with-130'-Night-Vision.product.100218592.html it's pretty easy to see that if a 8 channel, 2 TB HDD, with 8 1080P cameras is merely $500 @ Costco that a 2 camera system could easily be sold ~$200. Have a nice weekend!
Hi Vladimir, this is just an example of what's possible. 1080P 8 Camera system with 2 TB HDD for $500 @ Costco. If this were a two camera system $200 seems about right. I'm not certain which website I found the previously mentioned setups on, but if I run across it again I'll post the link on here. Here's the Costco link: http://m.costco.com/Lorex-8-Channel-HD-Analog-DVR-with-2TB-HDD,-8-1080p-Cameras-with-130'-Night-Vision.product.100218592.html<br>Have a great weekend!
<p>It's been a while, but I made a surveillance camera based on the steps from this instructable:</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/jqadNh_Uaa4" width="500"></iframe></p>
<p>Great instructions!</p><p>I managed to do everything with my PiCam but I seem to have an issue. The LED on my PiCam stays on for a few secs and then goes off for one second. When I watch the live feed on another pc in my network I see the live feed for as long as the LED of the PiCam is on, but once it goes off, I get the error &quot;The connection was reset&quot; (firefox) and I need to refresh. Any ideas what could be the cause of this issue?</p><p>Thanks!</p>
<p>Ok so i managed to navigate all of the steps :-) once I removed some of my copy &amp; paste errors. However when i access the web feed all i get is ghost like blue or grey content as it passes the camera. I checked the output folder and can see jpg which are nice clean images but i had thought you could live view the video feed?</p>
<p>just opened one of the avi files generated and the video is good so its just a question of live feed viewing. Do I have to do something extra</p>

About This Instructable




Bio: Passionate software developer running my own software consulting- and development company "Scavix Software Ltd. & Co. KG" (www.scavix.com). Loves hanging around with friends and ... More »
More by scavix:Raspberry Pi as low-cost audio streaming boxReplacing the battery of a Logitech BoomboxRaspberry Pi as low-cost HD surveillance camera
Add instructable to: