The Temboo service has moved away from Arduino support. The service access in this older guide will no longer work.
What we want to achieve in this first application is to take a picture whenever some motion is detected by the PIR motion sensor. And when that happens, store this picture locally on the SD card, and upload it to Dropbox. To do so, the code will be composed of two parts. The first one is a Python script that will connect to Dropbox, take a picture on the SD card, and then upload this picture to Dropbox. The reason to use Python for this part is that it is much easier to upload files to Dropbox using Python than directly from the Arduino sketch. The second part of the code will be the Arduino sketch itself, which will basically call the Python script to take pictures via the Bridge library of the Yun.

Let's first code the Python script. It starts by including the required libraries from the Temboo Python SDK:
from temboo.core.session import TembooSession
from temboo.Library.Dropbox.FilesAndMetadata import UploadFile
The Python script will also take the name of the picture we want to upload as an argument:
with open(str(sys.argv[1]), "rb") as image_file:
  encoded_string = base64.b64encode(
Remember these Temboo credentials that you created earlier ? That's where you need to enter them:
session = TembooSession('yourTembooName', 'yourTembooApp', 'yourTembooKey')
We can then create the correct Dropbox library to upload files, called a "Choreo" on Temboo:
uploadFileChoreo = UploadFile(session)
uploadFileInputs = uploadFileChoreo.new_input_set()
It's now the time to enter all the informations about your Dropbox account, like your app Key, app Secret, Access Token an Access Token Secret:
And finally, upload the file on Dropbox:
uploadFileResults = uploadFileChoreo.execute_with_results(uploadFileInputs)
You can now save this code in a file named Note that all the files are available on the GitHub repository of the project:

We'll now work on the Arduino sketch. The sketch starts by including the required libraries:
#include <Bridge.h>
#include <Process.h>
We also have to declare a process, that we are going to use to call functions on the Linux machine of the Yun (for example the fswebcam utility we used before):
Process picture;
We are also going to build a filename for each picture the project will take, that will be stored in a string:
String filename;
We also declare the pin on which the PIR motion sensor is connected:
int pir_pin = 8;
And the path of the SD card on the Yun:
String path = "/mnt/sda1/";
Because we need to call functions on the Linux machine of the Yun, we have to start the Bridge:
Then, in the loop() part of the sketch, we check if some motion was detected by the PIR sensor:
if (digitalRead(pir_pin) == true) {
If this is the case, we build a unique filename for the picture, with the date at which the picture was taken:
filename = "";
picture.runShellCommand("date +%s");

while (picture.available()>0) {
  char c =;
  filename += c;
filename += ".png";
We then make the first call to the Linux machine of the Yun, first to take a picture with the fswebcam utility. Note that here, we provide an extra argument with the -r command, which set the resolution. I used the maximum resolution of my camera, which is 720p:
picture.runShellCommand("fswebcam " + path + filename + " -r 1280x720");
We then make a second call to the Linux machine, this time calling the Python script with the name of the picture as an argument, which will upload the picture to Dropbox:
picture.runShellCommand("python " + path + " " + path + filename);
You are now ready to test the project. Again, all the files are available on the GitHub repository of the project:

First, put the Python file at the root of the SD card, and put the SD card back into the Arduino Yun board. Then, upload the Arduino sketch to the Yun. Now, try to trigger the motion sensor, for example by waiving your hand in front of it. You should see that the webcam is being activated shortly after (for example, my webcam has a LED that turns green when it is active).

To check that the project is working correctly, after a while you can check the SD card, you should see that some pictures have been recorded:
You can also check on your Dropbox folder, where the same pictures should have been uploaded. They should be located in your Dropbox apps folder:

This guide was first published on Mar 31, 2014. It was last updated on Mar 31, 2014.

This page (Upload pictures to Dropbox) was last updated on May 09, 2021.

Text editor powered by tinymce.