Introduction: Raspberry Pi DropCam Alternative

Picture of Raspberry Pi DropCam Alternative

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: - 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. - This software allow you to sync your files into a Dropbox Account - 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. - This site is where i started with for implementing the upload of the movie files to a Dropbox account - This Instructable was used to set up a simple website to view your Web Stream from.

Step 2: Setting Up Your Raspberry Pi

Picture of Setting Up Your Raspberry Pi

First things first. The raspberry pi should be setup with a standard version of Raspbian. If any help on doing this is needed please refer to or

We also need to setup a SSH connection to access the Raspberry Pi remotely. So do this refer to

Now You should setup port forwarding for your raspberry pi for both port 80 and 8081
while you are in your router settings also write down your Raspberry Pi's Public IP address as it will be what we use in the next few steps.

Step 3: Installing the Motion Detection Software

Picture of Installing the Motion Detection Software

Now lets install the Motion Software onto the Raspberry Pi.

1) Install Motion using the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install motion

2) Now lets setup the Motion Software, the following will open the configuration file:
sudo nano /etc/motion/motion.conf

a) In this file, you can adjust a whole bunch of things in the motion software but there are a few things that we need to change first
daemon - default is set to OFF, we need to set it to ON so that it will run in the background
webcam_localhost - Set to OFF so that you can access the stream from other computers
stream_port - Take note of the port as this is where you will point your browser to view the stream
control_localhost - Set to OFF as this will allow you to adjust some of the features remotely (I dont use this but it could be useful)
control_port - Take note of this port as it will be how you can change some parameters remotely in your web browser
framerate - I set this to 2 or 3 frames per second (over 5 will bog down your Pi)

b) We also need to change one last setting:
sudo nano /etc/default/motion
change "start_motion_daemon=no" to "start_motion_daemon=yes"

Now if you start the Motion software, in some browsers you will be able to view the stream. if you cannot yet, we will correct that in the next step.

Step 4: Setting Up the Web Server

Picture of Setting Up the Web Server

Next thing to make the web stream visible from nearly all browsers we need to setup a small web server on the raspberry pi along with a simple HTML page.

We are going to install Apache, PHP5, and PHP5 mod for apache. Not all of them may be used in this project but they are good to have in case you want to make your website a bit more that we will setup here.

Now Install the applications with the following command:
sudo apt-get install apache2 php5 libapache2-mod-php5

Next allow overrides:
sudo nano /etc/apache2/sites-enabled/000-default

Change "AllowOverride None" to "AllowOverride ALL"

Now restart the server to to allow the overrides

sudo service apache2 restart

Now your Website is Up and running. If you type the IP address for your Raspberry Pi into a browser you should be able to see a simple website.

Step 5: Setting Up a Basic Webpage

Picture of Setting Up a Basic Webpage

Now that you have a basic website being hosted on your raspberry Pi as well as the motion capture software lets combine the two.

first lets change the permissions to the directory for the HTML file

sudo chmod 777 /var/www

If you type in the following command line it will bring you to the HTML file that is the front page of your website:

sudo nano /var/www/index.html

This file currently contains the HTML code for a very basic website. We are going to change it to the following in order to display the web streaming image.

<h1> Raspberry Pi DropBox Camera Stream </h1>
<img src="http://Raspberry pi's IP:8081">

Note: Remove the <xmp> & </xmp>, this was the only way I know to get HTML into an instructable

Save this file and then in a web browser type in the raspberry pi's IP address and check out your new website

Step 6: Linking Your Raspberry Pi to Your Dropbox Account

Picture of Linking Your Raspberry Pi to Your Dropbox Account

First be sure that you have a DropBox account ( If you do not then set one up before going on.

Then Download Dropbox Uploader
First Change to which ever directory that you would like to install this program into (I just did it to the Home Directory)

Now download the application using the following command:
curl "" -o

Now change the permissions of the program
sudo chmod +x

Finally run the script and follow the instructions it gives you.  This will guide you through setting up the OAuth connection to your dropbox account

If you have any issues, try reading the README.txt in the files you downloaded or visible here

Step 7: Create Automatic Dropbox Uploads

Picture of Create Automatic Dropbox Uploads

Now we just need to create 2 Python Scripts. One to upload the Movie files and another to clear the temp directory from time to time.

First lets start with with creating the Python Script to Upload to Dropbox automatically.

Change the directory to which ever directory you would like (i did this in the home directory)
Then use the following command to create the script called Uploader

sudo nano

Now you should be in the blank python script file. Insert the following code into the file.
Please Note that this script is assuming that Motion's files are being saved in the Temp Directory (the default)

import os
def upload_files():
if not os.path.exists(path):
for files in os.listdir("."):
if files.endswith(".avi"):
cmd = "/home/pi/ upload " + path + files
os.system("sudo rm /tmp/motion/" + files)
if _name_ == "_main_":

Save and close the file (CTRL + X)

Now lets create the second File that clears the Temp Directory (this will happen each time the raspbery pi is restarted but I wanted to have more control)

sudo nano

In this new file place the following simple code

import os
os.system("sudo rm /tmp/motion/" + "*.jpg")

again Save and Close the file (CTRL + X)

Now One last time to make these two things run automatically

Type the following command to modify the crontab file

crontab -e

Add the following to lines to the bottom of this file

* * * * * python /home/pi/ # Sync webcam files dropbox to run each minute
@hourly python /home/pi/cleartmp/pr #Clear temp for motion each hour

Close and Save

Step 8: Finished

Picture of Finished

Now you are all set. I know that alot of this was a brute force method but it works. Also be careful as the website not very secure as it is just accessed via your IP address.

Finally, you can go through and play with the settings in motion to fine tune it as to what you would like.



CédricV2 (author)2015-05-25

You can also use, it's also open-source and a lot more user friendly to install and configure. You can find more information on the website.

MegaD3 (author)CédricV22016-02-06

Thank you

HazwerN (author)2016-01-14

can't find "webcam_localhost" in motion.conf file

MegaD3 (author)HazwerN2016-02-06

it's "stream_localhost" - I had trouble too. It must've changed recently.

HazwerN (author)2016-01-14

can't find "webcam_localhost" in motion.conf file

jbennett38 (author)2015-06-07

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?

Im searching for a way to sync DropCam to Dropbox, if at all possible.

ColmM1 (author)jbennett382015-10-20

@jbennett38 - 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.

MikaelH1 (author)2015-06-29

Thank u so much guy!

iminbali (author)2014-11-08

For anyone having trouble getting the photos to upload to dropbox use this script:

import os
def upload_files():
if not os.path.exists(path):
dir_list = os.listdir(path)
for file_name in dir_list:
if "jpg" in file_name:
print"Upload Pending..."
cmd = "/home/pi/ upload " + path + file_name + " " + dest
if __name__ == "__main__":

Pay attention to indenting which was hard to do on this comment...

Awesome article and very thorough.

Anyone have any advice on configuring passwords for web server?

markbrooke (author)iminbali2015-04-06


I've tried using your script but I get an indent error on line 6.

Any chance you can upload to github or something as I'm not savvy enough with python to fix errors.

This is what I'm doing - I've edited it briefly for my own situation (ie path of uploder, and where the script is located.

import os



def upload_files():

if not os.path.exists(path):


dir_list = os.listdir(path)

for file_name in dir_list:

if "jpg" in file_name:

print"Upload Pending..."

cmd = "/home/pi/Dropbox-Uploader/ upload " + path + file_name + " " + dest


if __name__ == "__main__":


Zatara11 (author)2015-03-26

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.

HenrikH (author)2014-08-09

curl "" -o

ssrivastava14 (author)HenrikH2015-02-25

Yeah_ this was the correction which was to be done,i suppose (this is what i checked).
I am sharing the screenshot i NOW get while running the .sh file.
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.
both the .py files are properly indented and i have used

cmd = "/home/pi/Dropbox-Uploader/ upload %s %s %s" %(path + file_name," ",path + file_name)

following a comment on this page (below).

any help is appreciated. :)

luipez made it! (author)2015-02-01

Ho seguito la tua guida fino al passo 5, ma ottengo quanto nella immagine 1.png
Il mio router è settato così come vedi nella immagine 2.png

Come mai non mi funziona?



I followed your guide through step 5, but I get the image in 1.png
My router is set so as you see in the image 2.png

How come I do not work?

Thank You

vidaa (author)2015-01-24

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 " myapp" it needed the " " then text...

cmd = "/home/pi/ upload " + path + files + " " + file_name

the first files are copy _from_ . the second are copy _to_.

I decided that a prefix of something raspberry flavored was actually a good thing :-)

best to you all


gal-x-e (author)2015-01-19


i just did every thing you said. but it doesn't work.

i have raspberry pi model a, a wifi dongle & MD80 mini camera, all connected to a usb hub. my uploader file contains :

import os
def upload_files():
if not os.path.exists(path):
for files in os.listdir("."):
if files.endswith(".avi"):
cmd = "/home/pi/ upload " + path + files
os.system("sudo rm /tmp/motion/" + files)

if _name_ == "_main_":

any Suggestions?

anggasaputra (author)2015-01-11

still not working on step 7 , please T_T

TimB3 (author)2014-12-26


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?

Thank you in advance!

IvanR1 (author)2014-10-29

Thanks for this useful article!

If it's not working with the RasPi Cam (no /dev/video0) try:
sudo modprobe bcm2835-v4l2

and /dev/video0 should be there; then restart motion.

pengocha (author)2014-08-17

My house got broken into last week so this got me to this tutorial.

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...

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&pi cam (replacing tv/laptop etc costs me enough already :( ).

1) does the script auto start when turning on the pi and if not how can i accomplish this?

2) when motion is detected is it possible to have a 60sec delay before posting to dropbox and further actions?

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?

4) when motion is detected can the pi contact me on my smartphone over facebook messenger/twitter/sms/mail/whatsapp and or others...?

mailto (author)pengocha2014-09-05

1) It should because of the file /etc/init.d/motion, but in case it doesn't...

Just edit rc.local file: sudo nano /etc/rc.local

And add these 2 lines before the exit statement:

# Start motion


2) Modify the file sudo nano

And add this line before "upload_files()": os.system(sleep 60)

3) First install a command line mp3 player: sudo apt-get -y install mpg321

Then add this to /etc/motion/motion.conf: On_picture_save mpg321 whatever.mp3

4) To create a script file that sends emails using Gmail, check this link:

Then add this to /etc/motion/motion.conf: On_picture_save

Hope it helps!

pengocha (author)mailto2014-09-05

wow, didn't expect that much detail. Thank you so much for that ! I'm ordering the parts and will let you know !

StudioDubio (author)2014-05-22

I've tested with the MD80 mini camera but it RPI doesn't recognize it? Please help!

zolore (author)2014-05-14

Hi. Small typo above. The closing HTML tag is missing the /.

The code should be:

<h1> Raspberry Pi DropBox Camera Stream </h1>
<img src="http://Raspberry pi's IP:8081">

TheK1D (author)2014-04-25

Help! i use the sudo python and sudo python but it keeps on shutting down my pi.

TheK1D (author)2014-04-24

I used sudo apt-get install Motion instead of sudo apt-get install motion that was silly of me...

traklikitporn (author)2014-04-17

sudo service motion restart << for start motion

traklikitporn (author)2014-04-17

sudo apt-get install motion << it's work for me

eccentricdyslexic (author)2014-03-22

Am I correct in thinking with dropbox uploader you have to specify the destination folder as well as the local location nowadays?

This works-

cmd = "/home/pi/Dropbox-Uploader/ upload %s %s %s" %(path + file_name," ",path + file_name)

tmv22 (author)2014-03-16 is not working. i get this error message "Uploaded

Traceback (most recent call last):

File "/home/pi/", line 15, in <module>


File "/home/pi/", line 12, in upload_files

os.remove(path + file_name)

OSError: [Errno 13] Permission denied: '/tmp/motion/01-20140316154001.avi'"

tmv22 (author)2014-02-26

i followed all the steps! everything worked EXCEPT step 8. when login to my dropbox, the folder is empty. what went wrong?

nochanceinhell3856 (author)tmv222014-02-26

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.

When it works properly, in your dropbox home folder you will see a folder called Apps. and your videos will be in there.

tmv22 (author)nochanceinhell38562014-02-26

everything is working EXCEPT:

1- i dont see anything in my dropbox APPs. i see the files in tmp/motion though

2- the old files are not being deleted every hour as you mentioned

basic web page streamed the image good. in step 5, your forgot / for <html> but its ok!

no errors during step 6

in step 7, i have everything same as your image. with indentation using TAB on my keyboard.

thanks for your help! i know everyone appreciates your hard work

nochanceinhell3856 (author)tmv222014-02-27

I need to think about why the temp directory isnt clearing out every hour.

But for the Uploader, I think I see the issue stopping the uploader from running.

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.

tmv22 (author)nochanceinhell38562014-02-27

yes, i made changes as you mentioned but still not working. can you share image of your and

nochanceinhell3856 (author)tmv222014-02-28

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.

tmv22 (author)nochanceinhell38562014-02-28

oh yes please post image of your 2 python script!

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?

Guy_Moquet (author)2014-02-18

Thanks - really useful.

Being very new to Python I got stuck at step 7 - I can't get the code 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

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.

camblonie (author)2014-01-01

"Now follow the instructions in the README.txt file in order to link the Raspberry Pi to your DropBox account using OAuth."
Could you link to this txt file please?
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.

Thanks for the instructable!

Sorry I realized I messed up step 6. I have updated it. See my post above.

mikestevens! (author)2014-01-09

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?

After looking at these comments I realized that I messed up step 6 and have updated it (See my post above)

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.

I hope this helps.

nochanceinhell3856 (author)2014-01-11

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

What I should have said is:

Now run the script and follow its instructions


The readme.txt file really just gives the same information I gave above but here is the link to the readme.txt

I am still very new to working with linux and the command prompt.

I just unzipped the files to my home directory.

I hope this helps

About This Instructable




More by nochanceinhell3856:Cheap and Easy Fireplace Heater3D Printed Cake TopperRecovering Files from a Snapped US Flash Drive Repair
Add instructable to: