Introduction: Datalogging to Dropbox With Arduino Yun

Picture of 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

Picture of 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

Picture of Setup Your Yun

Plug in your Yun and connect it to your local network and the Internet following the tutorial here : http://arduino.cc/en/Guide/ArduinoYun#toc13

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

"ssh root@ip_address_of_your_yun"

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 update

opkg install distribute

opkg install python-openssl

easy_install pip

pip install dropbox

Step 4: Add the Upload Script to the SD Card

Picture of 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

Picture of 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.

Comments

maurice.fonhof (author)2015-04-27

Hello,

i get the following message:

/usr/lib/python2.7/site-packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/securit...

InsecurePlatformWarning

Success

I don't know how to solve this.

simschv (author)maurice.fonhof2017-06-12

Hi Maurice, were you able to solve it? I'm having exactly the same problem when running

pip install dropbox

and I have posted the question at the Arduino Yun Forum, at the DropBox forum and got no answer from those.

I would appreciate any hint on how to fix it.

Many thanks in advance

maurice.fonhof (author)simschv2017-06-15

Hello,

No. It never worked. Now i am playing with the Raspberry Pi 3+. I installed Owncloud and it works fine.

Regards,
Maurice

maurice.fonhof (author)2014-11-12

Hello,

I can't pass the authorisation. It keeps telling me:

Error.Cannot connect to Dropbox

Please check app secret and key, and rerun script to get token

I filled in the app secret and key.

What am i doing wrong?

Meadowtec (author)maurice.fonhof2014-12-16

Had the same issue. It's file permission issue on the SD card. The token can't be written to dropbox_auth.cfg.

nathanielbell (author)Meadowtec2016-01-22

You can put in your information into the "dropbox_auth.cfg" file before you copy it to the SD card if you are having permission issues once on the Yun. I find it easier that way, just edit the file in something like brackets.io or notepad++.

nathanielbell (author)Meadowtec2016-01-22

You can put in your information into the "dropbox_auth.cfg" file before you copy it to the SD card if you are having permission issues once on the Yun. I find it easier that way, just edit the file in something like brackets.io or notepad++.

DjLoulou (author)Meadowtec2014-12-17

The problem is in the log.py file.

On line 7 it says :

configfile = '/mnt/sda1/LogToDropbox/dropbox_auth.cfg'

while it should be

configfile = '/mnt/sda1/YunLogToDropbox/dropbox_auth.cfg'

Or you could change the name of the folder to LogToDropbox

:)

Haguen611 (author)DjLoulou2015-09-15

Hi guys,

Im trying to do this instructable but i got the same error. Did the steps one by one. Already checked the route in log.py, but still the same result. Can you help me? Tks in advance.

Did you also generate the access token on the dropbox site. Its on the same page you get your key and secret from. Only difference is you have to click "generate access token"

NaveedR2 (author)2015-12-19

how can i solve this error?

nathanielbell (author)NaveedR22016-01-22

In dropbox_auth.cfg replace the placeholder "app_secret", "app_key" & "access_token" with the ones you get from dropbox when you create your app before you run Step 5. If you don't you are just trying to authenticate to the authors dropbox app and not yours.

rjaa.bokhari (author)2015-03-22

Hi! Would this tutorial work as well for the Uno and Mega boards?

About This Instructable

23,888views

62favorites

License:

More by ankitdaf:Turn your CC2541 based HM-10 Bluetooth Smart Module into an iBeaconGetting Started with the Daflabs ESP8266 ESP-12 Breakout BoardGetting Started with the ESP8266 ESP-12
Add instructable to: