Arduino Yun & Temboo IoT

Hi Guys, I’m doing a project with Arduino Yun, connecting the weather information with Yahoo. I’ using Temboo, and I was trying to get Seoul’s weather information with Yahoo, and get the weather. I was trying to run the choreo when the weather code was 4.

This is the code that I copied from Temboo:

#include <Bridge.h>
#include <Temboo.h>
#include “TembooAccount.h” // Contains Temboo account information

// The number of times to trigger the action if the condition is met
// We limit this so you won’t use all of your Temboo calls while testing
int maxCalls = 10;

// The number of times this Choreo has been run so far in this sketch
int calls = 0;

int outputPin = 13;
int inputPin = 8;

void setup() {
Serial.begin(9600);

// For debugging, wait until the serial console is connected
delay(4000);
while(!Serial);
Bridge.begin();

// Initialize pins
pinMode(outputPin, OUTPUT);
pinMode(inputPin, INPUT);

Serial.println(“Setup complete.\n”);
}

void loop() {
int sensorValue = digitalRead(inputPin);
Serial.println("Sensor: " + String(sensorValue));

if (sensorValue == HIGH) {
if (calls < maxCalls) {
Serial.println("\nTriggered! Calling GetWeatherByAddress Choreo…");
runGetWeatherByAddress(sensorValue);
calls++;
} else {
Serial.println("\nTriggered! Skipping to save Temboo calls. Adjust maxCalls as required.");
}
}
delay(250);
}

void runGetWeatherByAddress(int sensorValue) {
TembooChoreo GetWeatherByAddressChoreo;

// Invoke the Temboo client
GetWeatherByAddressChoreo.begin();

// Set Temboo account credentials
GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY);

// Set Choreo inputs
GetWeatherByAddressChoreo.addInput(“Address”, “Seoul”);

// Identify the Choreo to run
GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress");

// Run the Choreo
unsigned int returnCode = GetWeatherByAddressChoreo.run();

// A return code of zero means everything worked
if (returnCode == 0) {
while (GetWeatherByAddressChoreo.available()) {
String name = GetWeatherByAddressChoreo.readStringUntil(’\x1F’);
name.trim();

String data = GetWeatherByAddressChoreo.readStringUntil(’\x1E’);
data.trim();

if (name == “ConditionCode”) {
if (data.toInt() == 32) {
digitalWrite(outputPin, HIGH);
}
}
}
}

GetWeatherByAddressChoreo.close();
}

When I tried to compile it, there was an error. It said that the part ‘runGetWeatherByAddress’ was undefined(;_;). I have no idea how to fix it.
Can you guys help me?
Thanks.

Hi, Hojin.

I work at Temboo. We tried compiling the code on the latest version of the Arduino IDE and it worked just fine. I would suggest making sure you are using the latest version of the official Arduino IDE.

If you continue to have issues, feel free to contact us from the email address associated with your Temboo account at Documentation | Temboo.

Best,
Caitlin

The code in code tags for anyone in the future:

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // Contains Temboo account information   

// The number of times to trigger the action if the condition is met
// We limit this so you won't use all of your Temboo calls while testing
int maxCalls = 10;

// The number of times this Choreo has been run so far in this sketch
int calls = 0;

int outputPin = 13;
int inputPin = 8;


void setup() {
  Serial.begin(9600);
 
  // For debugging, wait until the serial console is connected
  delay(4000);
  while(!Serial);
  Bridge.begin();
 
  // Initialize pins
  pinMode(outputPin, OUTPUT);
  pinMode(inputPin, INPUT);

  Serial.println("Setup complete.\n");
}

void loop() {
  int sensorValue = digitalRead(inputPin);
  Serial.println("Sensor: " + String(sensorValue));

  if (sensorValue == HIGH) {
    if (calls < maxCalls) {
      Serial.println("\nTriggered! Calling GetWeatherByAddress Choreo...");
      runGetWeatherByAddress(sensorValue);
      calls++;
    } else {
      Serial.println("\nTriggered! Skipping to save Temboo calls. Adjust maxCalls as required.");
    }
  }
  delay(250);
}

void runGetWeatherByAddress(int sensorValue) {
  TembooChoreo GetWeatherByAddressChoreo;

  // Invoke the Temboo client
  GetWeatherByAddressChoreo.begin();

  // Set Temboo account credentials
  GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
  GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
  GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY);

  // Set Choreo inputs
  GetWeatherByAddressChoreo.addInput("Address", "Seoul");

  // Identify the Choreo to run
  GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress");

  // Run the Choreo
  unsigned int returnCode = GetWeatherByAddressChoreo.run();

  // A return code of zero means everything worked
  if (returnCode == 0) {
    while (GetWeatherByAddressChoreo.available()) {
      String name = GetWeatherByAddressChoreo.readStringUntil('\x1F');
      name.trim();

      String data = GetWeatherByAddressChoreo.readStringUntil('\x1E');
      data.trim();

      if (name == "ConditionCode") {
        if (data.toInt() == 32) {
          digitalWrite(outputPin, HIGH);
        }
      }
    }
  }

  GetWeatherByAddressChoreo.close();
}

Are you contacting Temboo, or do you still want help here? If you do, then post the exact error message in code tags (the </> symbol in the Reply, not Quick Reply area). Also, just making sure, you just changed your account info here, correct? When you uploaded it, those were your account information, right?

Hi
I am trying to connect arduino with temboo and getting following error

Is there any solution for it ??

Initializing the bridge...OK
Creating table 'sensors' (if needed)...The creation string is: CREATE TABLE IF NOT EXISTS myarduino.sensors (cpu_time INT UNSIGNED, sensor_value INT);Error
(-c) missing choreo ID.
HTTP_CODE
000

Can you post your code? You should also probably start a new thread.