Temboo, Dropbox & Blynk - A Free Combination For Makers

Temboo, Dropbox & Blynk - A Free Combination For Makers © GPL3+

Temboo is very easy to automate the IoT with Arduno YUN, in combination with Blynk and Dropbox to store pictures. All is free and easy.

  • 1,343 views
  • 0 comments
  • 8 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

Introduction

Temboo permits to créate Arduino applications using Temboo/Choreo platfom to link to Dropbox application folder. Therefore, after creating this APP in Choreo and Dropbox, and after an authorization procedure, you can do things like activate an input in your Arduino YUN. This board will send the command to the Linino side of the YUN to take a picture, and thanks to the Temboo/Choreo tool, this picture will be uploaded to your Dropbox app folder.

I have followed up, line by line, the following tutorial from Adafruit, and it works properly.

Step 1

There are some Little issues when you run the Authout sketch but after loading the Tembo example of the Arduino IDE, just the example sketch of Temboo, UploadToDropbox, the communication to Choreo is established, and the picture can be uploaded to Dropbox Automatically.

https://learn.adafruit.com/wireless-security-camera-arduino-yun/introduction

I recommend to buy the same camera c270, since there are some incompatible cameras in Linux and the first time when I started with the project, I waste a couple of days with a problem of incompatibility.

Then, having the hardware, all works. 

Step 2

When you register the first time to Temboo, you can have 30 days plan with 100,000 calls and after this first month you will have the free plan with 250 calls.

"Call" is similar like a data transaction. If you upload a picture you will spend one or two calls. For one calendar month you have 250 calls and it is enough for playing and have an experience with Temboo.

Enjoy.

Conclusions

I have also added the Blynk library because you can add a control panel of the desired process from your mobile all around the world.

Code

Arduino sketch to take a picture using the fswebcam command to be uploaded to DropboxArduino
We call fswebcam command in Linino, and we use a Python script shwon on the Adafruit tutorial called wireless-security-camera-arduino-yun.pdf
// Sketch to upload pictures to Dropbox when PUSHBUTTOM IN BLYNK is pressed
// be aware that temboo will permit till 250 calls to Temboo per calendar month in the free plan.


#include <Bridge.h>
#include <Process.h>
#include <BridgeClient.h>
#include <BridgeServer.h>
#include <BlynkSimpleYun.h>

//Blynk authorization code for the Blynk
char auth[] = "YOUR AUTHO TOKEN OF YOUR BLYNK PANEL";

// Picture process
Process ProcesoLinino;

// Filename
String filename, file_ino;

// Pines
int hacerfoto = 8; //When it is ON we take the picture
int pin13 =13; //only for diagnostics

// Path
String path = "/mnt/sda1/";   //SD card root in the YUN

// To define the variables for the LEDs on the Blynk panel
// They will be activated through the Arduino sketch and Blynk // will update their states

//****************************************************************************************************
// Meaning of the LEDs widges with:
//*********************************
// led1 will be solid when the command fswebcam is sent to 
// Linino to take the picture.

// led2 will be solid when we call the phyton script to upload // the taken picture to DropBox

// led3 will blink as an indicator of Arduino YUN is running // and there is comunication with Blynk

    WidgetLED led1(V1);     
    WidgetLED led2(V2);
    WidgetLED led3(V3); 
//****************************************************************************************************

void setup() {
  Serial.begin(9600);
  file_ino="yun_camera060317.ino";
  
  // Bridge takes about two seconds to start up
  // it can be helpful to use the on-board LED
  // as an indicator for when it has initialized  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Serial.println("Sent auth to Blynk...");
  Blynk.begin(auth);//Sent auth to Blynk...
  Serial.println("Activating Bridge to Linino.......");
  Bridge.begin();//Activating Bridge to Linino.......
  digitalWrite(13, HIGH);
  // Set pin mode
  pinMode(hacerfoto,INPUT);
  Serial.print("Fichero INO -->  ");
  Serial.println(file_ino);
  delay(3000);
}

void loop(void) 
{
 // Initialize the client library for Blynk
  Blynk.run();
  Serial.println("Blynk running....");
  digitalWrite(13, LOW);
  led3.setValue(255);
    if (digitalRead(hacerfoto) == HIGH) 
    {
                // To create filename as the retuned value of timeStamp.
                filename = "";
                Serial.print("1. To name the picture file as the timestamp  ");
                digitalWrite(13, LOW);
                ProcesoLinino.runShellCommand("date +%s");
                while(ProcesoLinino.running()); //Waiting while ProcesoLinino to get the timestamp is running
                led3.setValue(0);
                Serial.print("2.Returned code after Process completed. 0 is OK, any other number when there was a failure....   ");
                Serial.println(ProcesoLinino.exitValue());////////////////
                while (ProcesoLinino.available()>0) { //While there are values returned by the process, in this case the instance of the process returns an String with the timestamp.
                char c = ProcesoLinino.read();
                filename += c;
                } 
                filename.trim();
                Serial.println(filename);
                filename += ".png";   //Filename is composed including its extension
                
                ////INSTEAD TO UPLOAD MANY FILES WITH TIMESTAMP AS FILENAME DUE TO DELETE THEM AT DROPBOX IS DIFICULT, I OVERWRITE THE FILENAME TO A FIX NAME.
                filename = "FOTOYUN.png";
                
                // Mount the SD
                ProcesoLinino.runShellCommand("cd  /mnt/sda1");
                Serial.print("3.Returned code after request change directory where the SD card is....  ");
                Serial.println(ProcesoLinino.exitValue());////////////////// 
                led3.setValue(255);
                
                // Take picture 
                Serial.println("3.To send the comand fswebcam to Linino to take the picture , store the picture at the desired path and filenam and also adjusting its resolution");
                digitalWrite(13, HIGH);
                led1.setValue(255);
                led3.setValue(0);
                ProcesoLinino.runShellCommand("fswebcam " + path + filename + " -r 1280x720");
                while(ProcesoLinino.running()); //Waiting while ProcesoLinino to get the picture... fswebcam... is running
                digitalWrite(13, HIGH);
                Serial.print("4.Returned code after running fswebcam command is....  ");
                Serial.println(ProcesoLinino.exitValue());//////////////////////////////////////////////
                digitalWrite(13, LOW);
                led3.setValue(255);
                led1.setValue(0);
                
                // Upload to Dropbox
                led2.setValue(255);
                Serial.println("5.To upload to Dropbox, a python scrip is ran by the Linino");
                digitalWrite(13, LOW);
                ProcesoLinino.runShellCommand("python " + path + "upload_picture.py " + path + filename);
                while(ProcesoLinino.running());
                led3.setValue(0);
                Serial.println("6.Returned code after ran the python script that upload the filename to Dropbox....    ");
                Serial.println(ProcesoLinino.exitValue());//////////////////////////////////////////////
                led2.setValue(0);
                led3.setValue(255);
                Blynk.email("emailto@gmail.com",filename,"https://www.dropbox.com/home/Aplicaciones/mmc2vlcAPP1"); // An email is sent after uploading the picture to Dropbox by using Blynk.
                delay(5000);
                led3.setValue(0);
                delay(5000);
                led3.setValue(255);
                delay(5000);
                led3.setValue(0);
                delay(5000);
                led3.setValue(255); //THESE LINES ARE JUST TO CREATE THE BLYNKING EFFECT OF THE LED3 AS A WATCHDOG LED
                delay(5000);
                led3.setValue(0);
                delay(5000);
                led3.setValue(255);
                delay(5000);
                led3.setValue(0);
                delay(5000);
              
      }
        else
        {
        Serial.println("Awaiting for user to press the Blynk buttom remotelly.................");
          
          }

      led3.setValue(255);
      delay(2000);
      led3.setValue(0);
      delay(2000);        
          
            
}
Scrip file from Adafruit tutorialPython
You need to change some parameters after Temboo and Dropbox application is created
# coding=utf-8
# Script to upload files to Dropbox

# Import correct libraries
import base64
import sys
from temboo.core.session import TembooSession
from temboo.Library.Dropbox.FilesAndMetadata import UploadFile

print str(sys.argv[1])

# Encode image
with open(str(sys.argv[1]), "rb") as image_file:
    encoded_string = base64.b64encode(image_file.read())

# Declare Temboo session and Choreo to upload files
session = TembooSession('yourSession', 'yourApp', 'yourKey')
uploadFileChoreo = UploadFile(session)

# Get an InputSet object for the choreo
uploadFileInputs = uploadFileChoreo.new_input_set()

# Set inputs
uploadFileInputs.set_AppSecret("yourAppSecret")
uploadFileInputs.set_AccessToken("yourAccessToken")
uploadFileInputs.set_FileName(str(sys.argv[1]))
uploadFileInputs.set_AccessTokenSecret("yourTokenSecret")
uploadFileInputs.set_AppKey("yourAppKey")
uploadFileInputs.set_FileContents(encoded_string)
uploadFileInputs.set_Root("sandbox")

# Execute choreo
uploadFileResults = uploadFileChoreo.execute_with_results(uploadFileInputs)

Comments

Similar projects you might like

Introduction to the Blynk IoT service

by Rafa Juárez

  • 2,355 views
  • 1 comment
  • 9 respects

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,854 views
  • 17 comments
  • 75 respects

Back Up SD File to Dropbox

Project tutorial by Andrei Florian

  • 3,898 views
  • 6 comments
  • 36 respects

Monitoring Temperature Remotely with Blynk for Dummies

Project in progress by Cmtelesann

  • 3,121 views
  • 6 comments
  • 11 respects

Arduino 101 Blynk and BLE Example Panel

by Rafa Juárez

  • 1,463 views
  • 0 comments
  • 5 respects
Add projectSign up / Login