Close

Raspberry Pi Camera and DropBox

A project log for Cats in Motion

To help build a perfect shelter for feral cats and protect them from the harsh climate. To reduce suffering for those who have no voice.

brenda-armourBrenda Armour 03/26/2016 at 19:190 Comments

Raspberry Pi camera and Dropbox

I have used the Raspi_Cam_Web_Interface to capture stop motion pictures and videos. But I decided I would like the process to be more automated. I looked at pushing the media to a cloud so I would not have to manually download the images. I decided to try Dropbox and it works well with very little python code.

You need to set up a DropBox account and then set up an app to link to your Raspberry Pi. You can set up your app at:https://www.dropbox.com/developers/apps/

Then choose “Dropbox API app”, “Files and Datastores”, and answer the final question “Can your app be limited to its own, private folder?” – either answer is OK, depending on your needs.

It supplies an App Key and App Secret. You will be using this to link to your Pi.

Now we want to install Dropbox for Raspberry Pi:

git clonehttps://github.com/andreafabrizi/Dropbox-Uploader/

Once downloaded you can make the script executable by using the following command:

chmod +x dropbox_uploader.sh

The first time you run the script you will be asked to enter the App Key and App Secret.

./dropbox_uploader.sh

HINT:Copy the Keys to a text editor first rather than copy and paste from Putty to DropBox. Otherwise it does not play nice and you may have errors.I used Notepad. Once your Keys are accepted it will ask you to open up a URL to confirm connection.Assuming you are using Putty, copy the contents to your clipboard and paste to a text editor. Now copy the URL to a browser. You may receive a message from Dropbox that the connection is successful but unless you perform the last step in Putty the token may still fail. Some oauth tokens are corrupt so you may have to try a couple of times.

RaPiCamcoder stores media files in /var/www/media. So I want a script to pull the .jpg files to Dropbox and see the media on my Blackberry and Laptop in real time.I tried a couple of test.jpg and it seemed to work like a charm.

I used this script to start the downloader:

pi@raspberrypi ~/Dropbox-Uploader $ ./dropbox_uploader.sh upload /var/www/media/ {*.jpg*} /Apps/PiRover

This was tricky. Most documentation did not include a target file for the upload and failed. I took several scripts and reduced the code to one line and added the target DropBox. The command tells Raspberry Pi to upload all files ending in .jpg in /var/www.media (location that Raspi_Cam_Web stores the images) and upload to my DropBox App called PiRover.

I setup a full Dropbox instead for final testing and called it PiRover. When I ran the script the images stored in /var/www/media uploaded to DropBox at a fairly good speed and now is accessible on my Blackberry and Laptop in minutes.

A cron job is added to run the script every minute and I’m done! I will add a cleanup cron job so the SD card does not fill up too fast.


The camera in the foreground is the Raspberry Pi camera and the second is the Raspberry Pi Noir. I plan to include a Infrared light for the Raspberry PI Noir for night vision.

Below is a sample screen shot from DropBox.

So there is more work on cameras. Enclosures will have to be weather proof .

Discussions