Arduino Yun通过Temboo更新Google Sheets无响应但返回码0问题排查
问题:Temboo + Arduino Yun 无法更新Google Sheets但返回码为0
我正在尝试通过Temboo和Arduino Yun更新Google Sheets。在Temboo平台直接运行AppendValues与AppendRow Choreo时,可正常更新表格;但通过Arduino .ino代码运行时,Google Sheets无任何更新,不过Choreo返回码为0,说明OAuth验证正常,推测代码存在问题。
我已反复核对Arduino代码中的AccountName、Password、AppKey、Refresh Token、Client Secret、Client ID、Spreadsheet ID、表格名称等信息,分别尝试了AppendRowChoreo和AppendValuesChoreo,代码如下:
AppendRow .ino代码
// Include required libraries #include <Bridge.h> #include <Temboo.h> // Debug mode ? boolean debug_mode = true; void setup() { //start serial Serial.begin(115200); delay(4000); while(!Serial); // Start bridge Bridge.begin(); Serial.println("Setup complete. Waiting for sensor input...\n"); } void loop() { Serial.println("\nCalling the /Library/Google/Spreadsheets/AppendRow Choreo..."); // Append data to Google Docs sheet runAppendRow(); // Repeat every 10 seconds delay(10000); } // Function to add data to Google Docs void runAppendRow() { TembooChoreo AppendRowChoreo; // Invoke the Temboo client AppendRowChoreo.begin(); // Set Temboo account credentials AppendRowChoreo.setAccountName(""); AppendRowChoreo.setAppKeyName("myFirstApp"); AppendRowChoreo.setAppKey(""); // Identify the Choreo to run AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow"); // your Google username (usually your email address) AppendRowChoreo.addInput("Username", ""); // your Google account password AppendRowChoreo.addInput("Password", ""); // the title of the spreadsheet you want to append to AppendRowChoreo.addInput("SpreadsheetTitle", "Yun"); // Format data String data = "123,921"; // Set Choreo inputs AppendRowChoreo.addInput("RowData", data); // Run the Choreo unsigned int returnCode = AppendRowChoreo.run(); // A return code of zero means everything worked if (returnCode == 0) { if (debug_mode == true){ Serial.println("Completed execution of the /Library/Google/Spreadsheets/AppendRow Choreo.\n"); Serial.println("Row added: " + data); } } else { // A non-zero return code means there was an error // Read and print the error message while (AppendRowChoreo.available()) { char c = AppendRowChoreo.read(); if (debug_mode == true){ Serial.print(c); } } if (debug_mode == true){ Serial.println(); } } AppendRowChoreo.close(); }
AppendValues .ino代码
#include <Bridge.h> #include <Temboo.h> int calls = 1; // Execution count, so this doesn't run forever int maxCalls = 10; // Maximum number of times the Choreo should be executed void setup() { Serial.begin(9600); // For debugging, wait until the serial console is connected delay(4000); while(!Serial); Bridge.begin(); } void loop() { if (calls <= maxCalls) { Serial.println("Running AppendValues - Run #" + String(calls++)); TembooChoreo AppendValuesChoreo; // Invoke the Temboo client AppendValuesChoreo.begin(); // Set Temboo account credentials AppendValuesChoreo.setAccountName(""); AppendValuesChoreo.setAppKeyName(""); AppendValuesChoreo.setAppKey(""); // Set Choreo inputs AppendValuesChoreo.addInput("RefreshToken", ""); AppendValuesChoreo.addInput("ClientSecret", ""); AppendValuesChoreo.addInput("Values", "[[15,49]]"); AppendValuesChoreo.addInput("ClientID", ""); AppendValuesChoreo.addInput("SpreadsheetID", ""); // Identify the Choreo to run AppendValuesChoreo.setChoreo("/Library/Google/Sheets/AppendValues"); // Run the Choreo; when results are available, print them to serial AppendValuesChoreo.run(); while(AppendValuesChoreo.available()) { char c = AppendValuesChoreo.read(); Serial.print(c); } AppendValuesChoreo.close(); } Serial.println("Waiting..."); delay(30000); // wait 30 seconds between AppendValues calls }
内容的提问来源于stack exchange,提问作者Ezra Underwood
相关产品推荐
相关产品推荐

