Using Temboo with the Arduino Yún is pretty easy, but there are still some things that can go wrong. This document gives some tips and techniques to use when that happens.
Also, don't forget that you can check out the Arduino Forum for help with everything else to do with your Yún.
Your sketch should always check the value returned by the TembooChoreo.run()
statement to determine whether the Choreo execution succeeded. Even if your code does everything exactly right, the Choreo may fail due to a problem at the web service, at Temboo, or anywhere on the network between your Yún board and the service you're trying to use. Your sketch code should look something like this:
TembooChoreo choreo; choreo.begin(); choreo.setAccountName("MyTembooAccount"); ... unsigned int rc = choreo.run(); if (rc == 0) { // success! Do something cool. } else { // failure. Handle the error. }
What exactly "handle the error" means depends on your application. You may want to store the sensor values for later, flash a light, sound a horn, or whatever you think is appropriate. It may also depend on what specific code is returned. Some codes indicate problems that might go away in time (say, if the web service your Choreo uses is temporarily unavailable) while others will require manual intervention or code changes to handle.
See our Technical Documentation for details on each return code.
In most cases when something goes wrong, the Temboo client will return a short error message describing what happened. If you are developing your sketch with the Arduino IDE, you can try displaying the raw data returned from the TembooChoreo.run()
statement in the serial monitor.
The code snippet below illustrates how you would do this.
TembooChoreo choreo; choreo.begin(); choreo.setAccountName("MyTembooAccount"); ... unsigned int rc = choreo.run(); if (rc == 0) { // success! Do something cool. } else { while(choreo.available()) { char c = choreo.read(); Serial.print(c); } }
Suppose you forgot to include the application key name parameter. The raw output from the execution would look something like this when displayed in the Serial monitor in the Arduino IDE:
Error (-u) missing application key name. HTTP_CODE 000
That message is telling you that the Choreo couldn't execute because no application key name was specified. It also reminds you that the parameter for specifying the application key name is -u
(if you're using a settings file.)
The Temboo client on your Yún tries to detect problems like missing parameters before it sends the request to Temboo. However, there are some problems that it can't detect ahead of time. These are typically connection problems, either between the client and the Temboo platform, or between the Temboo platform and the web service the Choreo uses.
In these cases, you may have to examine the HTTP_CODE
returned with the output data to figure out what the problem is. If you want to avoid printing everything to the serial monitor and just focus on the HTTP_CODE
value, your code would look like this:
TembooChoreo choreo; choreo.begin(); choreo.setAccountName("MyTembooAccount"); ... unsigned int rc = choreo.run(); if (rc == 0) { // success! Do something cool. } else { while(choreo.available()) { String name = choreo.readStringUntil('\x1F'); name.trim(); String value = choreo.readStringUntil('\x1E'); value.trim(); if (name == "HTTP_CODE") { Serial.print("HTTP_CODE: "); Serial.println(value); } } }
If you want to learn more about HTTP status codes, Wikipedia’s explanations are relatively easy to understand.
Note: in cases where the client can not contact Temboo, the HTTP_CODE
may be reported as 000
, which is not an official code. In this event, the client return code and/or error message should contain more information about the problem.
We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.