Yun, Temboo, Twitter problem

Hi All,

I am having a massive problem with a Temboo Read-a-Tweet sketch.

It was generated on the Temboo website with a modification to examine the read tweet and respond basied on keywords, in this instance #white. #green or #blue.

The sketch attached below works fine. Until I add an additional libary in order to add additional functions biased on the said keywords. Then strange things happen.

If I add the wire libary so I can use an I2C interface with:-  #include <Wire.h>

Then I get an error:-
Running ReadATweet - Run #1
Error
A Step Error has occurred: "An input error has occurred. AccessToken, AccessTokenSecret, ConsumerKey, and ConsumerSecret are required. I
n addition, ScreenName or UserID must be specified.".  The error occurred in the Stop (Input error) step.
HTTP_CODE
500
Waiting...

Different libarys that I have added have casued differnet error, but most errors still work to some degree or other:-

~~~~~~~Error when adding softwareSerial.h
Running ReadATweet - Run #1
@ -
No suitable hashtag found in tweet
Waiting...


~~~~~~~Error when adding Servo.h
Running ReadATweet - Run #1
@ - More tests.
#white
Would set colour to white
Waiting...


~~~~~~~No Error when adding SPI.h
Running ReadATweet - Run #1
@cyber_seal - More tests.
#white
Would set colour to white
Waiting...

~~~~~~~No error when adding Stepper.h
Running ReadATweet - Run #1
@cyber_seal - More tests.
#white
Would set colour to white
Waiting...

I can not figure out if it is an error with Temboo, the Yun, twitter.

The kiker being the ONLY change to the code is to 'include' the libary, I've not actually tried to implement the libary. So all that should have done is change the size of the sketch, but the compiler indicated no errors and no size problems.

I have recently repeated the experiments with the NEW Yun image, which made no difference.

I have had a scan though past posts and can not see any similar problems..

Any pointer sappreciated.

Thanks

Liam







code]
/*
  ReadATweet

  Demonstrates retrieving the most recent Tweet from a user's home timeline
  using the Temboo Arduino Yun SDK.
 
  This example code is in the public domain.
*/

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
#include "TwitterAccount.h" // contains Twitter account information

int numRuns = 1;   // execution count, so this doesn't run forever
int maxRuns = 10;   // the max number of times the Twitter HomeTimeline Choreo should run


void colour_white() {
    Serial.println("Would set colour to white");
   
}

void colour_green() {
    Serial.println("Would set colour to green");
   
}

void colour_blue() {
    Serial.println("Would set colour to blue");
   
}



void setup() {
  Serial.begin(9600);
 
  // For debugging, wait until a serial console is connected.
  delay(4000);
  while(!Serial);
  Bridge.begin();
}

void loop()
{
  // while we haven't reached the max number of runs...
  if (numRuns <= maxRuns) {
    Serial.println("Running ReadATweet - Run #" + String(numRuns++));
   
    TembooChoreo TimelineChoreo;

    // invoke the Temboo client.
    // NOTE that the client must be reinvoked, and repopulated with
    // appropriate arguments, each time its run() method is called.
    TimelineChoreo.begin();
   
    // set Temboo account credentials
    TimelineChoreo.setAccountName(TEMBOO_ACCOUNT);
    TimelineChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    TimelineChoreo.setAppKey(TEMBOO_APP_KEY);

    // tell the Temboo client which Choreo to run
    TimelineChoreo.setChoreo("/Library/Twitter/Timelines/UserTimeline");
   
   
    // set the required choreo inputsc
    // see https://www.temboo.com/library/Library/Twitter/
    // for complete details about the inputs for this Choreo

    TimelineChoreo.addInput("Count", "1"); // the max number of Tweets to return from each request
    TimelineChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
    TimelineChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
    TimelineChoreo.addInput("ConsumerKey", TWITTER_API_KEY);   
    TimelineChoreo.addInput("ConsumerSecret", TWITTER_API_SECRET);

    TimelineChoreo.addInput("ScreenName", "cyber_seal");

    // next, we'll define two output filters that let us specify the
    // elements of the response from Twitter that we want to receive.
    // see the examples at http://www.temboo.com/arduino
    // for more on using output filters
  
    // we want the text of the tweet
    TimelineChoreo.addOutputFilter("tweet", "/[1]/text", "Response");
   
    // and the name of the author
    TimelineChoreo.addOutputFilter("author", "/[1]/user/screen_name", "Response");


    // tell the Process to run and wait for the results. The
    // return code will tell us whether the Temboo client
    // was able to send our request to the Temboo servers
    unsigned int returnCode = TimelineChoreo.run();
   
   // a response code of 0 means success; print the API response
    if(returnCode == 0) {
     
      String author; // a String to hold the tweet author's name
      String tweet; // a String to hold the text of the tweet


      // choreo outputs are returned as key/value pairs, delimited with
      // newlines and record/field terminator characters, for example:
      // Name1\n\x1F
      // Value1\n\x1E
      // Name2\n\x1F
      // Value2\n\x1E     
     
      // see the examples at http://www.temboo.com/arduino for more details
      // we can read this format into separate variables, as follows:
     
      while(TimelineChoreo.available()) {
        // read the name of the output item
        String name = TimelineChoreo.readStringUntil('\x1F');
        name.trim();

        // read the value of the output item
        String data = TimelineChoreo.readStringUntil('\x1E');
        data.trim();

        // assign the value to the appropriate String
        if (name == "tweet") {
          tweet = data;
        } else if (name == "author") {
          author = data;
        }
      }
    
      Serial.println("@" + author + " - " + tweet);
     
      if (tweet.indexOf("#white") >= 0) {
          colour_white();
      } else if (tweet.indexOf("#green") >= 0) {
          colour_green();
      } else if (tweet.indexOf("#blue") >= 0) {
          colour_blue();
      } else {
          Serial.println("No suitable hashtag found in tweet");
      }
   
    } else {
      // there was an error
      // print the raw output from the choreo
      while(TimelineChoreo.available()) {
        char c = TimelineChoreo.read();
        Serial.print(c);
      }
    }

    TimelineChoreo.close();

  }

  Serial.println("Waiting...");
  delay(60000); // wait 10 seconds between Timeline calls
}

Hi All,

I have just had a responce from the Temboo people suggesting it is a memory issue, 'Overflowing'.

I will read though their responce, but I don't understand twhy the compiler didn't report a memory issue.

Is this making sence to people?

Liam

The compiler used by the IDE warns you about memory statically allocated, like when you say String s = "hello world"
It cannot warn you about dynamic memory allocation. Using external services obliges you to dynamic allocate memory: if you allocate too much of it, you may run out of it

Hi,
try to allocate the String object into flash, by wrapping them with F().
ie:

Serial.println(F("Would set colour to blue"));

and also

TimelineChoreo.addInput(F("AccessToken"), TWITTER_ACCESS_TOKEN);

and so on.

Hi All,

Ok. Makes sence and a small step up the learning curve for me. I have never experianced memory issues yet.

One question I have is, are the ' // ' flagged lines which denote comments actually compiled in to the final code or are they stripped out, from the compiled code passed to the arduino? Would stipping them out save space.

Also would my sytax for varible labelling make a difference to mememory allocation. For example would

a1 = 2

take less memory than

Answer1 = 2

Pertinant when the 5 extra characters can be repeated dozens of time throughout the programme.

Temboo are suggesting placing settings files on the other side of the bridge and possibly on an SD card. I will explore that option as well.

Bit of a kicker as Temboo is promoted as a super easy thing to use... I missed my build date, but atleast I know I was on a lame hourse, and I'll learn a bit going forward. Useful for the future.

Thanks for your thoughts.

Liam

VideoLiam:
...
I have just had a responce from the Temboo people suggesting it is a memory issue, 'Overflowing'.
...

You mind share the response?

VideoLiam:
One question I have is, are the ' // ' flagged lines which denote comments actually compiled in to the final code or are they stripped out, from the compiled code passed to the arduino?

No, of course they are not compiled into code, they are just that, "comments" for the programmer

Would stipping them out save space.

No.

Also would my sytax for varible labelling make a difference to mememory allocation. For example would

a1 = 2

take less memory than

Answer1 = 2

Again no. Those variables are only readable in that form in the text of the source code of your script.

Pertinant when the 5 extra characters can be repeated dozens of time throughout the programme.

Come again? :~

Ralf

Plan B:

http://forum.arduino.cc/index.php?topic=239380.msg1719783#msg1719783