Raspberry Pi Surveillance Camera + Dropbox Upload

This tutorial will show you how to setup your Raspberry Pi Surveillance Camera for home security or to watch your fish tank while you’re away. I am going to use the Raspberry Pi Camera Module and Motion software.

1. Install motion, turning motion on by default

sudo apt-get install motion -y
sudo apt-get install libjpeg62 -y
sudo nano /etc/default/motion

Now set start_motion_daemon=yes

Raspberry Pi Surveillance Camera

Raspberry Pi Surveillance Camera


 2. Change permissions of locations where default motion images are stored.

sudo chmod -R 755 /etc/motion/motion.conf
sudo chmod -R 755 /tmp/motion
cd /tmp

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


3. Download Pi Cam Driver

wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz


4. Unpack and Move the Downloaded Files

tar zxvf motion-mmal.tar.gz

sudo mv motion /usr/bin/motion

sudo mv motion.conf /etc/motion.conf


5. Turn on Motion Daemon by default

sudo nano /etc/default/motion 
Changes to make: 

ctrl-x, Y and enter to save

6. Create storages for images

sudo chmod 664 /etc/motion.conf 
sudo chmod 755 /usr/bin/motion 
sudo touch /tmp/motion.log

sudo chmod 775 /tmp/motion.log 
cd /home/pi 
mkdir motion


To Modify motion.conf File

sudo nano /etc/motion.conf

Make these changes to the motion.conf file:

deamon on
logfile /tmp/motion.log
rotate 180
width 1280
height 720
framerate 10
threshold 0
ffmpeg_video_codec msmpeg4 (necessary to stream to windows based pc’s)
snapshot_interval 60 (every minute one snapshot)
text_left PI_CAMERA %t (PI_CAMERA can be any name you like and will appear on the image)

The following commands create file locations, A folder per day, per camera, per capture type. File names show camera number, image number, date & time

snapshot_filename %Y%m%d/camera%t/snapshots/camera-%t-%v-%Y%m%d%H%M%S

picture_filename %Y%m%d/camera-%t/motions/camera-%t-%v-%Y%m%d%H%M%S-%q

movie_filename %Y%m%d/camera-%t/movies/camera-%t-%v-%Y%m%d%H%M%S
move_timelapse_filename %Y%m%d/camera-%t/timelapses/camera-%t-%Y%m%d
stream_port 8081

stream_localhost off

ctrl-x, Y and enter to save

sudo /etc/init.d/motion restart
sudo reboot

Access Stream


Dropbox Uploader

First, clone the repository using git (recommended):

git clone https://github.com/andreafabrizi/Dropbox-Uploader/

Then give the execution permission to the script and run it:

chmod +x dropbox_uploader.sh

The first time you run


, you’ll be guided through a wizard in order to configure access to your Dropbox. This configuration will be stored in



Using the Scripts

The syntax is quite simple:

./dropbox_uploader.sh COMMAND [PARAMETERS]...

[%%]: Optional param
<%%>: Required param

After this you can create scripts to upload and use any images. I use this script to move all of my snapshots to a tmp folder to upload and remove afterwards.

mv /home/pi/img/* /home/pi/tmp
echo ""
echo ""
echo "Beginning Dropbox Upload..."
echo "Files have been moved from img to tmp..."
echo "Uploading all files in tmp to Dropbox..."
echo "..."
echo "..."
echo "..."

#uploads all files to dropbox folder
cd /home/pi/Dropbox-Uploader
./dropbox_uploader.sh upload /home/pi/tmp/* /Apps/CSE4471RaspberryPiUploader/

sleep 5

#alerting user
echo "..."
echo "Images Uploaded!"
echo "..."
echo "Cleaning tmp images..."

#removing all images that have been already uploaded
rm -rf /home/pi/tmp/*
echo "..."
echo "..."
echo "..."
echo "Complete!"


Purchase the Hardware

Links to purchase some of the Raspberry Pi hardware used can be found on Amazon here.


[1] Setting up Wireless motion-detect cam http://rbnrpi.wordpress.com/project-list/setting-up-wireless-motion-detect-cam/
[2] Raspberry Pi Camera Module Information http://www.raspberrypi.org/products/camera-module/
[3] How to use Dropbox with Raspberry Pi http://raspi.tv/2013/how-to-use-dropbox-with-raspberry-pi
[4] Github Dropbox Uploading Documentation https://github.com/andreafabrizi/Dropbox-Uploader
[5] Official IFTTT (If This Then That) Website https://ifttt.com/dashboard
[6] Information Regarding IFTTT (If This Then That) http://mitchtech.net/connect-raspberry-pi-to-gmail-facebook-twitter-more/
[7] MMAL Motion – Tuning & Optimizations http://www.raspberrypi.org/forums/viewtopic.php?t=75240&p=546758
[8] Cron Tasks to Update and Upgrade Raspberry Pi Packages http://www.techrepublic.com/article/automatically-update-your-ubuntu-system-with-cron-apt/

You may also like...

3 Responses

  1. Jarod says:

    I had a question about the images being saved. What directory will they be saved once they are taken? The /img directory?

    • Michael says:

      My motion.conf file has them being saved to /home/pi/img/ and then the MoveAndUpload.sh script moves them from there to the /home/pi/tmp/ directory for upload. After they are uploaded the files will be removed to save space on your Pi!

    • Michael says:

      So in your motion.conf file there is a parameter called ‘target_dir’ where the default value is the current working directory. If you want to change it to something like /home/pi/img/ it would save to the img folder. Let me know if you have any other questions!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.