Skip to content

Commit 4ae392b

Browse files
author
Federico Fissore
committed
updated and added new Temboo examples
1 parent 0d07ff9 commit 4ae392b

File tree

9 files changed

+921
-59
lines changed

9 files changed

+921
-59
lines changed

hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
GetYahooWeatherReport
33
44
Demonstrates making a request to the Yahoo! Weather API using the Temboo Arduino Yun SDK.
5+
6+
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
57
68
A Temboo account and application key are necessary to run all Temboo examples.
7-
If you don't already have one, you can register for a free Temboo account at
9+
If you don't already have one, you can register for a free Temboo account at
810
http://www.temboo.com
911
1012
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
11-
to the Internet. For more tutorials on using the Temboo Library and Temboo Arduino Yun SDK, visit
12-
http://www.temboo.com/arduino
13+
to the Internet.
14+
15+
Looking for another API? We've got over 100 in our Library!
1316
1417
This example code is in the public domain.
1518
*/
@@ -19,7 +22,8 @@
1922
#include <FileIO.h>
2023
#include <HttpClient.h>
2124
#include <Process.h>
22-
#include "TembooAccount.h" // contains Temboo account information, as described below
25+
#include "TembooAccount.h" // contains Temboo account information
26+
// as described in the footer comment below
2327

2428
int numRuns = 0; // execution count, so that this doesn't run forever
2529
int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run
@@ -38,7 +42,7 @@ void loop()
3842
if (numRuns < maxRuns) {
3943

4044
// print status
41-
Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++));
45+
Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "...");
4246

4347
// we need a Process object to send a Choreo request to Temboo
4448
Process GetWeatherByAddressChoreo;
@@ -80,6 +84,7 @@ void loop()
8084
}
8185

8286
Serial.println("Sleeping...");
87+
Serial.println("");
8388
delay(30000); // sleep 30 seconds between GetWeatherByAddress calls
8489
}
8590

@@ -96,7 +101,8 @@ void loop()
96101
97102
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
98103
99-
Visit https://www.temboo.com/account to access your Temboo account credentials.
104+
You can find your Temboo App Key information on the Temboo website,
105+
under My Account > Application Keys
100106
101107
Keeping your account information in a separate file means you can save it once,
102108
then just distribute the main .ino file without worrying that you forgot to delete your credentials.

hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Demonstrates retrieving the most recent Tweet from a user's home timeline
55
using the Temboo Arduino Yun SDK.
66
7+
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
8+
79
A Temboo account and application key are necessary to run all Temboo examples.
810
If you don't already have one, you can register for a free Temboo account at
911
http://www.temboo.com
@@ -14,8 +16,9 @@
1416
Substitute these values for the placeholders below.
1517
1618
This example assumes basic familiarity with Arduino sketches, and that your Yun
17-
is connected to the Internet. For more tutorials on using the Temboo Library and
18-
Temboo Arduino Yun SDK, visit http://www.temboo.com/arduino
19+
is connected to the Internet.
20+
21+
Looking for social APIs? We've got Facebook, Google+, Instagram, Tumblr and more.
1922
2023
This example code is in the public domain.
2124
*/
@@ -25,7 +28,15 @@
2528
#include <FileIO.h>
2629
#include <HttpClient.h>
2730
#include <Process.h>
28-
#include "TembooAccount.h" // contains Temboo account information, as described below
31+
#include "TembooAccount.h" // contains Temboo account information
32+
// as described in the footer comment below
33+
34+
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
35+
36+
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
37+
const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
38+
const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
39+
const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
2940

3041
int numRuns = 0; // execution count, so this sketch doesn't run forever
3142
int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
@@ -45,7 +56,7 @@ void loop()
4556
if (numRuns < maxRuns) {
4657

4758
// print status
48-
Serial.println("Running HomeTimeline - Run #" + String(numRuns++));
59+
Serial.println("Running ReadATweet - Run #" + String(numRuns++) + "...");
4960

5061
// define the Process that will be used to call the "temboo" client
5162
Process HomeTimelineChoreo;
@@ -71,18 +82,16 @@ void loop()
7182

7283
HomeTimelineChoreo.addParameter("-i");
7384
HomeTimelineChoreo.addParameter("Count:1"); // the max number of Tweets to return from each request
74-
75-
// IMPORTANT! You'll need to substitute your own Access Token, Access Token Secret,
76-
// Consumer Secret, and Consumer Key from the Twitter dev console into the method calls
77-
// below. (Make sure not to delete the "AccessToken:" etc prefixes!)
85+
86+
// add the Twitter account information
7887
HomeTimelineChoreo.addParameter("-i");
79-
HomeTimelineChoreo.addParameter("AccessToken:your-twitter-access-token");
88+
HomeTimelineChoreo.addParameter("AccessToken:" + TWITTER_ACCESS_TOKEN);
8089
HomeTimelineChoreo.addParameter("-i");
81-
HomeTimelineChoreo.addParameter("AccessTokenSecret:your-twitter-access-token-secret");
90+
HomeTimelineChoreo.addParameter("AccessTokenSecret:" + TWITTER_ACCESS_TOKEN_SECRET);
8291
HomeTimelineChoreo.addParameter("-i");
83-
HomeTimelineChoreo.addParameter("ConsumerSecret:your-twitter-consumer-secret");
92+
HomeTimelineChoreo.addParameter("ConsumerSecret:" + TWITTER_CONSUMER_SECRET);
8493
HomeTimelineChoreo.addParameter("-i");
85-
HomeTimelineChoreo.addParameter("ConsumerKey:your-twitter-consumer-key");
94+
HomeTimelineChoreo.addParameter("ConsumerKey:" + TWITTER_CONSUMER_KEY);
8695

8796
// next, we'll define two output filters that let us specify the
8897
// elements of the response from Twitter that we want to receive.
@@ -151,6 +160,7 @@ void loop()
151160
}
152161

153162
Serial.println("Sleeping...");
163+
Serial.println("");
154164
delay(90000); // sleep 90 seconds between HomeTimeline calls
155165
}
156166

@@ -167,7 +177,8 @@ void loop()
167177
168178
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
169179
170-
Visit https://www.temboo.com/account to access your Temboo account credentials.
180+
You can find your Temboo App Key information on the Temboo website,
181+
under My Account > Application Keys
171182
172183
Keeping your account information in a separate file means you can save it once,
173184
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
SendATweet
3+
4+
Demonstrates sending a tweet via a Twitter account using the Temboo Arduino Yun SDK.
5+
6+
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
7+
8+
A Temboo account and application key are necessary to run all Temboo examples.
9+
If you don't already have one, you can register for a free Temboo account at
10+
http://www.temboo.com
11+
12+
In order to run this sketch, you'll need to register an application using
13+
the Twitter dev console at https://dev.twitter.com. After creating the
14+
app, you'll find OAuth credentials for that application under the "OAuth Tool" tab.
15+
Substitute these values for the placeholders below.
16+
17+
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
18+
to the Internet.
19+
20+
Looking for social APIs? We've got Facebook, Google+, Instagram, Tumblr and more.
21+
22+
This example code is in the public domain.
23+
*/
24+
25+
#include <Bridge.h>
26+
#include <Console.h>
27+
#include <FileIO.h>
28+
#include <HttpClient.h>
29+
#include <Process.h>
30+
#include "TembooAccount.h" // contains Temboo account information
31+
// as described in the footer comment below
32+
33+
34+
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
35+
36+
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
37+
const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
38+
const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
39+
const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
40+
41+
int numRuns = 1; // execution count, so this sketch doesn't run forever
42+
int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
43+
44+
void setup() {
45+
Serial.begin(9600);
46+
47+
// for debugging, wait until a serial console is connected
48+
delay(4000);
49+
while(!Serial);
50+
51+
Bridge.begin();
52+
}
53+
54+
void loop()
55+
{
56+
// only try to send the tweet if we haven't already sent it successfully
57+
if (numRuns <= maxRuns) {
58+
59+
Serial.println("Running SendATweet - Run #" + String(numRuns++) + "...");
60+
61+
// we need a Process object to send a Choreo request to Temboo
62+
Process StatusesUpdateChoreo;
63+
64+
// invoke the Temboo client
65+
StatusesUpdateChoreo.begin("temboo");
66+
67+
// set Temboo account credentials
68+
StatusesUpdateChoreo.addParameter("-a");
69+
StatusesUpdateChoreo.addParameter(TEMBOO_ACCOUNT);
70+
StatusesUpdateChoreo.addParameter("-u");
71+
StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY_NAME);
72+
StatusesUpdateChoreo.addParameter("-p");
73+
StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY);
74+
75+
// identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
76+
StatusesUpdateChoreo.addParameter("-c");
77+
StatusesUpdateChoreo.addParameter("/Library/Twitter/Tweets/StatusesUpdate");
78+
79+
// set the required choreo inputs
80+
// see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
81+
// for complete details about the inputs for this Choreo
82+
83+
// add the Twitter account information
84+
StatusesUpdateChoreo.addParameter("-i");
85+
StatusesUpdateChoreo.addParameter("AccessToken:" + TWITTER_ACCESS_TOKEN);
86+
StatusesUpdateChoreo.addParameter("-i");
87+
StatusesUpdateChoreo.addParameter("AccessTokenSecret:" + TWITTER_ACCESS_TOKEN_SECRET);
88+
StatusesUpdateChoreo.addParameter("-i");
89+
StatusesUpdateChoreo.addParameter("ConsumerSecret:" + TWITTER_CONSUMER_SECRET);
90+
StatusesUpdateChoreo.addParameter("-i");
91+
StatusesUpdateChoreo.addParameter("ConsumerKey:" + TWITTER_CONSUMER_KEY);
92+
93+
String tweet("My Arduino Yun has been running for " + String(millis()) + " milliseconds.");
94+
95+
StatusesUpdateChoreo.addParameter("-i");
96+
StatusesUpdateChoreo.addParameter("StatusUpdate:" + tweet);
97+
98+
// tell the Process to run and wait for the results. The
99+
// return code (rc) will tell us whether the Temboo client
100+
// was able to send our request to the Temboo servers
101+
unsigned int rc = StatusesUpdateChoreo.run();
102+
103+
// a return code of zero (0) means everything worked
104+
if (rc == 0) {
105+
Serial.println("Success! Tweet sent!");
106+
} else {
107+
// a non-zero return code means there was an error
108+
// read and print the error message
109+
while (StatusesUpdateChoreo.available()) {
110+
Serial.print((char)StatusesUpdateChoreo.read());
111+
}
112+
}
113+
StatusesUpdateChoreo.close();
114+
115+
// do nothing for the next 90 seconds
116+
Serial.println("Sleeping...");
117+
delay(90000);
118+
}
119+
}
120+
121+
/*
122+
IMPORTANT NOTE: TembooAccount.h:
123+
124+
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
125+
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
126+
include the following variables and constants:
127+
128+
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
129+
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
130+
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
131+
132+
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
133+
134+
You can find your Temboo App Key information on the Temboo website,
135+
under My Account > Application Keys
136+
137+
Keeping your account information in a separate file means you can save it once,
138+
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
139+
*/
140+
141+
142+

hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/*
22
SendAnEmail
33
4-
Demonstrates sending an email via a Google Gmail account
5-
using the Temboo Arduino Yun SDK.
4+
Demonstrates sending an email via a Google Gmail account using the Temboo Arduino Yun SDK.
5+
6+
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
67
78
A Temboo account and application key are necessary to run all Temboo examples.
89
If you don't already have one, you can register for a free Temboo account at
@@ -13,9 +14,10 @@
1314
to log into your Gmail account: substitute the placeholders below for these values.
1415
1516
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
16-
to the Internet. For more tutorials on using the Temboo Library and Temboo Arduino Yun SDK, visit
17-
http://www.temboo.com/arduino
17+
to the Internet.
1818
19+
Looking for another API? We've got over 100 in our Library!
20+
1921
This example code is in the public domain.
2022
*/
2123

@@ -24,7 +26,19 @@
2426
#include <FileIO.h>
2527
#include <HttpClient.h>
2628
#include <Process.h>
27-
#include "TembooAccount.h" // contains Temboo account information, as described below
29+
#include "TembooAccount.h" // contains Temboo account information
30+
// as described in the footer comment below
31+
32+
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
33+
34+
// your Gmail address, eg "bob.smith@gmail.com"
35+
const String GMAIL_USER_NAME = "xxxxxxxxxx";
36+
37+
// your Gmail password
38+
const String GMAIL_PASSWORD = "xxxxxxxxxx";
39+
40+
// the email address you want to send the email to, eg "jane.doe@temboo.com"
41+
const String TO_EMAIL_ADDRESS = "xxxxxxxxxx";
2842

2943

3044
boolean success = false; // a flag to indicate whether we've sent the email yet or not
@@ -44,7 +58,7 @@ void loop()
4458
// only try to send the email if we haven't already sent it successfully
4559
if (!success) {
4660

47-
Serial.println("Running SendEmail ...");
61+
Serial.println("Running SendAnEmail...");
4862

4963
// we need a Process object to send a Choreo request to Temboo
5064
Process SendEmailChoreo;
@@ -69,15 +83,17 @@ void loop()
6983
// for complete details about the inputs for this Choreo
7084

7185
// the first input is a your Gmail user name.
72-
// NOTE: substitute your own value, retaining the "Username:" prefix.
7386
SendEmailChoreo.addParameter("-i");
74-
SendEmailChoreo.addParameter("Username:your-gmail-username");
87+
SendEmailChoreo.addParameter("Username:" + GMAIL_USER_NAME);
7588

7689
// next is your Gmail password.
77-
// NOTE: substitute your own value, retaining the "Password:" prefix
7890
SendEmailChoreo.addParameter("-i");
79-
SendEmailChoreo.addParameter("Password:your-gmail-password");
80-
91+
SendEmailChoreo.addParameter("Password:" + GMAIL_PASSWORD);
92+
93+
// who to send the email to
94+
SendEmailChoreo.addParameter("-i");
95+
SendEmailChoreo.addParameter("ToAddress:" + TO_EMAIL_ADDRESS);
96+
8197
// then a subject line
8298
SendEmailChoreo.addParameter("-i");
8399
SendEmailChoreo.addParameter("Subject:ALERT: Greenhouse Temperature");
@@ -86,16 +102,6 @@ void loop()
86102
SendEmailChoreo.addParameter("-i");
87103
SendEmailChoreo.addParameter("MessageBody:Hey! The greenhouse is too cold!");
88104

89-
// next is the email address of who the email is from.
90-
// NOTE: substitute your Gmail address, retaining the "FromAddress:" prefix.
91-
SendEmailChoreo.addParameter("-i");
92-
SendEmailChoreo.addParameter("FromAddress:your-gmail-email-address");
93-
94-
// who to send the email to
95-
// NOTE: substitute your desired recipient, retaining the "ToAddress:" prefix
96-
SendEmailChoreo.addParameter("-i");
97-
SendEmailChoreo.addParameter("ToAddress:recipient-email-address");
98-
99105
// tell the Process to run and wait for the results. The
100106
// return code (rc) will tell us whether the Temboo client
101107
// was able to send our request to the Temboo servers
@@ -132,11 +138,10 @@ void loop()
132138
133139
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
134140
135-
Visit https://www.temboo.com/account to access your Temboo account credentials.
141+
You can find your Temboo App Key information on the Temboo website,
142+
under My Account > Application Keys
136143
137144
Keeping your account information in a separate file means you can save it once,
138145
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
139-
140-
(Be sure to delete this comment after creating your TembooAccount.h file!)
141146
*/
142147

0 commit comments

Comments
 (0)