Software Development

Internet Of Things: Integrate Arduino With Yahoo! Using Temboo

Internet of things is the next big thing in the near feature. This technology is growing fast and there are many objects that begin talking each other using internet. Prototyping platforms like Arduino and Raspberry PI are supporting these innovations  and help many developers to create interesting IoT projects. One pillar of this emerging technology is the cloud IoT platforms that help developers to build Internet of things projects. One great platform, that is very useful, to build greatIoT project is Temboo . To explore the powerful features of Temboo, we will connect Arduino with Ethernet shield to Yahoo! Weather information, using this information Arduino controls an RGB led changing its color. In previous IoT project, we explored how external events, measured by sensors connected to Arduino, can trigger actions on Temboo platform, like sending messages and so on. In this project, it is used a different approach: data retrieved from an external source (like Yahoo! Weather) can control and have effects on Arduino connected devices.

Getting started with Arduino and RGB Led

Before digging into Temboo platform details, it is useful to create a simple Arduino sketch to control the RGB led. Arduino controls this led type using PWM (Pulse Width Modulation) so that it is possible to change the three basic color value (Red, Green, Blue).

The figure below shows the simple sketch:


The code is very simple: Arduino has some PWM pins that can be used for this purpose, in this sketch the PWM pins used are 3, 6, 5.

int delTime = 1000;
int redPin = 3;
int bluePin = 6;
int greenPin = 5;

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(greenPin, OUTPUT);

void loop() {

String val = "120";

Serial.print("Value " + val.toInt());
  analogWrite(redPin, 255);
  analogWrite(bluePin, 0);
  analogWrite(greenPin, 0);

Running the example, Arduino controls the RGB Led as shown below:

Yahoo! Wether details

If you are new to Yahoo! Weather, you have to know that to get weather information Yahoo uses Woeid. This is a unique identifier assigned to all cities, areas around the world. Using this parameter, it is possible to get weather information. As you will see later, Temboo requires Woeid so that it is necessary to convert the city name to woeid.

There are two different methods: one that uses Yahoo! API and another one much more simpler.

Yahoo! API : Woeid

This method requires you to create an account on Yahoo! and create a unique key. This can be done easily using Yahoo! developer site.

Once, the unique key is available we can get the woeid easily:'City_Name')?appid=your:key&format=json

The result is a JSON data like this:

            "placeTypeName attrs":{
            "country attrs":{
            "admin1 attrs":{
            "admin2 attrs":{
            "admin3 attrs":{
            "locality1 attrs":{
            "timezone attrs":{
               "type":"Fuso Orario",

The wooed (720187) is on the top so that it is enough to copy and paste this value.

Second method: Website

If you don’t want to waste your time using the method one and you are looking for a fast way to retrieve woeid, you can use this website:

Inserting the city name and clicking on lookup you will find as result the woeid list.

Integrate Arduino with Temboo

Temboo is a great platform that uses Choreos to expose services to Arduino or other dev platforms. To get Weather information we have to use Yahoo! Weather Choreos and thenGetTemperature. In this case, the project uses the Temperature to control the RGB Led, but you can use any other parameters.

Now everything is very simple, just paste the woeid you get before and click on run to get weather information.

In this example woeid is used but you can get the weather information using Address for example. Anyway i prefer woeid because it is much more simpler.

There are some other optional parameters you should consider like the Temperature unit and the response format:


Once you clicked run, you get the Arduino code that you have to copy and paste in your sketch. Arduino is ready to get weather information, if you run the example you get as result:

As you can see the source code is available to use in the sketch.

Control RGB Led using Temperature

Now that we have all the pieces in our hands we have to mix them to make things working.

The sketch with Temboo code, copied previously, has to be modified so that the result returned is used to change the RGB Led color.

Let’s slightly modify the code so that we get only the Temperature value:

String line;
    String lines[4];
    int counter = 0;
    while(GetTemperatureChoreo.available()) {
      char c =;
      if (c == '\r' || c == '\n') {
        Serial.println("Line ["+line+"]");
        lines[counter++] = line;
        line = "";
       line += c;
    String tempLine;
    // Clean line
    for (int i=1; i < lines[3].length(); i++) {
       tempLine += lines[3].charAt(i);

    int temp = tempLine.toInt();

Notice that there is the need to clean a bit the line before converting it to integer. Finally, you can implement your rules to covert the integer value to RGB color:

   // Now let's countrol the led
    int r = ( f1(temp, 20) * 5  ) % 255;
    int g = ( f1(temp, 10) * 5) % 255;
    int b = ( f2(temp, 5) * 5) % 255;

then add the RGB function to control the led:

void setRGBColor(int red, int green, int blue) {
  analogWrite(redPin, red);
  analogWrite(bluePin, blue);
  analogWrite(greenPin, green);

The functions f1,f2 are very simple:

int f1(int val, int threshold) {
   if (val < threshold)
    return 0;

  return val;

int f2(int val, int threshold) {
   if (val < threshold)
    return abs(val);

  return 0;

They are just a simple rules, of course you can change them as you prefer.

All done!!

In this Internet of things project we connected Arduino to Yahoo! Weather using Temboo chores. Arduino, with the information retrieved, controls RGB led.

What will you create using Temboo? Let me know…..

Francesco Azzola

He's a senior software engineer with more than 15 yrs old experience in JEE architecture. He's SCEA certified (Sun Certified Enterprise Architect), SCWCD, SCJP. He is an android enthusiast and he has worked for long time in the mobile development field.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button