I was looking for a way to check in on my house while away as well as have any motion captured and uploaded to the internet as a security camera. Doing a little research online and realizing that I had a raspberry pi and a usb webcam not being used for anything else, This is what I put together.

Please note, this is a brute force method and does not provide any type of security to the webcams stream but its my first time working on something like this.

Step 1: Resources

I have to start with credit to the websites that I used for my research:

http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome - The software I used was called Motion, it handles the streaming of the webcam to the web as well as detecting motion and saving the movie files.

https://github.com/andreafabrizi/Dropbox-Uploader - This software allow you to sync your files into a Dropbox Account

http://www.slblabs.com/2012/09/26/rpi-webcam-stream/ - This site explains a few different ways to setup the camera on the raspberry pi to set up a simple web stream of the image.

http://mogshade.wordpress.com/2012/12/23/simple-home-security-with-raspberry-pi-and-dropbox/ - This site is where i started with for implementing the upload of the movie files to a Dropbox account

https://www.instructables.com/id/Host-your-website-on-Raspberry-pi/ - This Instructable was used to set up a simple website to view your Web Stream from.
<p>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>
<p>Thank you</p>
<p>can't find &quot;webcam_localhost&quot; in motion.conf file</p>
<p>it's &quot;stream_localhost&quot; - I had trouble too. It must've changed recently.</p>
<p>can't find &quot;webcam_localhost&quot; in motion.conf file</p>
Im pretty sure this is clear to some, but being new to DropCam, I'm a little confused. Will this allow me to setup and use my DropCam without having to pay for their monthly service?<br><br>Im searching for a way to sync DropCam to Dropbox, if at all possible.
<p>@<a href="/member/jbennett38" rel="nofollow">jbennett38</a> - no, this is a DropCam *alternative* solution, it does not integrate with an existing DropCam camera. Here, you use a Camera designed to be connected to your Raspberry Pi. There's some pretty good ones out there with auto night-vision (WaveShare etc) for around $30.</p>
<p>Thank u so much guy!</p>
<p>For anyone having trouble getting the photos to upload to dropbox use this script:</p><blockquote>import os</blockquote><blockquote>path=&quot;/tmp/motion/&quot;</blockquote><blockquote>dest=&quot;/( REPLACE WITH NAME OF APP FOLDER ON DROPBOX...&quot;</blockquote><blockquote>def upload_files():</blockquote><blockquote> if not os.path.exists(path):</blockquote><blockquote> return</blockquote><blockquote> dir_list = os.listdir(path)</blockquote><blockquote> for file_name in dir_list:</blockquote><blockquote> if &quot;jpg&quot; in file_name:</blockquote><blockquote> print&quot;Upload Pending...&quot;</blockquote><blockquote> cmd = &quot;/home/pi/dropbox_uploader.sh upload &quot; + path + file_name + &quot; &quot; + dest</blockquote><blockquote> os.system(cmd)</blockquote><blockquote>if __name__ == &quot;__main__&quot;:</blockquote><blockquote> upload_files()</blockquote><p>Pay attention to indenting which was hard to do on this comment...</p><p>Awesome article and very thorough.</p><p>Anyone have any advice on configuring passwords for web server?</p>
<p>Hi,</p><p>I've tried using your script but I get an indent error on line 6.</p><p>Any chance you can upload to github or something as I'm not savvy enough with python to fix errors.</p><p>This is what I'm doing - I've edited it briefly for my own situation (ie path of uploder, and where the dropbox_uploader.sh script is located.</p><p>import os</p><p>path=&quot;/var/www/media/&quot;</p><p>dest=&quot;/MBRPI&quot;</p><p>def upload_files():</p><p> if not os.path.exists(path):</p><p> return</p><p> dir_list = os.listdir(path)</p><p> for file_name in dir_list:</p><p> if &quot;jpg&quot; in file_name:</p><p> print&quot;Upload Pending...&quot;</p><p> cmd = &quot;/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload &quot; + path + file_name + &quot; &quot; + dest</p><p> os.system(cmd)</p><p>if __name__ == &quot;__main__&quot;:</p><p> upload_files()</p>
<p>Getting stuck on step 5. Do i have to set my router to forward port 8081 in order for the stream to be seen on the webpage? This is what the page looks like right now.</p>
<p>curl &quot;https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh&quot; -o dropbox_uploader.sh</p>
<p>Yeah_ this was the correction which was to be done,i suppose (this is what i checked).<br>I am sharing the screenshot i NOW get while running the .sh file.<br>The folder name corresponding to the app name i defined whil following the instructions given in screenshot has been successfully created but the pictures are still not being uploaded.<br>both the .py files are properly indented and i have used </p><p>cmd = &quot;/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload %s %s %s&quot; %(path + file_name,&quot; &quot;,path + file_name)</p><p>following a comment on this page (below).<br></p><p>any help is appreciated. :)</p>
<p>Ho seguito la tua guida fino al passo 5, ma ottengo quanto nella immagine 1.png<br>Il mio router &egrave; settato cos&igrave; come vedi nella immagine 2.png</p><p>Come mai non mi funziona?</p><p>Grazie</p><p>______________________________________________________</p><p>I followed your guide through step 5, but I get the image in 1.png<br>My router is set so as you see in the image 2.png<br><br>How come I do not work?<br><br>Thank You</p>
<p>Wonderfull! :-) I don't know if dropbox usage has changed or if I did not read something correctly but I had trouble with the shell wanting more info. I finally gave it the name of my dropbox app and it worked! .... because I had put in &quot; myapp&quot; it needed the &quot; &quot; then text...</p><p>cmd = &quot;/home/pi/dropbox_uploader.sh upload &quot; + path + files + &quot; &quot; + file_name</p><p>the first files are copy _from_ . the second are copy _to_.</p><p>I decided that a prefix of something raspberry flavored was actually a good thing :-)</p><p>best to you all</p><p>bob</p>
<p>hi</p><p>i just did every thing you said. but it doesn't work.</p><p>i have raspberry pi model a, a wifi dongle &amp; MD80 mini camera, all connected to a usb hub. my uploader file contains :</p><p>import os<br>path=&quot;/tmp/motion/&quot;<br>def upload_files():<br> if not os.path.exists(path):<br> return<br> os.stdir(path)<br> for files in os.listdir(&quot;.&quot;):<br> if files.endswith(&quot;.avi&quot;):<br> cmd = &quot;/home/pi/dropbox_uploader.sh upload &quot; + path + files<br> os.system(cmd)<br> os.system(&quot;sudo rm /tmp/motion/&quot; + files)<br><br>if _name_ == &quot;_main_&quot;:<br> upload_files()</p><p>any Suggestions?</p>
<p>still not working on step 7 , please T_T</p>
<p>Gday,</p><p>I have just completed Step 5 and can get the camera to stream the video, however whenever there is movement detected the streaming of the video stops. I can get back onto the streaming eventually. Any ideas where this might be falling apart?</p><p>Thank you in advance!</p>
<p>Thanks for this useful article!</p><p>If it's not working with the RasPi Cam (no /dev/video0) try:<br>sudo modprobe bcm2835-v4l2</p><p>and /dev/video0 should be there; then restart motion.</p>
<p>My house got broken into last week so this got me to this tutorial.</p><p>I'm the owner of a pi but not that experienced in programming, all that i've done so far is running xbmc and stuff like that...</p><p>The tutorial seems pretty clear to me to construct but i have some questions before i run to the store for a new sd card&amp;pi cam (replacing tv/laptop etc costs me enough already :( ).</p><p>1) does the script auto start when turning on the pi and if not how can i accomplish this?</p><p>2) when motion is detected is it possible to have a 60sec delay before posting to dropbox and further actions?</p><p>3) when motion is detected how can i let the pi play a mp3 sound over the audio jack in an attempt to scare the intruder?</p><p>4) when motion is detected can the pi contact me on my smartphone over facebook messenger/twitter/sms/mail/whatsapp and or others...?</p>
<p>1) It should because of the file /etc/init.d/motion, but in case it doesn't...</p><p>Just edit rc.local file: sudo nano /etc/rc.local</p><p>And add these 2 lines before the exit statement:</p><p># Start motion </p><p>motion<br></p><p>2) Modify the file uploader.py: sudo nano uploader.py</p><p>And add this line before &quot;upload_files()&quot;: os.system(sleep 60)</p><p>3) First install a command line mp3 player: sudo apt-get -y install mpg321</p><p>Then add this to /etc/motion/motion.conf: On_picture_save mpg321 whatever.mp3</p><p>4) To create a script file that sends emails using Gmail, check this link: <a href="http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/" rel="nofollow">http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/</a></p><p>Then add this to /etc/motion/motion.conf: On_picture_save send_email.sh</p><p>Hope it helps!</p>
<p>wow, didn't expect that much detail. Thank you so much for that ! I'm ordering the parts and will let you know !</p>
<p>I've tested with the MD80 mini camera but it RPI doesn't recognize it? Please help!</p>
<p>Hi. Small typo above. The closing HTML tag is missing the /.</p><p>The code should be:</p><p>&lt;html&gt;<br>&lt;body&gt;<br>&lt;h1&gt; Raspberry Pi DropBox Camera Stream &lt;/h1&gt;<br>&lt;img src=&quot;http://Raspberry pi's IP:8081&quot;&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</p>
<p>Help! i use the sudo python picamstreamer.py and sudo python picamstills-db.py but it keeps on shutting down my pi.</p>
<p>I used <em><strong>sudo apt-get install Motion instead of </strong></em><em><strong>sudo apt-get install motion that was silly of me...</strong></em></p>
<p>sudo service motion restart &lt;&lt; for start motion</p>
<p><em><strong>sudo apt-get install motion &lt;&lt; it's work for me</strong></em></p>
<p>Am I correct in thinking with dropbox uploader you have to specify the destination folder as well as the local location nowadays?</p>
<p>This works- </p><p>cmd = &quot;/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload %s %s %s&quot; %(path + file_name,&quot; &quot;,path + file_name)</p>
<p>uploader.py is not working. i get this error message &quot;Uploaded</p><p>Traceback (most recent call last):</p><p> File &quot;/home/pi/uploader.py&quot;, line 15, in &lt;module&gt;</p><p> upload_files()</p><p> File &quot;/home/pi/uploader.py&quot;, line 12, in upload_files</p><p> os.remove(path + file_name)</p><p>OSError: [Errno 13] Permission denied: '/tmp/motion/01-20140316154001.avi'&quot;</p>
<p>i followed all the steps! everything worked EXCEPT step 8. when login to my dropbox, the folder is empty. what went wrong?</p>
<p>Hmmmm I know I had trouble with the dropbox upload at first. Did everything else seem to go well? Is the basic web page streaming the image? Did you get any errors when running through Step 6? I have to update Step 7 but I believe the code in the image is correct and the code in the text of step 7 is not. Python is also indent driven so all of the indents needs to be correct.</p><p>When it works properly, in your dropbox home folder you will see a folder called Apps. and your videos will be in there.</p>
<p>everything is working EXCEPT:</p><p>1- i dont see anything in my dropbox APPs. i see the files in tmp/motion though</p><p>2- the old files are not being deleted every hour as you mentioned</p><p>basic web page streamed the image good. in step 5, your forgot / for &lt;html&gt; but its ok! </p><p>no errors during step 6</p><p>in step 7, i have everything same as your image. with indentation using TAB on my keyboard. </p><p>thanks for your help! i know everyone appreciates your hard work</p>
<p>I need to think about why the temp directory isnt clearing out every hour. </p><p>But for the Uploader, I think I see the issue stopping the uploader from running. </p><p>See the image below, but i think you you make change files_name to file_name to match the other references. This should correct the uploader issue.</p>
<p>yes, i made changes as you mentioned but still not working. can you share image of your uploader.py and cleartmp.py</p>
<p>I am not currently at staying at my house (part of the reason I set this camera up) but I will try to stop by and get these screen shots this weekend. </p>
<p>oh yes please post image of your 2 python script!</p><p>also, do those 2 script automatically start doing the upload? meaning, if i boot up the raspberry pi, motion auto start...but what about the python scripts?</p>
<p>Thanks - really useful. </p><p>Being very new to Python I got stuck at step 7 - I can't get the code uploader.py to work. I noticed that the code in the picture is slightly different from the text. Which one is the correct version to use? Thanks </p>
<p>Sorry about the confusion. I believe that the Picture is the correct code because that's a screen shot from my running program. Unfortunately, I am away from my home for the last few weeks and cant double check the running system but I believe the code in the picture is correct. </p>
&quot;Now follow the instructions in the README.txt file in order to link the Raspberry Pi to your DropBox account using OAuth.&quot; <br>Could you link to this txt file please? <br>I had to download an updated driver for my camera from one of your links but I dont know where i should be unzipping it. I put it in the home folder but thats not working. <br> <br>Thanks for the instructable!
<p>Sorry I realized I messed up step 6. I have updated it. See my post above.</p>
<p>I second the OAuth command and readme.txt file. I have the camera displaying a video feed that is extremely laggy (3 to 5 seconds delay time). Is this an issue still once you are motion capturing and sending the video to dropbox?</p>
<p>After looking at these comments I realized that I messed up step 6 and have updated it (See my post above)</p><p>As for the extremely lag, that is actually going to be common for this setup. This is meant to be used for a home security type of setup where you can pop in from your cell phone or work computer to see what is going on in the house or in the case of something horrible (like a break in) you can hopefully have a picture of the bad person in your dropbox account. I think the lag is because what the Motion software is doing is taking a snapshot or still picture a few times each second (you can change this setting in the config file for motion). If you are looking to reduce the lag you could try dropping the image quality (also in the config for motion) or even update the frames per second. If that doesnt work, there may be another setup that may suit your needs.</p><p>I hope this helps.</p>
<p>I am sorry about the confusion. I see that i messed up a bit on Step 6. I have updated it but I will also put it here</p><p>What I should have said is:</p><p>Now run the script and follow its instructions</p><p><strong>./dropbox_uploader.sh</strong></p><p>The readme.txt file really just gives the same information I gave above but here is the link to the readme.txt</p><p><a href="https://github.com/andreafabrizi/Dropbox-Uploader/blob/master/README.md" rel="nofollow">https://github.com/andreafabrizi/Dropbox-Uploader/blob/master/README.md</a></p><p>I am still very new to working with linux and the command prompt.</p><p>I just unzipped the files to my home directory.</p><p>I hope this helps</p>

About This Instructable




More by nochanceinhell3856:Cheap and Easy Fireplace Heater 3D Printed Cake Topper Recovering Files from a Snapped US Flash Drive Repair 
Add instructable to: