Using data from Temboo

Hi,
I tried to get data from Temboo service to my Arduino Yun board and want to use them as an output to further processing (displaying on big 7-segment displays). So far it was very simple because I only filled input forms and output was generated as a code for Arduino IDE.
In my case I wanted to get temperature for certain city (Library - Yahoo - Weather - GetTemperature API :: Temboo) and now I can run code and view results in serial monitor (attached image). What I want to do next is to view temperature on my display but I don't know which part in the code is responsible for viewing value of temperature itself. Maybe I should create some variable in order to use it as an output for display?...
I'm pretty unfamiliar with programming so thank you for your help :slight_smile:

Hello! I work at Temboo.

Temboo returns Choreo result data to the Yún in a simple key-value format. Each name and value is followed by a newline character (\n), to increase readability, and a record-separator or field-separator hex character (\x1F to delimit names, and \x1E to delimit values).

In order to extract components of a Choreo's output, you'll need to read the key-value pair that you want from the output string. Complete details on how to read Choreo outputs on your Yún can be found here.

To store our temperature data, let's create a global variable of type int called "temp". For example:

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information, as described below

int temp;

Then, let's change the contents of the while(GetTemperatureChoreo.available()) loop to read each output item. This code snippet does the following: if that output item has the name "Temperature", then we assign the value of that item to the temp variable we created.

    while(GetTemperatureChoreo.available()) {
      // read the name of the next output item
      String name = GetTemperatureChoreo.readStringUntil('\x1F');
      name.trim(); // use “trim” to get rid of newlines

      // read the value of the next output item
      String data = GetTemperatureChoreo.readStringUntil('\x1E');
      data.trim(); // use “trim” to get rid of newlines

      if (name == "Temperature") {
        temp = data.toInt(); // convert the data from type String to type int
        Serial.println(temp);
      }
    }

Now you can do whatever you like with the temp variable.

If you have any questions, feel free to contact us at Contact | Temboo - we're always happy to help.

Best,
Caitlin

Thank you so much :slight_smile: It works fine...

One more question regarding to this issue...is it possible to convert the data from type String to type Char? Can I do it in similar way just like you did it in order to convert to type Int?