33
44 Demonstrates appending a row of data to a Google spreadsheet using Temboo from an Arduino Yún.
55
6- Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
6+ Check out the latest Arduino & Temboo examples and tutorials at http://www.temboo.com/arduino
77
88 A Temboo account and application key are necessary to run all Temboo examples.
99 If you don't already have one, you can register for a free Temboo account at
1212 Instructions:
1313
1414 1. Create a Temboo account: http://www.temboo.com
15+
1516 2. Retrieve your Temboo application details: http://www.temboo.com/account/applications
17+
1618 3. Replace the values in the TembooAccount.h tab with your Temboo application details
19+
1720 4. You'll also need a Google Spreadsheet that includes a title in the first row
1821 of each column that data will be written to. This example assumes there are two columns.
1922 The first column is the time (in milliseconds) that the row was appended, and the second
2932
3033 https://temboo.com/library/Library/Google/OAuth/
3134
32- For the scope field, you need to use: https://spreadsheets.google .com/feeds/
35+ For the scope field, you need to use: https://www.googleapis .com/auth/spreadsheets
3336
3437 Here's a video outlines how Temboo helps with the OAuth process:
3538
3639 https://www.temboo.com/videos#oauthchoreos
3740
3841 And here's a more in-depth version of this example on our website:
3942
40- https://temboo.com/hardware/ti/update-google-spreadsheet
41-
42- 6. Next, upload the sketch to your Arduino Yún and open Arduino's serial monitor
43+ https://temboo.com/arduino/yun/update-google-spreadsheet
4344
45+ 6. Next, upload the sketch to your Arduino Yún and open the serial monitor
46+
4447 Note: you can test this Choreo and find the latest instructions on our website:
45- https://temboo.com/library/Library/Google/Spreadsheets/AppendRow /
48+ https://temboo.com/library/Library/Google/Sheets/AppendValues /
4649
4750 Looking for another API to use with your Arduino Yún? We've got over 100 in our Library!
4851
6164// Note that for additional security and reusability, you could
6265// use #define statements to specify these values in a .h file.
6366
64- // the clientID found in Google's Developer Console under APIs & Auth > Credentials
67+ // the clientID found in Google's Developer Console under API Manager > Credentials
6568const String CLIENT_ID = " your-client-id" ;
6669
67- // the clientSecret found in Google's Developer Console under APIs & Auth > Credentials
70+ // the clientSecret found in Google's Developer Console under API Manager > Credentials
6871const String CLIENT_SECRET = " your-client-secret" ;
6972
7073// returned after running FinalizeOAuth
7174const String REFRESH_TOKEN = " your-oauth-refresh-token" ;
7275
73- // the title of the spreadsheet you want to send data to
74- // (Note that this must actually be the title of a Google spreadsheet
75- // that exists in your Google Drive/Docs account, and is configured
76- // as described above.)
77- const String SPREADSHEET_TITLE = " your-spreadsheet-title " ;
76+ // The ID of the spreadsheet you want to send data to
77+ // which can be found in the URL when viewing your spreadsheet at Google. For example,
78+ // the ID in the URL below is: "1tvFW2n-xFFJCE1q5j0HTetOsDhhgw7_998_K4sFtk"
79+ // Sample URL: https://docs.google.com/spreadsheets/d/1tvFW2n-xFFJCE1q5j0HTetOsDhhgw7_998_K4sFtk/edit
80+ const String SPREADSHEET_ID = " your-spreadsheet-id " ;
7881
7982const unsigned long RUN_INTERVAL_MILLIS = 60000 ; // how often to run the Choreo (in milliseconds)
8083
@@ -114,47 +117,44 @@ void loop()
114117 Serial.println (" Appending value to spreadsheet..." );
115118
116119 // we need a Process object to send a Choreo request to Temboo
117- TembooChoreo AppendRowChoreo ;
120+ TembooChoreo AppendValuesChoreo ;
118121
119122 // invoke the Temboo client
120123 // NOTE that the client must be reinvoked and repopulated with
121124 // appropriate arguments each time its run() method is called.
122- AppendRowChoreo .begin ();
125+ AppendValuesChoreo .begin ();
123126
124127 // set Temboo account credentials
125- AppendRowChoreo .setAccountName (TEMBOO_ACCOUNT);
126- AppendRowChoreo .setAppKeyName (TEMBOO_APP_KEY_NAME);
127- AppendRowChoreo .setAppKey (TEMBOO_APP_KEY);
128+ AppendValuesChoreo .setAccountName (TEMBOO_ACCOUNT);
129+ AppendValuesChoreo .setAppKeyName (TEMBOO_APP_KEY_NAME);
130+ AppendValuesChoreo .setAppKey (TEMBOO_APP_KEY);
128131
129- // identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow )
130- AppendRowChoreo .setChoreo (" /Library/Google/Spreadsheets/AppendRow " );
132+ // identify the Temboo Library choreo to run (Google > Sheets > AppendValues )
133+ AppendValuesChoreo .setChoreo (" /Library/Google/Sheets/AppendValues " );
131134
132135 // set the required Choreo inputs
133- // see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow /
136+ // see https://www.temboo.com/library/Library/Google/Sheets/AppendValues /
134137 // for complete details about the inputs for this Choreo
135138
136139 // your Google application client ID
137- AppendRowChoreo .addInput (" ClientID" , CLIENT_ID);
138- // your Google application client secert
139- AppendRowChoreo .addInput (" ClientSecret" , CLIENT_SECRET);
140+ AppendValuesChoreo .addInput (" ClientID" , CLIENT_ID);
141+ // your Google application client secret
142+ AppendValuesChoreo .addInput (" ClientSecret" , CLIENT_SECRET);
140143 // your Google OAuth refresh token
141- AppendRowChoreo .addInput (" RefreshToken" , REFRESH_TOKEN);
144+ AppendValuesChoreo .addInput (" RefreshToken" , REFRESH_TOKEN);
142145
143- // the title of the spreadsheet you want to append to
144- // NOTE: substitute your own value, retaining the "SpreadsheetTitle:" prefix.
145- AppendRowChoreo.addInput (" SpreadsheetTitle" , SPREADSHEET_TITLE);
146+ // the ID of the spreadsheet you want to append to
147+ AppendValuesChoreo.addInput (" SpreadsheetID" , SPREADSHEET_ID);
146148
147149 // convert the time and sensor values to a comma separated string
148- String rowData (now);
149- rowData += " ," ;
150- rowData += sensorValue;
150+ String rowData = " [[\" " + String (now) + " \" , \" " + String (sensorValue) + " \" ]]" ;
151151
152152 // add the RowData input item
153- AppendRowChoreo .addInput (" RowData " , rowData);
153+ AppendValuesChoreo .addInput (" Values " , rowData);
154154
155155 // run the Choreo and wait for the results
156156 // The return code (returnCode) will indicate success or failure
157- unsigned int returnCode = AppendRowChoreo .run ();
157+ unsigned int returnCode = AppendValuesChoreo .run ();
158158
159159 // return code of zero (0) means success
160160 if (returnCode == 0 ) {
@@ -163,13 +163,13 @@ void loop()
163163 } else {
164164 // return code of anything other than zero means failure
165165 // read and display any error messages
166- while (AppendRowChoreo .available ()) {
167- char c = AppendRowChoreo .read ();
166+ while (AppendValuesChoreo .available ()) {
167+ char c = AppendValuesChoreo .read ();
168168 Serial.print (c);
169169 }
170170 }
171171
172- AppendRowChoreo .close ();
172+ AppendValuesChoreo .close ();
173173 }
174174}
175175
0 commit comments