Simple Home Security with Raspberry Pi and DropBox

I’ve set up a simple home security system using my raspberry pi and a playstation eye camera I had lying around. It takes shots every 5 mins, then records continuously if any movement is detected.

Step 1: Connect the raspberry pi into your router via the ethernet. Plug in the usb webcam.

Step 2: Follow this youtube video from MileyORiley to set up your raspberry pi as a webcam server:

Step 3: Sign up for a DropBox account, if you don’t have one.

Step 4: Get the dropbox uploader script from Follow the instructions in the readme file to get connected to your DropBox account. I saved the script under ~/DropboxSync/

Step 5: Create a simple python script to upload files from the webcam directory to Dropbox. I saved the following in file ~/DropboxSync/

import os
def upload_files():
    if not os.path.exists(path):
    dir_list = os.listdir(path)
    first_10 = dir_list[:10]
    for file_name in first_10:
        file_full_path = path + file_name
        cmd = "/home/pi/DropboxSync/ upload " + file_full_path

if __name__ == "__main__":

Step 6: Add a cron job to run the python file every minute. At the command line on the pi run:

crontab -e

Then add the following entry to the bottom:

* * * * * python /home/pi/DropboxSync/ # Sync webcam files dropbox

Files should start appearing in your DropBox account (assuming the motion daemon on the raspberry pi is up and running). I had to play with the settings in motion.conf (see the youtube video) but it seems to be working ok. The python script could do with some better error checking and it should probably avoid using the default temp directory, but it works as a quick hack.


I’ve added the following python script to /home/pi/DropboxSync/ to give a bit of remote control over the camera. It’s a crude hack but is ok for the moment. Basically you add a file called “_cmd.txt” to your DropBox app (where the pictures are downloaded). You place a word on the first line of the file to control the behaviour on the pi:

  • reboot
  • motion start
  • shutdown
  • None

Reboot and shutdown do what they say on the tin, motion start begins the motion daemon and None keeps things the same.

import os
cmd_filename = "_cmd.txt"
download_dir = "/home/pi/DropboxSync/"

def download_cmd_file():
        cmd = download_dir + " download "
        cmd += cmd_filename + " "
        cmd += download_dir + cmd_filename

def get_cmd():
        lines = open(download_dir + cmd_filename)
        for line in lines:
                return line.strip() # return first line in file

def execute_cmd(cmd):
        if cmd == "reboot":
                os.system("sudo reboot")
        elif cmd == "motion start":
        elif cmd == "shutdown":
                os.system("sudo shutdown now")

if __name__ == "__main__":
        cmd = get_cmd()

The “_cmd.txt” file is read from DropBox every 5 mins with the following cron command:

*/5 * * * * python /home/pi/DropboxSync/ # control web cam