No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Plant Cam

Create App

Why? What?

At the moment the code just takes one photo every time it is run. I am planning on running it using cron.

**PLEASE NOTE - Don't panic, I have changed all the keys and things, so I'm not leaking personal info **

Setting Up Dropbox

Sign up to Dropbox Apps

Create App

Create App

Dropbox API app

Create App

  1. What type of data does your app need to store on Dropbox? Files and datastores
  2. Can your app be limited to its own folder? Yes
  3. Name your app
  4. Create App.

Create App

You will need this information for later:

  • App key
  • App secret

Setting Up Raspberry Pi

Fresh Raspian install

enable camera (if you miss it the first time, just run raspi-config) - This ask you to then reboot the pi.

Make sure you are connected to the Internets. (I would SSH into your pi now)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
sudo pip install dropbox

Depending on your internet connection this may take a while.

Then we want to download this github repo.:

git clone

Enter the directory

cd plant_cam

Setting up API

We need to put in our app key and secret, so open


Replace key and secret with your Dropbox details. It should look something like this:

app_key = '059dr5c4cpncyhe'
app_secret = 'yjz7d06x3s462t6'

Run the script


Authorising Dropbox

First time you run it will ask you to authorise the app use with Dropbox. Follow the the instructions in terminal.

pi@raspberrypi ~/plant_cam $ python
1. Go to:
2. Click "Allow" (you might have to log in first)
3. Copy the authorization code.
Enter the authorization code here:

Create App Create App Once you've entered your authorisation code it will save your access_token in the and you won't need to authorise it again. It'll look something like this:

key = 'Yk3H7pri9Z0AAAAAAAAgrb4SFdLYqEdpMOR-Vv-wSJoVSQhiO7AYm2SXsWN1Ycbk'

If you want to re-authorise, if you have a new app key and secret for example. Open in nano and remove the key string, leaving it looking like this:

key = ''


After the first time you will see:

pi@raspberrypi ~/plant_cam $ python
You are authorised!
Captured img2014-06-20_10-36-25.jpg
sending img2014-06-20_10-36-25.jpg to dropbox
uploaded: img2014-06-20_10-36-25.jpg

Create App

And it's uploaded to Dropbox! oh... but you see the time and date is all wrong? That's annoying..

Set Date and Time

sudo apt-get install ntpdate

Then we want to make sure we are set to the right timezone.

sudo raspi-config

Select 4 - Internationalisation Options Select I2 - Change Timezone Select the correct place for you and you will see something like this:

Current default time zone: 'Europe/London'
Local time is now:      Fri Jul 18 18:13:36 BST 2014.
Universal Time is now:  Fri Jul 18 17:13:36 UTC 2014.

So, let's try taking another photo.

Create App That's better!

Scheduling the script

sudo crontab -e

We are using sudo crontab because we may want to use the GPIOs in future. Add this line to run the script every 15 minutes. :

*/15 * * * * python /home/pi/plant_cam/ >> /home/pi/picamera-dropbox.log 2>&1

Soon your SD card will fill up with images. So, add this line to delete files every day at 8pm:

0 20 * * * find /home/pi/plant_cam -mtime +24 -name 'plant*' -exec rm {} \;

Save this file.

Create your log file

touch picamera-dropbox.log

to watch the log updating:

watch cat picamera-dropbox.log

It'll look something like this:

You are authorised!
Captured img2014-07-18_19-04-05.jpg
sending img2014-07-18_19-04-05.jpg to dropbox
uploaded: img2014-07-18_19-04-05.jpg