aboutsummaryrefslogtreecommitdiff
path: root/libraries/Bridge/examples
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/Bridge/examples')
-rw-r--r--libraries/Bridge/examples/BootWatcher001/BootWatcher001.ino90
-rw-r--r--libraries/Bridge/examples/Bridge/Bridge.ino150
-rw-r--r--libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino94
-rw-r--r--libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino58
-rw-r--r--libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino55
-rw-r--r--libraries/Bridge/examples/Datalogger/Datalogger.ino90
-rw-r--r--libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino65
-rw-r--r--libraries/Bridge/examples/HttpClient/HttpClient.ino23
-rw-r--r--libraries/Bridge/examples/OLDYahooWeather/OLDYahooWeather.ino94
-rw-r--r--libraries/Bridge/examples/Process/Process.ino70
-rw-r--r--libraries/Bridge/examples/ShellCommands/ShellCommands.ino52
-rw-r--r--libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino109
-rw-r--r--libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino185
-rw-r--r--libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino142
-rw-r--r--libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino147
-rw-r--r--libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino160
-rw-r--r--libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino184
-rw-r--r--libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino174
-rw-r--r--libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino133
-rw-r--r--libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino212
-rw-r--r--libraries/Bridge/examples/TimeCheck/TimeCheck.ino79
-rw-r--r--libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino32
-rw-r--r--libraries/Bridge/examples/XivelyClient/XivelyClient.ino110
-rw-r--r--libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino73
24 files changed, 2581 insertions, 0 deletions
diff --git a/libraries/Bridge/examples/BootWatcher001/BootWatcher001.ino b/libraries/Bridge/examples/BootWatcher001/BootWatcher001.ino
new file mode 100644
index 0000000..7833d54
--- /dev/null
+++ b/libraries/Bridge/examples/BootWatcher001/BootWatcher001.ino
@@ -0,0 +1,90 @@
+
+/*
+ Arduino Yun Boot watcher
+
+ Allows you to use the Yun's 32U4 processor as a
+ serial terminal for the linino processor
+
+ Upload this to an Arduino Yun via serial (not WiFi)
+ then open the serial monitor at 115200 to see the boot process
+ of the linino processor. You can also use the serial monitor
+ as a basic command line interface for the linino processor using
+ this sketch.
+
+ The circuit:
+ * Arduino Yun
+
+ created March 2013
+ by Massimo Banzi
+ modified 26 May 2013
+ by Tom Igoe
+
+ This example code is in the public domain.
+ */
+
+long baud = 115200;
+
+// Pin 13 has an LED connected on most Arduino boards.
+// give it a name:
+int led = 13;
+int ledState = HIGH; // whether the LED is high or low
+
+String bootString = "";
+int bootLineCount = 0;
+boolean booting = true;
+
+void setup() {
+ Serial.begin(baud); // open serial connection to Linino
+ Serial1.begin(baud); // open serial connection via USB-Serial
+
+ // initialize the digital pin as an output.
+ pinMode(led, OUTPUT);
+ digitalWrite(led, ledState); // turn the LED on (HIGH is the voltage level)
+ while(booting) {
+ listenForBoot();
+ }
+ delay(500);
+}
+
+
+void loop() {
+ // After booting, become a serial terminal:
+ if (Serial.available()) { // got anything from USB-Serial?
+ char c = (char)Serial.read(); // read from USB-serial
+ Serial1.write(c); // write to Linino
+ ledState=!ledState; // invert LED state
+ digitalWrite(led, ledState); // toggle the LED
+ }
+ if (Serial1.available()) { // got anything from Linino?
+ char c = (char)Serial1.read(); // read from Linino
+ Serial.write(c); // write to USB-serial
+ }
+
+}
+
+void listenForBoot() {
+ char c;
+ if (Serial1.available()) { // got anything from Linino?
+ c = (char)Serial1.read(); // read from Linino
+
+ if (c == '\n') { // clear the bootString every newline
+ bootLineCount++; // increment the boot line counter
+ Serial.println(bootLineCount); // print the count
+ bootString = ""; // clear the boot string
+ }
+ else { // anything other than newline, add to string
+ bootString += c;
+ }
+ }
+
+ // look for the final boot string message:
+ if (bootString.endsWith("entered forwarding state")) {
+ Serial1.println();
+ }
+
+ // look for the command prompt:
+ if (bootString.endsWith(":/#")) {
+ Serial.println("Ready for action.");
+ booting = false;
+ }
+}
diff --git a/libraries/Bridge/examples/Bridge/Bridge.ino b/libraries/Bridge/examples/Bridge/Bridge.ino
new file mode 100644
index 0000000..c7627b2
--- /dev/null
+++ b/libraries/Bridge/examples/Bridge/Bridge.ino
@@ -0,0 +1,150 @@
+
+//#include <Bridge.h>
+#include <Mailbox.h>
+
+void setup() {
+ pinMode(13,OUTPUT);
+ digitalWrite(13, LOW);
+ Bridge.begin();
+ digitalWrite(13, HIGH);
+ Serial.begin(9600);
+}
+
+void loop() {
+ while (Mailbox.messageAvailable()) {
+ String msg;
+ Mailbox.readMessage(msg);
+ process(msg);
+ }
+ delay(100); // Poll every 0.100s
+}
+
+void process(String command) {
+ Serial.println(command);
+ // "digital/13" -> digitalRead(13)
+ // "digital/13/1" -> digitalWrite(13, HIGH)
+ // "analog/2/123" -> analogWrite(2, 123)
+ // "analog/2" -> analogRead(2)
+ // "mode/13/input" -> pinMode(13, INPUT)
+ // "mode/13/output" -> pinMode(13, OUTPUT)
+
+ // is digital command?
+ if (command.startsWith("digital/")) {
+ // extract subcommand (after the "/")
+ command = command.substring(8);
+ digitalCommand(command);
+
+ }
+ // is analog command?
+ else if (command.startsWith("analog/")) {
+ // extract subcommand (after the "/")
+ command = command.substring(7);
+ analogCommand(command);
+
+ }
+ // is mode command?
+ else if (command.startsWith("mode/")) {
+ // extract subcommand (after the "/")
+ command = command.substring(5);
+ modeCommand(command);
+ }
+}
+
+void digitalCommand(String command) {
+ int pin, value;
+
+ // Find the position of the "/" inside the command
+ int slashIndex = command.indexOf("/");
+
+ // If there are no slashes
+ if (slashIndex == -1) {
+ // then we are in the following case:
+ // "digital/13" -> digitalRead(13)
+
+ // so we can extract the pin number from the remainder of the command string
+ pin = command.toInt();
+ }
+ else {
+ // else, we found a slash, so we are in the following case:
+ // "digital/13/1" -> digitalWrite(13, HIGH)
+
+ // we must estract pin number before the "/"
+ pin = command.substring(0, slashIndex).toInt();
+ // and value after the "/"
+ value = command.substring(slashIndex+1).toInt();
+ digitalWrite(pin, value);
+ }
+ reportDigitalRead(pin, true);
+}
+
+void analogCommand(String command) {
+ int pin, value;
+ if (command.indexOf("/") != -1) {
+ pin = command.substring(0, command.indexOf("/")).toInt();
+ value = command.substring(command.indexOf("/") + 1, command.length()).toInt();
+ analogWrite(pin, value);
+ }
+ else {
+ pin = command.toInt();
+ }
+ reportAnalogRead(pin, true);
+}
+
+void modeCommand(String command) {
+ int pin;
+ String strValue;
+ pin = command.substring(0, command.indexOf("/")).toInt();
+ strValue = command.substring(command.indexOf("/") + 1, command.length());
+ if (strValue == "output") {
+ pinMode(pin, OUTPUT);
+ reportPinMode(pin, strValue);
+ }
+ else if (strValue == "input") {
+ pinMode(pin, INPUT);
+ reportPinMode(pin, strValue);
+ }
+}
+
+void reportPinMode(int pin, String mode) {
+ String json = "{\"pin\":";
+ json += pin;
+ json += ", \"mode\": \"";
+ json += mode;
+ json += "\"}";
+ Mailbox.writeJSON(json);
+}
+
+void reportDigitalRead(int pin, boolean dataset) {
+ int value = digitalRead(pin);
+
+ String json = "{\"pin\":";
+ json += pin;
+ json += ", \"value\": ";
+ json += value;
+ json += "}";
+ Mailbox.writeJSON(json);
+
+ if (dataset) {
+ String key = "D";
+ key += pin;
+ Bridge.put(key.c_str(), String(value).c_str());
+ }
+}
+
+void reportAnalogRead(int pin, boolean dataset) {
+ int value = analogRead(pin);
+
+ String json = "{\"pin\":";
+ json += pin;
+ json += ", \"value\": ";
+ json += value;
+ json += "}";
+ Mailbox.writeJSON(json);
+
+ if (dataset) {
+ String key = "A";
+ key += pin;
+ Bridge.put(key.c_str(), String(value).c_str());
+ }
+}
+
diff --git a/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
new file mode 100644
index 0000000..4cdf4c1
--- /dev/null
+++ b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
@@ -0,0 +1,94 @@
+/*
+ ASCII table
+
+ Prints out byte values in all possible formats:
+ * as raw binary values
+ * as ASCII-encoded decimal, hex, octal, and binary values
+
+ For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
+
+ The circuit: No external hardware needed.
+
+ created 2006
+ by Nicholas Zambetti
+ modified 9 Apr 2012
+ by Tom Igoe
+ modified 22 May 2013
+ by Cristian Maglie
+
+ This example code is in the public domain.
+
+ <http://www.zambetti.com>
+
+ */
+
+#include <Console.h>
+
+void setup() {
+ //Initialize Console and wait for port to open:
+ Bridge.begin();
+ Console.begin();
+
+ // Uncomment the following line to enable buffering:
+ // - better transmission speed and efficiency
+ // - needs to call Console.flush() to ensure that all
+ // transmitted data is sent
+
+ //Console.buffer(64);
+
+ while (!Console) {
+ ; // wait for Console port to connect.
+ }
+
+ // prints title with ending line break
+ Console.println("ASCII Table ~ Character Map");
+}
+
+// first visible ASCIIcharacter '!' is number 33:
+int thisByte = 33;
+// you can also write ASCII characters in single quotes.
+// for example. '!' is the same as 33, so you could also use this:
+//int thisByte = '!';
+
+void loop() {
+ // prints value unaltered, i.e. the raw binary version of the
+ // byte. The Console monitor interprets all bytes as
+ // ASCII, so 33, the first number, will show up as '!'
+ Console.write(thisByte);
+
+ Console.print(", dec: ");
+ // prints value as string as an ASCII-encoded decimal (base 10).
+ // Decimal is the default format for Console.print() and Console.println(),
+ // so no modifier is needed:
+ Console.print(thisByte);
+ // But you can declare the modifier for decimal if you want to.
+ //this also works if you uncomment it:
+
+ // Console.print(thisByte, DEC);
+
+ Console.print(", hex: ");
+ // prints value as string in hexadecimal (base 16):
+ Console.print(thisByte, HEX);
+
+ Console.print(", oct: ");
+ // prints value as string in octal (base 8);
+ Console.print(thisByte, OCT);
+
+ Console.print(", bin: ");
+ // prints value as string in binary (base 2)
+ // also prints ending line break:
+ Console.println(thisByte, BIN);
+
+ // if printed last visible character '~' or 126, stop:
+ if(thisByte == 126) { // you could also use if (thisByte == '~') {
+ // ensure the latest bit of data is sent
+ Console.flush();
+
+ // This loop loops forever and does nothing
+ while(true) {
+ continue;
+ }
+ }
+ // go on to the next character
+ thisByte++;
+}
diff --git a/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino
new file mode 100644
index 0000000..4201465
--- /dev/null
+++ b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino
@@ -0,0 +1,58 @@
+/*
+ Console Pixel
+
+ An example of using the Arduino board to receive data from the
+ Console on the Arduino Yun. In this case, the Arduino boards turns on an LED when
+ it receives the character 'H', and turns off the LED when it
+ receives the character 'L'.
+
+ To see the Console, pick your Yun's name and IP address in the Port menu
+ then open the Port Monitor. You can also see it by opening a terminal window
+ and typing
+ ssh root@ yourYunsName.local 'telnet localhost 6571'
+ then pressing enter. When prompted for the password, enter it.
+
+
+ The circuit:
+ * LED connected from digital pin 13 to ground
+
+ created 2006
+ by David A. Mellis
+ modified 25 Jun 2013
+ by Tom Igoe
+
+ This example code is in the public domain.
+
+ */
+#include <Console.h>
+
+const int ledPin = 13; // the pin that the LED is attached to
+char incomingByte; // a variable to read incoming Console data into
+
+void setup() {
+ // initialize Console communication:
+ Bridge.begin();
+ Console.begin();
+ while(!Console); // wait for the Console to open from the remote side
+ Console.println("type H or L to turn pin 13 on or off");
+ // initialize the LED pin as an output:
+ pinMode(ledPin, OUTPUT);
+}
+
+void loop() {
+ // see if there's incoming Console data:
+ if (Console.available() > 0) {
+ // read the oldest byte in the Console buffer:
+ incomingByte = Console.read();
+ Console.println(incomingByte);
+ // if it's a capital H (ASCII 72), turn on the LED:
+ if (incomingByte == 'H') {
+ digitalWrite(ledPin, HIGH);
+ }
+ // if it's an L (ASCII 76) turn off the LED:
+ if (incomingByte == 'L') {
+ digitalWrite(ledPin, LOW);
+ }
+ }
+}
+
diff --git a/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino b/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino
new file mode 100644
index 0000000..7b38f03
--- /dev/null
+++ b/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino
@@ -0,0 +1,55 @@
+/*
+ Console.read() example:
+ read data coming from bridge using the Console.read() function
+ and store it in a string.
+
+ To see the Console, pick your Yun's name and IP address in the Port menu
+ then open the Port Monitor. You can also see it by opening a terminal window
+ and typing
+ ssh root@ yourYunsName.local 'telnet localhost 6571'
+ then pressing enter. When prompted for the password, enter it.
+
+ created 13 Jun 2013
+ by Angelo Scialabba
+ modified 16 June 2013
+ by Tom Igoe
+
+ This example code is in the public domain.
+ */
+
+#include <Console.h>
+
+String name;
+
+void setup() {
+ //Initialize Console and wait for port to open:
+ Bridge.begin();
+ Console.begin();
+
+ while (!Console){
+ ; // wait for Console port to connect.
+ }
+ Console.println("Hi, what's your name?");
+}
+
+void loop() {
+ if (Console.available() > 0) {
+ char thisChar = Console.read(); //read the next char received
+ //look for the newline character, this is the last character in the string
+ if (thisChar == '\n') {
+ //print text with the name received
+ Console.print("Hi ");
+ Console.print(name);
+ Console.println("! Nice to meet you!");
+ Console.println();
+ //Ask again for name and clear the old name
+ Console.println("Hi, what's your name?");
+ name = "";
+ }
+ else { //if the buffer is empty Cosole.read returns -1
+ name += thisChar; //thisChar is int, treat him as char and add it to the name string
+ }
+ }
+}
+
+
diff --git a/libraries/Bridge/examples/Datalogger/Datalogger.ino b/libraries/Bridge/examples/Datalogger/Datalogger.ino
new file mode 100644
index 0000000..5878e05
--- /dev/null
+++ b/libraries/Bridge/examples/Datalogger/Datalogger.ino
@@ -0,0 +1,90 @@
+/*
+ SD card datalogger
+
+ This example shows how to log data from three analog sensors
+ to an SD card mounted on the Arduino Yun using the Bridge library.
+
+ The circuit:
+ * analog sensors on analog ins 0, 1, and 2
+ * SD card attached to SD card slot of the Arduino Yun
+
+ You can remove the SD card while the Linux and the
+ sketch are running but be careful not to remove it while
+ the system is writing to it.
+
+ created 24 Nov 2010
+ modified 9 Apr 2012
+ by Tom Igoe
+ adapted to the Yun Bridge library 20 Jun 2013
+ by Federico Vanzati
+ modified 21 Jun 2013
+ by Tom Igoe
+
+ This example code is in the public domain.
+
+ */
+
+#include <FileIO.h>
+#include <Serial.h>
+
+void setup() {
+ // Initialize the Bridge and the Serial
+ Bridge.begin();
+ Serial.begin(9600);
+ FileSystem.begin();
+
+ while(!Serial); // wait for Serial port to connect.
+ Serial.println("Filesystem datalogger");
+}
+
+
+void loop () {
+ // make a string that start with a timestamp for assembling the data to log:
+ String dataString = "";
+ dataString += addTimeStamp();
+ dataString += " = ";
+
+ // read three sensors and append to the string:
+ for (int analogPin = 0; analogPin < 3; analogPin++) {
+ int sensor = analogRead(analogPin);
+ dataString += String(sensor);
+ if (analogPin < 2) {
+ dataString += ",";
+ }
+ }
+
+ // open the file. note that only one file can be open at a time,
+ // so you have to close this one before opening another.
+ // The FileSystem card is mounted at the following "/mnt/FileSystema1"
+ File dataFile = FileSystem.open("/mnt/sda1/datalog.txt", FILE_APPEND);
+
+ // if the file is available, write to it:
+ if (dataFile) {
+ dataFile.println(dataString);
+ dataFile.close();
+ // print to the serial port too:
+ Serial.println(dataString);
+ }
+ // if the file isn't open, pop up an error:
+ else {
+ Serial.println("error opening datalog.txt");
+ }
+
+ delay(15000);
+
+}
+
+// This function append a time stamp to the string passed as argument
+String addTimeStamp() {
+ String result;
+ Process time;
+ time.begin("date");
+ time.addParameter("+%D-%T");
+ time.run();
+
+ while(time.available()>0) {
+ char c = time.read();
+ if(c != '\n')
+ result += c;
+ }
+}
diff --git a/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino b/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino
new file mode 100644
index 0000000..d5bbb26
--- /dev/null
+++ b/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino
@@ -0,0 +1,65 @@
+/*
+ Write to file using FileIO classes.
+
+ This sketch demonstrate how to write file into the Yún filesystem.
+ A shell script file is created in /tmp, and it is executed afterwards.
+
+ */
+
+#include <FileIO.h>
+
+void setup() {
+ // Setup Bridge (needed every time we communicate with the Arduino Yún)
+ Bridge.begin();
+
+ // Setup Console
+ Console.begin();
+ // Buffering improves Console performance, but we must remember to
+ // finish sending using the Console.flush() command.
+ Console.buffer(64);
+
+ // Setup File IO
+ SD.begin();
+
+ // Upload script used to gain network statistics
+ uploadScript();
+}
+
+void loop() {
+ // Run stats script every 5 secs.
+ runScript();
+ delay(5000);
+}
+
+void uploadScript() {
+ // Write our shell script in /tmp
+ // Using /tmp stores the script in RAM this way we can preserve
+ // the limited amount of FLASH erase/write cycles
+ File script = SD.open("/tmp/wlan-stats.sh", FILE_WRITE);
+ script.print("#!/bin/sh\n");
+ script.print("ifconfig wlan0 | grep \"RX bytes\" | tr ':' ' ' | awk \"{ print \\$3 \\\" \\\" \\$8 }\"\n");
+ script.close();
+
+ // Make the script executable
+ Process chmod;
+ chmod.begin("chmod");
+ chmod.addParameter("+x");
+ chmod.addParameter("/tmp/wlan-stats.sh");
+ chmod.run();
+}
+
+void runScript() {
+ // Launch script and show results on the console
+ Process myscript;
+ myscript.begin("/tmp/wlan-stats.sh");
+ myscript.run();
+
+ Console.print("WiFi RX/TX bytes: ");
+ while (myscript.available()) {
+ char c = myscript.read();
+ Console.print(c);
+ }
+ Console.println();
+ Console.flush();
+}
+
diff --git a/libraries/Bridge/examples/HttpClient/HttpClient.ino b/libraries/Bridge/examples/HttpClient/HttpClient.ino
new file mode 100644
index 0000000..bf5e8ff
--- /dev/null
+++ b/libraries/Bridge/examples/HttpClient/HttpClient.ino
@@ -0,0 +1,23 @@
+
+#include <HttpClient.h>
+
+void setup() {
+ pinMode(13, OUTPUT);
+ digitalWrite(13, LOW);
+ Bridge.begin();
+}
+
+void loop() {
+ HttpClient client;
+ client.get("http://my.server.address/file.php");
+
+ char c = client.read();
+ if (c=='1')
+ digitalWrite(13, HIGH);
+ if (c=='0')
+ digitalWrite(13, LOW);
+
+ delay(5000);
+}
+
+
diff --git a/libraries/Bridge/examples/OLDYahooWeather/OLDYahooWeather.ino b/libraries/Bridge/examples/OLDYahooWeather/OLDYahooWeather.ino
new file mode 100644
index 0000000..b751e1d
--- /dev/null
+++ b/libraries/Bridge/examples/OLDYahooWeather/OLDYahooWeather.ino
@@ -0,0 +1,94 @@
+/*
+ Yahoo Weather Forecast parser
+
+ http://developer.yahoo.com/weather/
+ This sketch demonstrate how to use the Linux command line tools
+ to parse a simple XML file on the Arduino Yún.
+
+ First thing download the XML file from the Yahoo Weather service
+ than use "grep" and "cut" to extract the data you want.
+
+ To find the location ID of your location, browse or search for your
+ city from the Weather home page. The location ID is in the URL for
+ the forecast page for that city.
+
+ created 21 Jun 2013
+ by Federico Vanzati
+
+ */
+
+#include <Bridge.h>
+
+String locationID = "725003"; // Turin, Italy
+
+// table with keywords to search in the XML file
+// the third column is the tag to the field
+String forecast[10][3] = {
+ "location", "2", "city",
+ "condition", "6", "temperature",
+ "condition", "2", "condition",
+ "astronomy", "2", "sunrise",
+ "astronomy", "4", "sunset",
+ "atmosphere", "2", "humidity",
+ "atmosphere", "6", "pressure",
+ "wind", "6", "wind speed",
+ "wind", "4", "wind direction",
+ "wind", "2", "chill temperature"
+};
+
+
+void setup() {
+ Bridge.begin();
+ Serial.begin(9600);
+ while(!Serial);
+
+ Serial.println("Weather Forecast for your location: \n");
+}
+
+void loop() {
+
+ for(int i=0; i<10; i++) {
+
+ // Compose the request
+
+ // curl is a program that connect to an URL an download the content
+ // is used to get the weather forecast from yahoo in XML format
+ String command = "curl -s "; // -s is the silent option
+ command += "http://weather.yahooapis.com/forecastrss"; // yahoo weather RSS service
+ command += "?w="; // query for the location
+ command += locationID;
+ //command += "\\&u=c"; // ask for celsius degrees
+
+ // add a new process
+ // grep is used to extract a single line of content containig a search keyword form the XML
+ command += " | "; // pipe a new process
+ command += "grep ";
+ command += forecast[i][0]; // word to search in the XML file
+
+ // add a new process
+ // cut is a program that split a text in different fields
+ // when encouter the passed character delimiter
+ command += " | "; // pipe a new process
+ command += "cut ";
+ command += "-d \\\" "; // -d parameter split the string every " char
+ command += "-f "; // -f parameter is to return the 6th splitted element
+ command += forecast[i][1]; // the field are already manually calculated and inserted in the forecast table
+
+
+ Serial.print(forecast[i][2]);
+ Serial.print("= ");
+
+ // run the command
+ Process wf;
+ wf.runShellCommand(command);
+
+ while(wf.available()>0)
+ {
+ Serial.print( (char)wf.read() );
+ }
+ }
+
+ //do nothing forevermore
+ while(1);
+}
+
diff --git a/libraries/Bridge/examples/Process/Process.ino b/libraries/Bridge/examples/Process/Process.ino
new file mode 100644
index 0000000..919cea7
--- /dev/null
+++ b/libraries/Bridge/examples/Process/Process.ino
@@ -0,0 +1,70 @@
+/*
+ Running process using Process class.
+
+ This sketch demonstrate how to run linux processes
+ using an Arduino Yún.
+
+ created 5 Jun 2013
+ by Cristian Maglie
+
+ */
+
+#include <Process.h>
+
+void setup() {
+ // Setup Bridge (needed every time we communicate with the Arduino Yún)
+ Bridge.begin();
+
+ // Setup Console
+ Console.begin();
+ // Buffering improves Console performance, but we must remember to
+ // finish sending using the Console.flush() command.
+ Console.buffer(64);
+
+ // Wait until a Network Monitor is connected.
+ while (!Console);
+
+ // run various example processes
+ runCurl();
+ runCpuInfo();
+}
+
+void loop() {
+ // Do nothing here.
+}
+
+void runCurl() {
+ // Launch "curl" command and get Arduino asciilogo from the network
+
+ Process p; // Create a process and call it "p"
+ p.begin("curl"); // Process should launch the "curl" command
+ p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
+ p.run(); // Run the process and wait for its termination
+
+ // Print arduino logo over the console.
+ // A process output can be read with the stream methods
+ while (p.available()>0) {
+ char c = p.read();
+ Console.print(c);
+ }
+ // Ensure the latest bit of data is sent.
+ Console.flush();
+}
+
+void runCpuInfo() {
+ // Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU)
+ Process p;
+ p.begin("cat");
+ p.addParameter("/proc/cpuinfo");
+ p.run();
+
+ // Print command output on the Console.
+ // A process output can be read with the stream methods
+ while (p.available()>0) {
+ char c = p.read();
+ Console.print(c);
+ }
+ // Ensure the latest bit of data is sent.
+ Console.flush();
+}
+
diff --git a/libraries/Bridge/examples/ShellCommands/ShellCommands.ino b/libraries/Bridge/examples/ShellCommands/ShellCommands.ino
new file mode 100644
index 0000000..d2f9b7a
--- /dev/null
+++ b/libraries/Bridge/examples/ShellCommands/ShellCommands.ino
@@ -0,0 +1,52 @@
+
+/*
+ Running shell coommands using Process class.
+
+ This sketch demonstrate how to run linux shell commands
+ using an Arduino Yún. It runs the wifiCheck script on the linino side
+ of the Yun, then uses grep to get just the signal strength line.
+ Then it uses parseInt() to read the wifi signal strength as an integer,
+ and finally uses that number to fade an LED using analogWrite().
+
+ The circuit:
+ * Arduino Yun with LED connected to pin 9
+
+ created 12 Jun 2013
+ by Cristian Maglie
+ modified 25 June 2013
+ by Tom Igoe
+
+ This example code is in the public domain.
+
+ */
+
+#include <Process.h>
+
+void setup() {
+ // initialize the Bridge and Serial connections:
+ Bridge.begin();
+ Serial.begin(9600);
+}
+
+void loop() {
+ Process p;
+ // This command line runs the wifiCheck script, (lua /arduino/pretty...), then
+ // sends the result to the grep command to look for a line containing the word
+ // "Signal:" the result is passed to this sketch:
+ p.runShellCommand("lua /arduino/pretty_wifi_info.lua | grep Signal");
+
+ // do nothing until the process finishes, so you get the whole output:
+ while(p.running());
+
+ // Read command output. runShellCommand() should have passed "Signal: xx&":
+ while (p.available()) {
+ int result = p.parseInt(); // look for an integer
+ int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255
+ analogWrite(9, signal); // set the brightness of LED on pin 9
+ Serial.println(result); // print the number as well
+ }
+ delay(5000); // wait 5 seconds before you do it again
+}
+
+
+
diff --git a/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino b/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino
new file mode 100644
index 0000000..4a4e818
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino
@@ -0,0 +1,109 @@
+/*
+ GetYahooWeatherReport
+
+ Demonstrates making a request to the Yahoo! Weather API using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
+ to the Internet.
+
+ Looking for another API? We've got over 100 in our Library!
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information
+ // as described in the footer comment below
+
+int numRuns = 0; // execution count, so that this doesn't run forever
+int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run
+
+void setup() {
+ Serial.begin(9600);
+
+ // for debugging, wait until a serial console is connected
+ while(!Serial);
+ Bridge.begin();
+}
+
+void loop()
+{
+ // while we haven't reached the max number of runs...
+ if (numRuns < maxRuns) {
+
+ // print status
+ Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "...");
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process GetWeatherByAddressChoreo;
+
+ // invoke the Temboo client
+ GetWeatherByAddressChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ GetWeatherByAddressChoreo.addParameter("-a");
+ GetWeatherByAddressChoreo.addParameter(TEMBOO_ACCOUNT);
+ GetWeatherByAddressChoreo.addParameter("-u");
+ GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ GetWeatherByAddressChoreo.addParameter("-p");
+ GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress)
+ GetWeatherByAddressChoreo.addParameter("-c");
+ GetWeatherByAddressChoreo.addParameter("/Library/Yahoo/Weather/GetWeatherByAddress");
+
+ // set choreo inputs; in this case, the address for which to retrieve weather data
+ // the Temboo client provides standardized calls to 100+ cloud APIs
+ GetWeatherByAddressChoreo.addParameter("-i");
+ GetWeatherByAddressChoreo.addParameter("Address:104 Franklin St., New York NY 10013");
+
+ // run the choreo
+ GetWeatherByAddressChoreo.run();
+
+ // when the choreo results are available, print them to the serial monitor
+ while(GetWeatherByAddressChoreo.available()) {
+
+ // note that in this example, we just print the raw XML response from Yahoo
+ // see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
+ // for information on how to filter this data
+
+ Serial.print((char)GetWeatherByAddressChoreo.read());
+ }
+ GetWeatherByAddressChoreo.close();
+
+ }
+
+ Serial.println("Sleeping...");
+ Serial.println("");
+ delay(30000); // sleep 30 seconds between GetWeatherByAddress calls
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/
diff --git a/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino b/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino
new file mode 100644
index 0000000..5acdbab
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino
@@ -0,0 +1,185 @@
+/*
+ ReadATweet
+
+ Demonstrates retrieving the most recent Tweet from a user's home timeline
+ using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ In order to run this sketch, you'll need to register an application using
+ the Twitter dev console at https://dev.twitter.com. After creating the
+ app, you'll find OAuth credentials for that application under the "OAuth Tool" tab.
+ Substitute these values for the placeholders below.
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun
+ is connected to the Internet.
+
+ Looking for social APIs? We've got Facebook, Google+, Instagram, Tumblr and more.
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information
+ // as described in the footer comment below
+
+/*** SUBSTITUTE YOUR VALUES BELOW: ***/
+
+const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
+const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
+const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
+const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
+
+int numRuns = 0; // execution count, so this sketch doesn't run forever
+int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
+
+void setup() {
+ Serial.begin(9600);
+
+ // for debugging, wait until a serial console is connected
+ delay(4000);
+ while(!Serial);
+ Bridge.begin();
+}
+
+void loop()
+{
+ // while we haven't reached the max number of runs...
+ if (numRuns < maxRuns) {
+
+ // print status
+ Serial.println("Running ReadATweet - Run #" + String(numRuns++) + "...");
+
+ // define the Process that will be used to call the "temboo" client
+ Process HomeTimelineChoreo;
+
+ // invoke the Temboo client
+ HomeTimelineChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ HomeTimelineChoreo.addParameter("-a");
+ HomeTimelineChoreo.addParameter(TEMBOO_ACCOUNT);
+ HomeTimelineChoreo.addParameter("-u");
+ HomeTimelineChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ HomeTimelineChoreo.addParameter("-p");
+ HomeTimelineChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // tell the Temboo client which Choreo to run (Twitter > Timelines > HomeTimeline)
+ HomeTimelineChoreo.addParameter("-c");
+ HomeTimelineChoreo.addParameter("/Library/Twitter/Timelines/HomeTimeline");
+
+ // set the required choreo inputs
+ // see https://www.temboo.com/library/Library/Twitter/Timelines/HomeTimeline/
+ // for complete details about the inputs for this Choreo
+
+ HomeTimelineChoreo.addParameter("-i");
+ HomeTimelineChoreo.addParameter("Count:1"); // the max number of Tweets to return from each request
+
+ // add the Twitter account information
+ HomeTimelineChoreo.addParameter("-i");
+ HomeTimelineChoreo.addParameter("AccessToken:" + TWITTER_ACCESS_TOKEN);
+ HomeTimelineChoreo.addParameter("-i");
+ HomeTimelineChoreo.addParameter("AccessTokenSecret:" + TWITTER_ACCESS_TOKEN_SECRET);
+ HomeTimelineChoreo.addParameter("-i");
+ HomeTimelineChoreo.addParameter("ConsumerSecret:" + TWITTER_CONSUMER_SECRET);
+ HomeTimelineChoreo.addParameter("-i");
+ HomeTimelineChoreo.addParameter("ConsumerKey:" + TWITTER_CONSUMER_KEY);
+
+ // next, we'll define two output filters that let us specify the
+ // elements of the response from Twitter that we want to receive.
+ // see the examples at http://www.temboo.com/arduino
+ // for more on using output filters
+
+ // we want the text of the tweet
+ HomeTimelineChoreo.addParameter("-o");
+ HomeTimelineChoreo.addParameter("tweet:/[1]/text:Response");
+
+ // and the name of the author
+ HomeTimelineChoreo.addParameter("-o");
+ HomeTimelineChoreo.addParameter("author:/[1]/user/screen_name:Response");
+
+
+ // tell the Process to run and wait for the results. The
+ // return code (rc) will tell us whether the Temboo client
+ // was able to send our request to the Temboo servers
+ unsigned int rc = HomeTimelineChoreo.run();
+
+ // a response code of 0 means success; print the API response
+ if(rc == 0) {
+
+ String author; // a String to hold the tweet author's name
+ String tweet; // a String to hold the text of the tweet
+
+
+ // choreo outputs are returned as key/value pairs, delimited with
+ // newlines and record/field terminator characters, for example:
+ // Name1\n\x1F
+ // Value1\n\x1E
+ // Name2\n\x1F
+ // Value2\n\x1E
+
+ // see the examples at http://www.temboo.com/arduino for more details
+ // we can read this format into separate variables, as follows:
+
+ while(HomeTimelineChoreo.available()) {
+ // read the name of the output item
+ String name = HomeTimelineChoreo.readStringUntil('\x1F');
+ name.trim();
+
+ // read the value of the output item
+ String data = HomeTimelineChoreo.readStringUntil('\x1E');
+ data.trim();
+
+ // assign the value to the appropriate String
+ if (name == "tweet") {
+ tweet = data;
+ } else if (name == "author") {
+ author = data;
+ }
+ }
+
+ Serial.println("@" + author + " - " + tweet);
+
+ } else {
+ // there was an error
+ // print the raw output from the choreo
+ while(HomeTimelineChoreo.available()) {
+ Serial.print((char)HomeTimelineChoreo.read());
+ }
+ }
+
+ HomeTimelineChoreo.close();
+ }
+
+ Serial.println("Sleeping...");
+ Serial.println("");
+ delay(90000); // sleep 90 seconds between HomeTimeline calls
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/
diff --git a/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino b/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino
new file mode 100644
index 0000000..70befef
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino
@@ -0,0 +1,142 @@
+/*
+ SendATweet
+
+ Demonstrates sending a tweet via a Twitter account using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ In order to run this sketch, you'll need to register an application using
+ the Twitter dev console at https://dev.twitter.com. After creating the
+ app, you'll find OAuth credentials for that application under the "OAuth Tool" tab.
+ Substitute these values for the placeholders below.
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
+ to the Internet.
+
+ Looking for social APIs? We've got Facebook, Google+, Instagram, Tumblr and more.
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information
+ // as described in the footer comment below
+
+
+/*** SUBSTITUTE YOUR VALUES BELOW: ***/
+
+const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
+const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
+const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
+const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
+
+int numRuns = 1; // execution count, so this sketch doesn't run forever
+int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
+
+void setup() {
+ Serial.begin(9600);
+
+ // for debugging, wait until a serial console is connected
+ delay(4000);
+ while(!Serial);
+
+ Bridge.begin();
+}
+
+void loop()
+{
+ // only try to send the tweet if we haven't already sent it successfully
+ if (numRuns <= maxRuns) {
+
+ Serial.println("Running SendATweet - Run #" + String(numRuns++) + "...");
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process StatusesUpdateChoreo;
+
+ // invoke the Temboo client
+ StatusesUpdateChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ StatusesUpdateChoreo.addParameter("-a");
+ StatusesUpdateChoreo.addParameter(TEMBOO_ACCOUNT);
+ StatusesUpdateChoreo.addParameter("-u");
+ StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ StatusesUpdateChoreo.addParameter("-p");
+ StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
+ StatusesUpdateChoreo.addParameter("-c");
+ StatusesUpdateChoreo.addParameter("/Library/Twitter/Tweets/StatusesUpdate");
+
+ // set the required choreo inputs
+ // see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
+ // for complete details about the inputs for this Choreo
+
+ // add the Twitter account information
+ StatusesUpdateChoreo.addParameter("-i");
+ StatusesUpdateChoreo.addParameter("AccessToken:" + TWITTER_ACCESS_TOKEN);
+ StatusesUpdateChoreo.addParameter("-i");
+ StatusesUpdateChoreo.addParameter("AccessTokenSecret:" + TWITTER_ACCESS_TOKEN_SECRET);
+ StatusesUpdateChoreo.addParameter("-i");
+ StatusesUpdateChoreo.addParameter("ConsumerSecret:" + TWITTER_CONSUMER_SECRET);
+ StatusesUpdateChoreo.addParameter("-i");
+ StatusesUpdateChoreo.addParameter("ConsumerKey:" + TWITTER_CONSUMER_KEY);
+
+ String tweet("My Arduino Yun has been running for " + String(millis()) + " milliseconds.");
+
+ StatusesUpdateChoreo.addParameter("-i");
+ StatusesUpdateChoreo.addParameter("StatusUpdate:" + tweet);
+
+ // tell the Process to run and wait for the results. The
+ // return code (rc) will tell us whether the Temboo client
+ // was able to send our request to the Temboo servers
+ unsigned int rc = StatusesUpdateChoreo.run();
+
+ // a return code of zero (0) means everything worked
+ if (rc == 0) {
+ Serial.println("Success! Tweet sent!");
+ } else {
+ // a non-zero return code means there was an error
+ // read and print the error message
+ while (StatusesUpdateChoreo.available()) {
+ Serial.print((char)StatusesUpdateChoreo.read());
+ }
+ }
+ StatusesUpdateChoreo.close();
+
+ // do nothing for the next 90 seconds
+ Serial.println("Sleeping...");
+ delay(90000);
+ }
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/
+
+
+
diff --git a/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino
new file mode 100644
index 0000000..76fdc1d
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino
@@ -0,0 +1,147 @@
+/*
+ SendAnEmail
+
+ Demonstrates sending an email via a Google Gmail account using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ Since this sketch uses Gmail to send the email, you'll also need a valid
+ Google Gmail account. The sketch needs the username and password you use
+ to log into your Gmail account: substitute the placeholders below for these values.
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
+ to the Internet.
+
+ Looking for another API? We've got over 100 in our Library!
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information
+ // as described in the footer comment below
+
+/*** SUBSTITUTE YOUR VALUES BELOW: ***/
+
+// your Gmail address, eg "bob.smith@gmail.com"
+const String GMAIL_USER_NAME = "xxxxxxxxxx";
+
+// your Gmail password
+const String GMAIL_PASSWORD = "xxxxxxxxxx";
+
+// the email address you want to send the email to, eg "jane.doe@temboo.com"
+const String TO_EMAIL_ADDRESS = "xxxxxxxxxx";
+
+
+boolean success = false; // a flag to indicate whether we've sent the email yet or not
+
+void setup() {
+ Serial.begin(9600);
+
+ // for debugging, wait until a serial console is connected
+ delay(4000);
+ while(!Serial);
+
+ Bridge.begin();
+}
+
+void loop()
+{
+ // only try to send the email if we haven't already sent it successfully
+ if (!success) {
+
+ Serial.println("Running SendAnEmail...");
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process SendEmailChoreo;
+
+ // invoke the Temboo client
+ SendEmailChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ SendEmailChoreo.addParameter("-a");
+ SendEmailChoreo.addParameter(TEMBOO_ACCOUNT);
+ SendEmailChoreo.addParameter("-u");
+ SendEmailChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ SendEmailChoreo.addParameter("-p");
+ SendEmailChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
+ SendEmailChoreo.addParameter("-c");
+ SendEmailChoreo.addParameter("/Library/Google/Gmail/SendEmail");
+
+ // set the required choreo inputs
+ // see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
+ // for complete details about the inputs for this Choreo
+
+ // the first input is a your Gmail user name.
+ SendEmailChoreo.addParameter("-i");
+ SendEmailChoreo.addParameter("Username:" + GMAIL_USER_NAME);
+
+ // next is your Gmail password.
+ SendEmailChoreo.addParameter("-i");
+ SendEmailChoreo.addParameter("Password:" + GMAIL_PASSWORD);
+
+ // who to send the email to
+ SendEmailChoreo.addParameter("-i");
+ SendEmailChoreo.addParameter("ToAddress:" + TO_EMAIL_ADDRESS);
+
+ // then a subject line
+ SendEmailChoreo.addParameter("-i");
+ SendEmailChoreo.addParameter("Subject:ALERT: Greenhouse Temperature");
+
+ // next comes the message body, the main content of the email
+ SendEmailChoreo.addParameter("-i");
+ SendEmailChoreo.addParameter("MessageBody:Hey! The greenhouse is too cold!");
+
+ // tell the Process to run and wait for the results. The
+ // return code (rc) will tell us whether the Temboo client
+ // was able to send our request to the Temboo servers
+ unsigned int rc = SendEmailChoreo.run();
+
+ // a return code of zero (0) means everything worked
+ if (rc == 0) {
+ Serial.println("Success! Email sent!");
+ success = true;
+ } else {
+ // a non-zero return code means there was an error
+ // read and print the error message
+ while (SendEmailChoreo.available()) {
+ Serial.print((char)SendEmailChoreo.read());
+ }
+ }
+ SendEmailChoreo.close();
+
+ // do nothing for the next 60 seconds
+ delay(60000);
+ }
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/
+
diff --git a/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino b/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino
new file mode 100644
index 0000000..67a0b25
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino
@@ -0,0 +1,160 @@
+/*
+ SendAnSMS
+
+ Demonstrates sending an SMS via a Twilio account using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ Since this sketch uses Twilio to send the SMS, you'll also need a valid
+ Twilio account. You can create one for free at https://www.twilio.com.
+
+ The sketch needs your Twilio phone number, along with
+ the Account SID and Auth Token you get when you register with Twilio.
+ Make sure to use the Account SID and Auth Token from your Twilio Dashboard
+ (not your test credentials from the Dev Tools panel).
+
+ Also note that if you're using a free Twilio account, you'll need to verify
+ the phone number to which messages are being sent by going to twilio.com and following
+ the instructions under the "Numbers > Verified Caller IDs" tab (this restriction
+ doesn't apply if you have a paid Twilio account).
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
+ to the Internet.
+
+ Looking for another API? We've got over 100 in our Library!
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information
+ // as described in the footer comment below
+
+
+
+/*** SUBSTITUTE YOUR VALUES BELOW: ***/
+
+// the Account SID from your Twilio account
+const String TWILIO_ACCOUNT_SID = "xxxxxxxxxx";
+
+// the Auth Token from your Twilio account
+const String TWILIO_AUTH_TOKEN = "xxxxxxxxxx";
+
+// your Twilio phone number, e.g., "+1 555-222-1212"
+const String TWILIO_NUMBER = "xxxxxxxxxx";
+
+// the number to which the SMS should be sent, e.g., "+1 555-222-1212"
+const String RECIPIENT_NUMBER = "xxxxxxxxxx";
+
+boolean success = false; // a flag to indicate whether we've sent the SMS yet or not
+
+void setup() {
+ Serial.begin(9600);
+
+ // for debugging, wait until a serial console is connected
+ delay(4000);
+ while(!Serial);
+
+ Bridge.begin();
+}
+
+void loop()
+{
+ // only try to send the SMS if we haven't already sent it successfully
+ if (!success) {
+
+ Serial.println("Running SendAnSMS...");
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process SendSMSChoreo;
+
+ // invoke the Temboo client
+ SendSMSChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ SendSMSChoreo.addParameter("-a");
+ SendSMSChoreo.addParameter(TEMBOO_ACCOUNT);
+ SendSMSChoreo.addParameter("-u");
+ SendSMSChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ SendSMSChoreo.addParameter("-p");
+ SendSMSChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (Twilio > SMSMessages > SendSMS)
+ SendSMSChoreo.addParameter("-c");
+ SendSMSChoreo.addParameter("/Library/Twilio/SMSMessages/SendSMS");
+
+ // set the required choreo inputs
+ // see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/
+ // for complete details about the inputs for this Choreo
+
+ // the first input is a your AccountSID
+ SendSMSChoreo.addParameter("-i");
+ SendSMSChoreo.addParameter("AccountSID:" + TWILIO_ACCOUNT_SID);
+
+ // next is your Auth Token
+ SendSMSChoreo.addParameter("-i");
+ SendSMSChoreo.addParameter("AuthToken:" + TWILIO_AUTH_TOKEN);
+
+ // next is your Twilio phone number
+ SendSMSChoreo.addParameter("-i");
+ SendSMSChoreo.addParameter("From:" + TWILIO_NUMBER);
+
+ // next, what number to send the SMS to
+ SendSMSChoreo.addParameter("-i");
+ SendSMSChoreo.addParameter("To:" + RECIPIENT_NUMBER);
+
+ // finally, the text of the message to send
+ SendSMSChoreo.addParameter("-i");
+ SendSMSChoreo.addParameter("Body:Hey, there! This is a message from your Arduino Yun!");
+
+ // tell the Process to run and wait for the results. The
+ // return code (rc) will tell us whether the Temboo client
+ // was able to send our request to the Temboo servers
+ unsigned int rc = SendSMSChoreo.run();
+
+ // a return code of zero (0) means everything worked
+ if (rc == 0) {
+ Serial.println("Success! SMS sent!");
+ success = true;
+ } else {
+ // a non-zero return code means there was an error
+ // read and print the error message
+ while (SendSMSChoreo.available()) {
+ Serial.print((char)SendSMSChoreo.read());
+ }
+ }
+ SendSMSChoreo.close();
+
+ // do nothing for the next 60 seconds
+ Serial.println("Sleeping...");
+ delay(60000);
+ }
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/ \ No newline at end of file
diff --git a/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino
new file mode 100644
index 0000000..9698d81
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino
@@ -0,0 +1,184 @@
+/*
+ SendDataToGoogleSpreadsheet
+
+ Demonstrates appending a row of data to a Google spreadsheet from the Arduino Yun
+ using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ Since this sketch uses a Google spreadsheet, you'll also need a
+ Google account: substitute the placeholders below for your Google account values.
+
+ This example assumes basic familiarity with Arduino sketches, and that your
+ Yun is connected to the Internet.
+
+ The columns in your spreadsheet must have labels for the Choreo to
+ work properly. It doesn't matter what the column labels actually are,
+ but there must be text in the first row of each column. This example
+ assumes there are two columns. The first column is the time (in milliseconds)
+ that the row was appended, and the second column is a sensor value
+ (simulated in this example via a random number). In other words, your spreadsheet
+ should look like:
+
+ Time | Sensor Value |
+ ------+-----------------
+ | |
+
+ NOTE that the first time you run this sketch, you may receive a warning from
+ Google, prompting you to authorize access from a 3rd party system.
+
+ Looking for another API? We've got over 100 in our Library!
+
+ This example code is in the public domain.
+
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information,
+ // as described in the footer comment below
+
+
+/*** SUBSTITUTE YOUR VALUES BELOW: ***/
+
+const String GOOGLE_USERNAME = "your-google-username";
+const String GOOGLE_PASSWORD = "your-google-password";
+
+// the title of the spreadsheet you want to send data to
+const String SPREADSHEET_TITLE = "your-spreadsheet-title";
+
+
+const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds)
+
+// the last time we ran the Choreo
+// (initialized to 60 seconds ago so the
+// Choreo is run immediately when we start up)
+unsigned long lastRun = (unsigned long)-60000;
+
+void setup() {
+
+ // for debugging, wait until a serial console is connected
+ Serial.begin(9600);
+ delay(4000);
+ while(!Serial);
+
+ Serial.print("Initializing the bridge...");
+ Bridge.begin();
+ Serial.println("Done");
+}
+
+void loop()
+{
+ // get the number of milliseconds this sketch has been running
+ unsigned long now = millis();
+
+ // run again if it's been 60 seconds since we last ran
+ if (now - lastRun >= RUN_INTERVAL_MILLIS) {
+
+ // remember 'now' as the last time we ran the choreo
+ lastRun = now;
+
+ Serial.println("Getting sensor value...");
+
+ // get the value we want to append to our spreadsheet
+ unsigned long sensorValue = getSensorValue();
+
+ Serial.println("Appending value to spreadsheet...");
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process AppendRowChoreo;
+
+ // invoke the Temboo client
+ AppendRowChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ AppendRowChoreo.addParameter("-a");
+ AppendRowChoreo.addParameter(TEMBOO_ACCOUNT);
+ AppendRowChoreo.addParameter("-u");
+ AppendRowChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ AppendRowChoreo.addParameter("-p");
+ AppendRowChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow)
+ AppendRowChoreo.addParameter("-c");
+ AppendRowChoreo.addParameter("/Library/Google/Spreadsheets/AppendRow");
+
+ // set the required Choreo inputs
+ // see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/
+ // for complete details about the inputs for this Choreo
+
+ // your Google username (usually your email address)
+ AppendRowChoreo.addParameter("-i");
+ AppendRowChoreo.addParameter("Username:" + GOOGLE_USERNAME);
+
+ // your Google account password
+ AppendRowChoreo.addParameter("-i");
+ AppendRowChoreo.addParameter("Password:" + GOOGLE_PASSWORD);
+
+ // the title of the spreadsheet you want to append to
+ // NOTE: substitute your own value, retaining the "SpreadsheetTitle:" prefix.
+ AppendRowChoreo.addParameter("-i");
+ AppendRowChoreo.addParameter("SpreadsheetTitle:" + SPREADSHEET_TITLE);
+
+ // convert the time and sensor values to a comma separated string
+ String rowData(now);
+ rowData += ",";
+ rowData += sensorValue;
+
+ // add the RowData input item
+ AppendRowChoreo.addParameter("-i");
+ AppendRowChoreo.addParameter("RowData:" + rowData);
+
+ // run the Choreo and wait for the results
+ // The return code (rc) will indicate success or failure
+ unsigned int rc = AppendRowChoreo.run();
+
+ // return code of zero (0) means success
+ if (rc == 0) {
+ Serial.println("Success! Appended " + rowData);
+ Serial.println("");
+ } else {
+ // return code of anything other than zero means failure
+ // read and display any error messages
+ while (AppendRowChoreo.available()) {
+ Serial.print((char)AppendRowChoreo.read());
+ }
+ }
+
+ AppendRowChoreo.close();
+ }
+}
+
+// this function simulates reading the value of a sensor
+// in this example, we're generating a random number
+unsigned long getSensorValue() {
+ return (unsigned long)random(0, 256);
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/
+
diff --git a/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino b/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino
new file mode 100644
index 0000000..eea009e
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino
@@ -0,0 +1,174 @@
+/*
+ ToxicFacilitiesSearch
+
+ Demonstrates making a request to the Envirofacts API using the Temboo Arduino Yun SDK.
+ This example retrieves the names and addresses of EPA-regulated facilities in the
+ Toxins Release Inventory (TRI) database within a given zip code.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
+ to the Internet.
+
+ Looking for another API? We've got over 100 in our Library!
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information
+ // as described in the footer comment below
+
+// the zip code to search
+const String US_ZIP_CODE = "11215";
+
+int numRuns = 1; // execution count, so that this doesn't run forever
+int maxRuns = 10; // max number of times the Envirofacts FacilitiesSearch Choreo should be run
+
+void setup() {
+ Serial.begin(9600);
+
+ // for debugging, wait until a serial console is connected
+ delay(4000);
+ while(!Serial);
+ Bridge.begin();
+}
+
+void loop()
+{
+ // while we haven't reached the max number of runs...
+ if (numRuns <= maxRuns) {
+
+ // print status
+ Serial.println("Running ToxicFacilitiesSearch - Run #" + String(numRuns++) + "...");
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process FacilitiesSearchByZipChoreo;
+
+ // invoke the Temboo client
+ FacilitiesSearchByZipChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ FacilitiesSearchByZipChoreo.addParameter("-a");
+ FacilitiesSearchByZipChoreo.addParameter(TEMBOO_ACCOUNT);
+ FacilitiesSearchByZipChoreo.addParameter("-u");
+ FacilitiesSearchByZipChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ FacilitiesSearchByZipChoreo.addParameter("-p");
+ FacilitiesSearchByZipChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (EnviroFacts > Toxins > FacilitiesSearchByZip)
+ FacilitiesSearchByZipChoreo.addParameter("-c");
+ FacilitiesSearchByZipChoreo.addParameter("/Library/EnviroFacts/Toxins/FacilitiesSearchByZip");
+
+ // set choreo inputs; in this case, the US zip code for which to retrieve toxin release data
+ // the Temboo client provides standardized calls to 100+ cloud APIs
+ FacilitiesSearchByZipChoreo.addParameter("-i");
+ FacilitiesSearchByZipChoreo.addParameter("Zip:" + US_ZIP_CODE);
+
+ // specify two output filters, to help simplify the Envirofacts API results.
+ // see the tutorials on using Temboo SDK output filters at http://www.temboo.com/arduino
+ FacilitiesSearchByZipChoreo.addParameter("-o");
+ FacilitiesSearchByZipChoreo.addParameter("fac:FACILITY_NAME:Response");
+
+ FacilitiesSearchByZipChoreo.addParameter("-o");
+ FacilitiesSearchByZipChoreo.addParameter("addr:STREET_ADDRESS:Response");
+
+ // run the choreo
+ FacilitiesSearchByZipChoreo.run();
+
+ String facs;
+ String addrs;
+
+ // when the choreo results are available, process them.
+ // the output filters we specified will return comma delimited
+ // lists containing the name and street address of the facilities
+ // located in the specified zip code.
+ while(FacilitiesSearchByZipChoreo.available()) {
+ String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F');
+ name.trim();
+
+ String data = FacilitiesSearchByZipChoreo.readStringUntil('\x1E');
+ data.trim();
+
+ if (name == "fac") {
+ facs = data;
+ } else if (name == "addr") {
+ addrs = data;
+ }
+ }
+ FacilitiesSearchByZipChoreo.close();
+
+ // parse the comma delimited lists of facilities to join the
+ // name with the address and print it to the serial monitor
+ if (facs.length() > 0) {
+ int i = -1;
+ int fstart = 0;
+ int astart = 0;
+ String f;
+ String a;
+ do {
+ i = facs.indexOf(',', fstart);
+ if (i >= 0) {
+ f = facs.substring(fstart, i);
+ fstart = i + 1;
+ }
+
+ i = addrs.indexOf(',', astart);
+ if (i >= 0) {
+ a = addrs.substring(astart, i);
+ astart = i + 1;
+ }
+
+ if (i >= 0) {
+ printResult(f, a);
+ }
+
+ }while (i >= 0);
+ f = facs.substring(fstart);
+ a = addrs.substring(astart);
+ printResult(f, a);
+ } else {
+ Serial.println("No facilities found in zip code " + US_ZIP_CODE);
+ }
+ }
+
+ Serial.println("Sleeping...");
+ Serial.println("");
+ delay(30000); // sleep 30 seconds between calls
+}
+
+// a simple utility function, to output the facility name and address in the serial monitor.
+void printResult(String fac, String addr) {
+ Serial.print(fac);
+ Serial.print(" - ");
+ Serial.println(addr);
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/
+
diff --git a/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino b/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino
new file mode 100644
index 0000000..1352762
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino
@@ -0,0 +1,133 @@
+/*
+ UpdateFacebookStatus
+
+ Demonstrates sending a Facebook status update using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ In order to run this sketch, you'll need to register an application using
+ the Facebook dev console at https://developers.facebook.com/apps. After creating
+ the app, log in to Temboo and visit https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/
+ to use our OAuth Wizard (or OAuth Choreos) to obtain a Facebook access token.
+ Substitute your access token for the placeholder value of FACEBOOK_ACCESS_TOKEN below.
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun
+ is connected to the Internet.
+
+ Looking for social APIs? We've got Twitter, Google+, Instagram, Tumblr and more.
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information,
+ // as described in the footer comment below
+
+/*** SUBSTITUTE YOUR VALUES BELOW: ***/
+
+// the Facebook Access Token, which can be obtained using the Temboo OAuth Wizard or Choreos
+const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx";
+
+
+int numRuns = 0; // execution count, so this sketch doesn't run forever
+int maxRuns = 10; // the max number of times the Facebook SetStatus Choreo should run
+
+void setup() {
+ Serial.begin(9600);
+
+ // For debugging, wait until a serial console is connected.
+ delay(4000);
+ while(!Serial);
+ Bridge.begin();
+}
+
+void loop() {
+ // while we haven't reached the max number of runs...
+ if (numRuns < maxRuns) {
+
+ // print status
+ Serial.println("Running UpdateFacebookStatus - Run #" + String(numRuns++) + "...");
+
+ // Define the status message we want to post on Facebook; since Facebook
+ // doesn't allow duplicate status messages, we'll include a changing value.
+ String statusMsg = "My Arduino Yun has been running for " + String(millis()) + " milliseconds!";
+
+ // define the Process that will be used to call the "temboo" client
+ Process SetStatusChoreo;
+
+ // invoke the Temboo client
+ SetStatusChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ SetStatusChoreo.addParameter("-a");
+ SetStatusChoreo.addParameter(TEMBOO_ACCOUNT);
+ SetStatusChoreo.addParameter("-u");
+ SetStatusChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ SetStatusChoreo.addParameter("-p");
+ SetStatusChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // tell the Temboo client which Choreo to run (Facebook > Publishing > SetStatus)
+ SetStatusChoreo.addParameter("-c");
+ SetStatusChoreo.addParameter("/Library/Facebook/Publishing/SetStatus");
+
+ // set the required choreo inputs
+ // see https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/
+ // for complete details about the inputs for this Choreo
+
+ SetStatusChoreo.addParameter("-i");
+ SetStatusChoreo.addParameter("AccessToken:" + FACEBOOK_ACCESS_TOKEN);
+ SetStatusChoreo.addParameter("-i");
+ SetStatusChoreo.addParameter("Message:" + statusMsg);
+
+
+ // tell the Process to run and wait for the results. The
+ // return code (rc) will tell us whether the Temboo client
+ // was able to send our request to the Temboo servers
+ unsigned int rc = SetStatusChoreo.run();
+
+ // print the response code and API response.
+ Serial.println("Resonse code: " + String(rc));
+
+ // note that in this case, we're just printing the raw response from Facebook.
+ // see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
+ // for information on how to filter this data
+ while(SetStatusChoreo.available()) {
+ Serial.print((char)SetStatusChoreo.read());
+ }
+
+ SetStatusChoreo.close();
+ }
+
+ Serial.println("Sleeping...");
+ Serial.println("");
+
+ delay(30000); // sleep 30 seconds between SetStatus calls
+}
+
+/*
+ IMPORTANT NOTE: TembooAccount.h:
+
+ TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
+ You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
+ include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
+ #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
+
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/ \ No newline at end of file
diff --git a/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino b/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino
new file mode 100644
index 0000000..cb56582
--- /dev/null
+++ b/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino
@@ -0,0 +1,212 @@
+/*
+ UploadToDropbox
+
+ Demonstrates uploading a file to Dropbox using the Temboo Arduino Yun SDK.
+
+ Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+
+ A Temboo account and application key are necessary to run all Temboo examples.
+ If you don't already have one, you can register for a free Temboo account at
+ http://www.temboo.com
+
+ You'll also need a valid Dropbox account, and OAuth credentials for Dropbox. To
+ obtain OAuth credentials for Dropbox, you'll need to register a Dropbox app at
+ https://www.dropbox.com/developers/apps and then follow the instructions at
+ https://www.temboo.com/library/Library/Dropbox/OAuth/ to run the Initialize and Finalize
+ OAuth Choreos to complete the OAuth handshake and retrieve your Access Token information.
+
+ This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
+ to the Internet.
+
+ Looking for another API? We've got over 100 in our Library!
+
+ This example code is in the public domain.
+*/
+
+#include <Bridge.h>
+#include <Console.h>
+#include <FileIO.h>
+#include <HttpClient.h>
+#include <Process.h>
+#include "TembooAccount.h" // contains Temboo account information
+ // as described in the footer comment below
+
+
+/*** SUBSTITUTE YOUR VALUES BELOW: ***/
+
+// your Dropbox app key, available on the Dropbox developer console after registering an app
+const String DROPBOX_APP_KEY = "xxxxxxxxxx";
+
+// your Dropbox app secret, available on the Dropbox developer console after registering an app
+const String DROPBOX_APP_SECRET = "xxxxxxxxxx";
+
+// your Dropbox access token, which is returned by the FinalizeOAuth Choreo
+const String DROPBOX_ACCESS_TOKEN = "xxxxxxxxxx";
+
+// your Dropbox access token secret, which is returned by the FinalizeOAuth Choreo
+const String DROPBOX_ACCESS_TOKEN_SECRET = "xxxxxxxxxx";
+
+
+boolean success = false; // a flag to indicate whether we've uploaded the file yet
+
+void setup() {
+ Serial.begin(9600);
+
+ // For debugging, wait until a serial console is connected.
+ delay(4000);
+ while(!Serial);
+ Bridge.begin();
+}
+
+void loop()
+{
+ // only try to upload the file if we haven't already done so
+ if (!success) {
+
+ Serial.println("Base64 encoding data to upload...");
+
+ // base64 encode the data to upload
+ String base64EncodedData = base64Encode("Hello, Arduino!");
+
+
+ Serial.println("Uploading data to Dropbox...");
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process UploadFileChoreo;
+
+ // invoke the Temboo client
+ UploadFileChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ UploadFileChoreo.addParameter("-a");
+ UploadFileChoreo.addParameter(TEMBOO_ACCOUNT);
+ UploadFileChoreo.addParameter("-u");
+ UploadFileChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ UploadFileChoreo.addParameter("-p");
+ UploadFileChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (Dropbox > FilesAndMetadata > UploadFile)
+ UploadFileChoreo.addParameter("-c");
+ UploadFileChoreo.addParameter("/Library/Dropbox/FilesAndMetadata/UploadFile");
+
+ // set the required choreo inputs
+ // see https://www.temboo.com/library/Library/Dropbox/FilesAndMetadata/UploadFile/
+ // for complete details about the inputs for this Choreo
+
+ // first specify the name of the file to create/update on Dropbox
+ UploadFileChoreo.addParameter("-i");
+ UploadFileChoreo.addParameter("FileName:ArduinoTest.txt");
+
+ // next, the root folder on Dropbox relative to which the file path is specified.
+ // unless you're using an in-production Dropbox app, this should be left as "sandbox"
+ UploadFileChoreo.addParameter("-i");
+ UploadFileChoreo.addParameter("Root:sandbox");
+
+ // next, the Base64 encoded file data to upload
+ UploadFileChoreo.addParameter("-i");
+ UploadFileChoreo.addParameter("FileContents:" + base64EncodedData);
+
+ // finally, the Dropbox OAuth credentials defined above
+ UploadFileChoreo.addParameter("-i");
+ UploadFileChoreo.addParameter("AppSecret:" + DROPBOX_APP_SECRET);
+ UploadFileChoreo.addParameter("-i");
+ UploadFileChoreo.addParameter("AccessToken:" + DROPBOX_ACCESS_TOKEN);
+ UploadFileChoreo.addParameter("-i");
+ UploadFileChoreo.addParameter("AccessTokenSecret:" + DROPBOX_ACCESS_TOKEN_SECRET);
+ UploadFileChoreo.addParameter("-i");
+ UploadFileChoreo.addParameter("AppKey:" + DROPBOX_APP_KEY);
+
+ // tell the Process to run and wait for the results. The
+ // return code (rc) will tell us whether the Temboo client
+ // was able to send our request to the Temboo servers
+ unsigned int rc = UploadFileChoreo.run();
+
+ // a return code of zero (0) means everything worked
+ if (rc == 0) {
+ Serial.println("Success! File uploaded!");
+ success = true;
+ } else {
+ // a non-zero return code means there was an error
+ Serial.println("Uh-oh! Something went wrong!");
+ }
+
+ // print out the full response to the serial monitor in all
+ // cases, just for debugging
+ while (UploadFileChoreo.available()) {
+ Serial.print((char)UploadFileChoreo.read());
+ }
+ UploadFileChoreo.close();
+
+ Serial.println("Sleeping...");
+ }
+
+ delay(30000); // sleep 30 seconds between upload attempts
+}
+
+
+/*
+ A utility function to Base64 encode the specified string
+ by calling a Temboo Utilities Choreo.
+*/
+String base64Encode(String toEncode) {
+
+ // we need a Process object to send a Choreo request to Temboo
+ Process Base64EncodeChoreo;
+
+ // invoke the Temboo client
+ Base64EncodeChoreo.begin("temboo");
+
+ // set Temboo account credentials
+ Base64EncodeChoreo.addParameter("-a");
+ Base64EncodeChoreo.addParameter(TEMBOO_ACCOUNT);
+ Base64EncodeChoreo.addParameter("-u");
+ Base64EncodeChoreo.addParameter(TEMBOO_APP_KEY_NAME);
+ Base64EncodeChoreo.addParameter("-p");
+ Base64EncodeChoreo.addParameter(TEMBOO_APP_KEY);
+
+ // identify the Temboo Library choreo to run (Utilities > Encoding > Base64Encode)
+ Base64EncodeChoreo.addParameter("-c");
+ Base64EncodeChoreo.addParameter("/Library/Utilities/Encoding/Base64Encode");
+
+ // set choreo inputs
+ Base64EncodeChoreo.addParameter("-i");
+ Base64EncodeChoreo.addParameter("Text:" + toEncode);
+
+ // run the choreo
+ Base64EncodeChoreo.run();
+
+ // read in the choreo results, and return the "Base64EncodedText" output value.
+ // see http://www.temboo.com/arduino for more details on using choreo outputs.
+ while(Base64EncodeChoreo.available()) {
+ // read the name of the output item
+ String name = Base64EncodeChoreo.readStringUntil('\x1F');
+ name.trim();
+
+ // read the value of the output item
+ String data = Base64EncodeChoreo.readStringUntil('\x1E');
+ data.trim();
+
+ if(name == "Base64EncodedText") {
+ return data;
+ }
+ }
+}
+
+/*
+ IMPORTANT NOTE About TembooAccount.h:
+
+ TembooAccount.h is not included with this example because it contains your account information.
+ You need to create it for your own version of this application. To do so, make
+ a new tab in Arduino, call it TembooAccount.h, and include the following variables and constants:
+
+ #define TEMBOO_ACCOUNT "matthew-yun" // your Temboo account name
+ #define TEMBOO_APP_KEY_NAME "someKey" // your Temboo app key name
+ #define TEMBOO_APP_KEY "fveIrkjAVIkuNUUPE6df" // your Temboo app key
+ The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
+
+ You can find your Temboo App Key information on the Temboo website,
+ under My Account > Application Keys
+
+ Keeping your account information in a separate file means you can save it once,
+ then just distribute the main .ino file without worrying that you forgot to delete your credentials.
+*/
diff --git a/libraries/Bridge/examples/TimeCheck/TimeCheck.ino b/libraries/Bridge/examples/TimeCheck/TimeCheck.ino
new file mode 100644
index 0000000..2673dea
--- /dev/null
+++ b/libraries/Bridge/examples/TimeCheck/TimeCheck.ino
@@ -0,0 +1,79 @@
+
+/*
+ Time Check
+
+ Gets the time from the linino processor via Bridge
+ then parses out hours, minutes and seconds for the Arduino
+ using an Arduino Yun.
+
+ created 27 May 2013
+ modified 21 June 2013
+ By Tom Igoe
+ */
+
+
+#include <Process.h>
+
+Process date; // process used to get the date
+int hours, minutes, seconds; // for the results
+int lastSecond = -1; // need an impossible value for comparison
+
+void setup() {
+ Serial.begin(9600); // initialize serial
+ Bridge.begin(); // initialize Bridge
+
+ while(!Serial); // wait for Serial Monitor to open
+ Serial.println("Time Check"); // Title of sketch
+
+ // run an initial date process. Should return:
+ // hh:mm:ss :
+ if (!date.running()) {
+ date.begin("date");
+ date.addParameter("+%T");
+ date.run();
+ }
+}
+
+void loop() {
+
+ if(lastSecond != seconds) { // if a second has passed
+ // print the time:
+ if (hours <= 9) Serial.print("0"); // adjust for 0-9
+ Serial.print(hours);
+ Serial.print(":");
+ if (minutes <= 9) Serial.print("0"); // adjust for 0-9
+ Serial.print(minutes);
+ Serial.print(":");
+ if (seconds <= 9) Serial.print("0"); // adjust for 0-9
+ Serial.println(seconds);
+
+ // restart the date process:
+ if (!date.running()) {
+ date.begin("date");
+ date.addParameter("+%T");
+ date.run();
+ }
+ }
+
+ //if there's a result from the date process, parse it:
+ while (date.available()>0) {
+ // get the result of the date process (should be hh:mm:ss):
+ String timeString = date.readString();
+
+ // find the colons:
+ int firstColon = timeString.indexOf(":");
+ int secondColon= timeString.lastIndexOf(":");
+
+ // get the substrings for hour, minute second:
+ String hourString = timeString.substring(0, firstColon);
+ String minString = timeString.substring(firstColon+1, secondColon);
+ String secString = timeString.substring(secondColon+1);
+
+ // convert to ints,saving the previous second:
+ hours = hourString.toInt();
+ minutes = minString.toInt();
+ lastSecond = seconds; // save to do a time comparison
+ seconds = secString.toInt();
+ }
+
+}
diff --git a/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino b/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino
new file mode 100644
index 0000000..4df9bf0
--- /dev/null
+++ b/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino
@@ -0,0 +1,32 @@
+#include <Process.h>
+
+void setup() {
+ Serial.begin(9600); // initialize serial communication
+ while(!Serial); // do nothing until the serial monitor is opened
+
+ Serial.println("Starting bridge...\n");
+ pinMode(13,OUTPUT);
+ digitalWrite(13, LOW);
+ Bridge.begin(); // make contact with the linux processor
+ digitalWrite(13, HIGH);
+
+ delay(2000); // wait 2 seconds
+}
+
+void loop() {
+ Process wifiCheck; // initialize a new process
+
+ wifiCheck.runShellCommand("lua /arduino/pretty_wifi_info.lua"); // command you want to run
+
+ // while there's any characters coming back from the
+ // process, print them to the serial monitor:
+ while (wifiCheck.available() > 0) {
+ char thisChar = wifiCheck.read();
+ Serial.print(thisChar);
+ }
+
+ Serial.println();
+
+ delay(5000);
+}
+
diff --git a/libraries/Bridge/examples/XivelyClient/XivelyClient.ino b/libraries/Bridge/examples/XivelyClient/XivelyClient.ino
new file mode 100644
index 0000000..69f979c
--- /dev/null
+++ b/libraries/Bridge/examples/XivelyClient/XivelyClient.ino
@@ -0,0 +1,110 @@
+/*
+ Xively sensor client with Strings
+
+ This sketch connects an analog sensor to Xively,
+ using an Arduino Yún.
+
+ created 15 March 2010
+ updated 27 May 2013
+ by Tom Igoe
+
+ */
+
+// include all Libraries needed:
+#include <Process.h>
+#include "passwords.h" // contains my passwords, see below
+
+/*
+ NOTE: passwords.h is not included with this repo because it contains my passwords.
+ You need to create it for your own version of this application. To do so, make
+ a new tab in Arduino, call it passwords.h, and include the following variables and constants:
+
+ #define APIKEY "foo" // replace your pachube api key here
+ #define FEEDID 0000 // replace your feed ID
+ #define USERAGENT "my-project" // user agent is the project name
+ */
+
+
+// set up net client info:
+const unsigned long postingInterval = 60000; //delay between updates to xively.com
+unsigned long lastRequest = 0; // when you last made a request
+String dataString = "";
+
+void setup() {
+ // start serial port:
+ Bridge.begin();
+ Serial.begin(9600);
+
+ while(!Serial); // wait for Network Serial to open
+ Serial.println("Xively client");
+
+ // Do a first update immediately
+ updateData();
+ sendData();
+ lastRequest = millis();
+}
+
+void loop() {
+ // get a timestamp so you can calculate reading and sending intervals:
+ long now = millis();
+
+ // if the sending interval has passed since your
+ // last connection, then connect again and send data:
+ if (now - lastRequest >= postingInterval) {
+ updateData();
+ sendData();
+ lastRequest = now;
+ }
+}
+
+void updateData() {
+ // convert the readings to a String to send it:
+ dataString = "Temperature,";
+ dataString += random(10) + 20;
+ // add pressure:
+ dataString += "\nPressure,";
+ dataString += random(5) + 100;
+}
+
+// this method makes a HTTP connection to the server:
+void sendData() {
+ // form the string for the API header parameter:
+ String apiString = "X-ApiKey: ";
+ apiString += APIKEY;
+
+ // form the string for the URL parameter:
+ String url = "https://api.xively.com/v2/feeds/";
+ url += FEEDID;
+ url += ".csv";
+
+ // Send the HTTP PUT request
+
+ // Is better to declare the Process here, so when the
+ // sendData function finishes the resources are immediately
+ // released. Declaring it global works too, BTW.
+ Process xively;
+ Serial.print("\n\nSending data... ");
+ xively.begin("curl");
+ xively.addParameter("-k");
+ xively.addParameter("--request");
+ xively.addParameter("PUT");
+ xively.addParameter("--data");
+ xively.addParameter(dataString);
+ xively.addParameter("--header");
+ xively.addParameter(apiString);
+ xively.addParameter(url);
+ xively.run();
+ Serial.println("done!");
+
+ // If there's incoming data from the net connection,
+ // send it out the Serial:
+ while (xively.available()>0) {
+ char c = xively.read();
+ Serial.write(c);
+ }
+
+}
+
+
+
+
diff --git a/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino
new file mode 100644
index 0000000..0ae3c2e
--- /dev/null
+++ b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino
@@ -0,0 +1,73 @@
+/*
+ Arduino Yun USB-to-Serial
+
+ Allows you to use the Yun's 32U4 processor as a
+ serial terminal for the linino processor.
+
+ Upload this to an Arduino Yun via serial (not WiFi)
+ then open the serial monitor at 115200 to see the boot process
+ of the linino processor. You can also use the serial monitor
+ as a basic command line interface for the linino processor using
+ this sketch.
+
+ From the serial monitor the following commands can be issued:
+
+ '~' followed by '0' -> Set the UART speed to 57600 baud
+ '~' followed by '1' -> Set the UART speed to 115200 baud
+ '~' followed by '2' -> Set the UART speed to 250000 baud
+ '~' followed by '3' -> Set the UART speed to 500000 baud
+
+ The circuit:
+ * Arduino Yun
+
+ created March 2013
+ by Massimo Banzi
+ modified by Cristian Maglie
+
+ This example code is in the public domain.
+ */
+
+long lininoBaud = 250000;
+
+void setup() {
+ Serial.begin(115200); // open serial connection via USB-Serial
+ Serial1.begin(lininoBaud); // open serial connection to Linino
+}
+
+boolean commandMode = false;
+
+void loop() {
+ // copy from virtual serial line to uart and vice versa
+ if (Serial.available()) { // got anything from USB-Serial?
+ char c = (char)Serial.read(); // read from USB-serial
+ if (commandMode == false) { // if we aren't in command mode...
+ if (c == '~') { // Tilde '~' key pressed?
+ commandMode = true; // enter in command mode
+ } else {
+ Serial1.write(c); // otherwise write char to Linino
+ }
+ } else { // if we are in command mode...
+ if (c == '0') { // '0' key pressed?
+ Serial1.begin(57600); // set speed to 57600
+ Serial.println("Speed set to 57600");
+ } else if (c == '1') { // '1' key pressed?
+ Serial1.begin(115200); // set speed to 115200
+ Serial.println("Speed set to 115200");
+ } else if (c == '2') { // '2' key pressed?
+ Serial1.begin(250000); // set speed to 250000
+ Serial.println("Speed set to 250000");
+ } else if (c == '3') { // '3' key pressed?
+ Serial1.begin(500000); // set speed to 500000
+ Serial.println("Speed set to 500000");
+ } else { // any other key pressed?
+ Serial1.write('~'); // write '~' to Linino
+ Serial1.write(c); // write char to Linino
+ }
+ commandMode = false; // in all cases exit from command mode
+ }
+ }
+ if (Serial1.available()) { // got anything from Linino?
+ char c = (char)Serial1.read(); // read from Linino
+ Serial.write(c); // write to USB-serial
+ }
+}