mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
included newest Temboo examples
This commit is contained in:
parent
1f8e061350
commit
8ac5c7c076
@ -0,0 +1,103 @@
|
||||
/*
|
||||
GetYahooWeatherReport
|
||||
|
||||
Demonstrates making a request to the Yahoo! Weather API using the Temboo Arduino Yun SDK.
|
||||
|
||||
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. For more tutorials on using the Temboo Library and Temboo Arduino Yun SDK, visit
|
||||
http://www.temboo.com/arduino
|
||||
|
||||
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 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...");
|
||||
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.
|
||||
|
||||
Visit https://www.temboo.com/account to access your Temboo account credentials.
|
||||
|
||||
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.
|
||||
*/
|
@ -0,0 +1,174 @@
|
||||
/*
|
||||
ReadATweet
|
||||
|
||||
Demonstrates retrieving the most recent Tweet from a user's home timeline
|
||||
using the Temboo Arduino Yun SDK.
|
||||
|
||||
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. For more tutorials on using the Temboo Library and
|
||||
Temboo Arduino Yun SDK, visit http://www.temboo.com/arduino
|
||||
|
||||
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 below
|
||||
|
||||
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 HomeTimeline - 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
|
||||
|
||||
// IMPORTANT! You'll need to substitute your own Access Token, Access Token Secret,
|
||||
// Consumer Secret, and Consumer Key from the Twitter dev console into the method calls
|
||||
// below. (Make sure not to delete the "AccessToken:" etc prefixes!)
|
||||
HomeTimelineChoreo.addParameter("-i");
|
||||
HomeTimelineChoreo.addParameter("AccessToken:your-twitter-access-token");
|
||||
HomeTimelineChoreo.addParameter("-i");
|
||||
HomeTimelineChoreo.addParameter("AccessTokenSecret:your-twitter-access-token-secret");
|
||||
HomeTimelineChoreo.addParameter("-i");
|
||||
HomeTimelineChoreo.addParameter("ConsumerSecret:your-twitter-consumer-secret");
|
||||
HomeTimelineChoreo.addParameter("-i");
|
||||
HomeTimelineChoreo.addParameter("ConsumerKey:your-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...");
|
||||
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.
|
||||
|
||||
Visit https://www.temboo.com/account to access your Temboo account credentials.
|
||||
|
||||
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.
|
||||
*/
|
@ -0,0 +1,142 @@
|
||||
/*
|
||||
SendAnEmail
|
||||
|
||||
Demonstrates sending an email via a Google Gmail account
|
||||
using the Temboo Arduino Yun SDK.
|
||||
|
||||
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. For more tutorials on using the Temboo Library and Temboo Arduino Yun SDK, visit
|
||||
http://www.temboo.com/arduino
|
||||
|
||||
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 below
|
||||
|
||||
|
||||
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 SendEmail ...");
|
||||
|
||||
// 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.
|
||||
// NOTE: substitute your own value, retaining the "Username:" prefix.
|
||||
SendEmailChoreo.addParameter("-i");
|
||||
SendEmailChoreo.addParameter("Username:your-gmail-username");
|
||||
|
||||
// next is your Gmail password.
|
||||
// NOTE: substitute your own value, retaining the "Password:" prefix
|
||||
SendEmailChoreo.addParameter("-i");
|
||||
SendEmailChoreo.addParameter("Password:your-gmail-password");
|
||||
|
||||
// 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!");
|
||||
|
||||
// next is the email address of who the email is from.
|
||||
// NOTE: substitute your Gmail address, retaining the "FromAddress:" prefix.
|
||||
SendEmailChoreo.addParameter("-i");
|
||||
SendEmailChoreo.addParameter("FromAddress:your-gmail-email-address");
|
||||
|
||||
// who to send the email to
|
||||
// NOTE: substitute your desired recipient, retaining the "ToAddress:" prefix
|
||||
SendEmailChoreo.addParameter("-i");
|
||||
SendEmailChoreo.addParameter("ToAddress:recipient-email-address");
|
||||
|
||||
// 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.
|
||||
|
||||
Visit https://www.temboo.com/account to access your Temboo account credentials.
|
||||
|
||||
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.
|
||||
|
||||
(Be sure to delete this comment after creating your TembooAccount.h file!)
|
||||
*/
|
||||
|
@ -0,0 +1,165 @@
|
||||
/*
|
||||
SendDataToGoogleSpreadsheet
|
||||
|
||||
Demonstrates appending a row of data to a Google spreadsheet
|
||||
from the Arduino Yun using the Temboo Arduino Yun SDK.
|
||||
|
||||
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. For more tutorials on using the Temboo Library
|
||||
and Temboo Arduino Yun SDK, visit http://www.temboo.com/arduino
|
||||
|
||||
Since this sketch uses a Google spreadsheet, you'll also need a
|
||||
Google account: substitute the placeholders below for your Google account values.
|
||||
|
||||
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).
|
||||
|
||||
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 below
|
||||
|
||||
|
||||
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)
|
||||
// NOTE: substitute your own value, retaining the "Username:" prefix.
|
||||
AppendRowChoreo.addParameter("-i");
|
||||
AppendRowChoreo.addParameter("Username:your-google-username");
|
||||
|
||||
// your Google account password
|
||||
// NOTE: substitute your own value, retaining the "Password:" prefix.
|
||||
AppendRowChoreo.addParameter("-i");
|
||||
AppendRowChoreo.addParameter("Password:your-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:your-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);
|
||||
} 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.
|
||||
|
||||
Visit https://www.temboo.com/account to access your Temboo account credentials.
|
||||
|
||||
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.
|
||||
|
||||
(Be sure to delete this comment after creating your TembooAccount.h file!)
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user