Introduction: Datalogging to Dropbox With Arduino Yun
This instructable is an extension to the Datalogger for Arduino Yun. This lets you use the Yun to log your sensors to the SD card, and uses Python and the Dropbox API to store the logged data periodically so you don't lose your data to the elements.
The link to the Github repository is here : https://github.com/ankitdaf/yun-datalogger-dropbox
Step 1: Setup Your Dropbox App
Create a Dropbox account if you don't have one already. You can do that here : http://www.dropbox.com
Next, go to the Dropbox Apps Console here : https://www.dropbox.com/developers/apps/create
Create an app with the options shown in the image.
Note down the app key and the app secret that you get when you create this, we will use it later.
Step 2: Setup Your Yun
Make sure you have plugged in your SD card to the Yun. It should show up at the location "/mnt/sda1" when you SSH into the Yun.
You can SSH into the Yun by typing
in the Linux Terminal. Refer to http://arduino.cc/en/Guide/ArduinoYun if you are using it on Windows.
Step 3: Install Necessary Python Packages
openwrt on the Linux processor of the Yun comes with a lean Linux install and does not contain all the packages. Run the following commands after SSHing into the Yun to install the necessary packages for the Python script to work.
opkg install distribute
opkg install python-openssl
pip install dropbox
Step 4: Add the Upload Script to the SD Card
Download the zip file attached, unzip it, and upload the folder to the Yun using the scp command on the terminal as shown. This will upload the Python script containing the Dropbox upload code to the SD card. We will then be calling (running) the script from the Yun's micro-controller side.
The Python script uses the Dropbox Python SDK Core API
Step 5: Authenticate the Yun With Dropbox
SSH into the Yun, and edit the dropbox_auth.cfg files, entering the app key and app secret from the previous step. Do not include any special characters while editing.
Next, run the script as in the image, copy the URL to your web browser, and authenticate the app. Copy the key back into the terminal and press enter, and authentication should be done. Once that is done, you can use the access token until you manually deauthorize or delete the app.
Step 6: Setup the Arduino Sketch to Call the Python Script
Download the sketch attached and upload it to the Yun.
This is a modified version of the DataLogger example in the Bridge Library.
The code is well commented, but it polls the three analog sensors A0 to A2 one by one, constructs a text string and writes it to a file on the SD card on the Yun. Once that is done, we call the Python script that uploads the log file to Dropbox, replacing the previous log.
You can modify your sensors in the sketch code, and also the filename if you want to have a different file for every day or hour.
We have a be nice policy.
Please be positive and constructive.