This is an example configuration of uploading images to Dropbox from a Raspberry PI. The images are then linked to a Google sites webpage. Prerequisites
Raspberry configurationCreate a folder for storing the images and scripts. On the Raspberry PI command line
Start by downloading the Dropbox uploader from Github and configuring it: https://github.com/andreafabrizi/Dropbox-Uploader cd /home/pi/scripts curl " https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh " -o dropbox_uploader.sh chmod 755 dropbox_uploader.sh At this point you must have created your Dropbox API key here: https://www.dropbox.com/developers/apps Next start the dropbox_uploader for the first time to create the config file. Enter the API key
and secret and follow instructions to configure. Note that the dropbox uploader
configuration file is created in users home directory ~/.dropbox_uploader. This
means that the cron task must be running as this user and cannot be added to
cron.hourly without modifications. ./dropbox_uploader.sh Shell scriptsThree scripts are created to make this work, they could be run in just one script, but this allows them to be timed differently. Webcam SnapshotThis script takes a snapshot with the webcam using fswebcam. Start by Installing fswebcam
sudo apt-get install
fswebcam
Create script using your favourite text editor in /home/pi/scripts/snapshot.sh The script creates a logical link to the latest snapshot that is used on the Google sites website. #!/bin/bash DATEFOLDER=$(date +"%Y-%m-%d") DATE=$(date +"%Y-%m-%d_%H%M") mkdir -p /home/pi/images/$DATEFOLDER fswebcam -r 1280x960 --jpeg 95 /home/pi/images/$DATEFOLDER/$DATE.jpg #Make logical link to latest image ln -f -s /home/pi/images/$DATEFOLDER/$DATE.jpg /home/pi/images/webcam.jpg Image upload scriptCreate a file to export daily graphs from Cacti and upload everything to Dropbox /home/pi/scripts/greenhouse_to_dropbox.sh #!/bin/sh #get temperature Cacti Graph for dropbox export wget " http://192.168.1.2/cacti/graph_image.php?action=view&local_graph_id=102&rra_id=2 " -O /home/pi/images/temperature.png #upload temperature and latest webcam picture to dropbox /home/pi/scripts/dropbox_uploader.sh upload /home/pi/images/temperature.png temperature.png /home/pi/scripts/dropbox_uploader.sh upload /home/pi/images/webcam.jpg webcam.jpg Cleanup scriptThis script uploads yesterdays images to a folder in Dropbox and removes them from Raspberry PI /home/pi/scripts/cleanup.sh #Cleanup old images and upload to Dropbox yesterday=$(date --date="yesterday" +"%Y-%m-%d") /home/pi/scripts/dropbox_uploader.sh -p upload /home/pi/images/$yesterday/ /imagearchive/$yesterday/ rm -rf /home/pi/images/$yesterday/
Add rights to execute the scriptschmod 755 greenhouse_to_dropbox.sh chmod 755 cleanup.sh chmod 755 snapshot_10minutes.sh Create Cron jobs for user PI
|
Home Automation >