Raspberry Pi 003: Automatic upload to dropbox a camerashot

I have been with this idea in my mind for a while. Basically I want to have the Raspberry Pi to get a picture every time it starts and try to upload it to Dropbox.



In this way, it is like a security option and we will learn a few tricks on our way.

First of all. Do you remember our other projects with the Pi?

Raspberry Pi 001: Setup and Run first Arduino-Python project.

Raspberry Pi 002: Pi Camera, start up scripts and remote desktop

So, first step, let’s change Raspberry Pi password to have in in the local Wifi network.

1. Change Password. Open a LXTerminal and run

sudo raspi-config

The configuration window will open. From there just select to change the Password.


2. Change Raspberry Pi network name. By default, when in a Wifi network, the Raspberry Pi will try to get the local hostname “raspberrypi” (that is the name you will write when doing remote desktop to look for the Raspberry Pi). This configuration will create conflicts if there is various Raspberry Pi in the same network. So let’s change the name of the Raspberry Pi in the local network (original tutorial here).

Type the next command to open the host file:

sudo nano /etc/hosts

It will show this window, the last one is the actual name of the raspberry pi in the network


Edit that and put the name you want. In my case I’m going to call it Eneas. Just Ctrl+C and Yes and Enter.

Now edit the hostname file:

sudo nano /etc/hostname

Change here the name also


Save and run the file:

sudo /etc/init.d/hostname.sh

Now just reboot the terminal and you will be able to locate it in the network with the new name. Or in my case to do remote access from windows I don’t need any more the IP, I just type the name (remember the tutorial where I explained how to do remote desktop?).

3 More memory. Do you have a 512mB Raspberry Pi model B? Is it using the 512mB? It seems that by default most of the Pi with 512mB need a firmware update before being able to use the whole memory! How to check it?

free -m


This window will appear. Here we can see the amount of memory used by the system. It is not the whole 512mB since part of the memory is reserved for the GPU. Raspberry Pi shares memory between CPU and GPU. So in my case it is not necessary, but still if you need it:

First install Git Core

sudo apt-get install git-core

Now download the required files

sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update

The next command will update the SSL

sudo apt-get install ca-certificates

Install rpi

sudo apt-get install rpi-update

mkdir -p /lib/modules/3.10.25+/build

and finally update

sudo rpi-update

and voilà!

4 Turbo boost. There is a few things that can be done in order to overclock the Pi, like adjusting the CPU voltage, but most of them will break the warranty. Here is one that will not.

sudo apt-get update && sudo apt-get install raspberrypi* raspi-config

Now launch the config and turn the TURBO mode on

sudo raspi-config

005 006

Reboot and changes will be made.

5 Dropbox. Next step is to connect your Raspberry Pi with Dropbox. We do it through the Dropbox API. First ensure you have Git Core

sudo apt-get install git-core

Next copy the files you need in order to invoke the API

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

Now you will be able to see the next directory

cd Dropbox-Uploader


And inside the folder…


You should now see three files, one of which is called dropbox_uploader.sh. This is the script we’re going to use. Run it.


You should see something like this:


Now you need to go to Dropbox webpage for developers https://www.dropbox.com/developers/apps, login to DropBox and create an “app” by clicking the “create app” button.

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.

Fill the information from Dropbox into the script and everything should be ready.

Now you can try uploading a file from the main folder (in my case named image.jpg).

Command line

cd home/pi/Dropbox-Uploader
./dropbox_uploader.sh upload /home/pi/name_of_upload_file name_of_upload_file


    from subprocess import call
    photofile = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/image.jpg image.jpg"
    call ([photofile], shell=True)

6 Python and saving the start image to Dropbox. This is a nice idea I have that can be implemented as a safety feature. Basically now that we have access to Dropbox API and with the PiCamera installed… (how to setup the PiCamera) it will be a great idea making a script that runs at the start-up takes a picture and uploads it to Dropbox. You can think it as a safety feature. If your Raspberry Pi gets stolen, every time somebody starts it a picture will be taken and send to Dropbox.

First create a Python script that looks like this:

from subprocess import call
try:#We put everything inside a try to avoid running if the camera doesn't work
    import picamera
    import datetime
    camera = picamera.PiCamera()

    photofile = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/"+timestamp+".jpg "+timestamp+".jpg "
    call([photofile], shell=True)

This script will try to run the camera, take a picture and upload it to Dropbox. The format of the time is a little bit tricky and will not work for naming files in Dropbox. It should be fine as it is.

Now as we explained in

Raspberry Pi 002: Pi Camera, start up scripts and remote desktop

Put the script into the start up sequence to run after starting the Pi.

and every time you start the Pi it will take a picture and send it to Dropbox!


In this way if your Pi is stolen and they are not aware of this, you will be able to see images and maybe locate it.

Did you like it?


3 thoughts on “Raspberry Pi 003: Automatic upload to dropbox a camerashot”

  1. Thanks for the great tutorial. I got the Pi to upload a photo on reboot. The photos are on the dark side (under exposed). Is there a way to adjust the script to make them brighter? I am new to coding. Thanks again.

    1. Hi Paul,
      Sorry for the delay, I was waiting to see if someone else wanted to answer. In the official webpage there is a reference of other commands. https://www.raspberrypi.org/documentation/usage/camera/python/README.md
      I think you need to play with some of these
      camera.contrast = 0
      camera.brightness = 50
      camera.saturation = 0
      camera.ISO = 0
      You can add them in the script after the commands
      Please, let us know if you solved the problem and what’s the outcome.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s