Pages: [1]   Go Down
Author Topic: I2C (wire) devices and Temboo Twitter Choreos - SOLVED  (Read 929 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everyone!

I've made a sketch to send a tweet and read mentions to me with the temboo api and I would like to use the
wire library so that I can activate e led matrix when I receive a tweet for example.
But If I include the wire.h lib then I always get an error when trying to send a tweet.  Everything compiles ok but the
temboo StatusUpdateChoreo seems to have some trouble when I iclude the Wire.h library.
When I comment the iclusion line // include <Wire.h>   then everything works ok again...
I use a nightly build of the 1.5.4 beta on my Arduino Yun.

the error returned is:
A Step Error has occurred: "An input error has occurred. ConsumerKey, ConsumerSecret, AccessToken, AccessTokenSecret, and StatusUpdate are required.".  The error occurred in the Stop (Input error) step



Anyone experiencing the same problem??

kind regards,
Philippe
« Last Edit: October 21, 2013, 03:28:21 pm by PB7781 » Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it seems it is not the library itself, after hours of testing, I've found out that something with the adafruit ledbackpack library must be wrong, everytime I even declare the matrix, then I get this strange error from the choreo.

I am now trying with the LiquidCrystal_I2C.h lib and also that doesn't work, there must be something strange when using I2C libs in combination with Temboo, I have used the bridge lib in combination with I2C devices and that is no problem at all, so there must be a conflict somewhere between the temboo twitter choreos and someting with the I2C part???
anyone, any idea??????


greetings!
Philippe
« Last Edit: October 15, 2013, 04:14:39 pm by PB7781 » Logged

Offline Offline
Edison Member
*
Karma: 38
Posts: 1233
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Uhm that sounds strange as TembooChoreo is just an extension of Process
Can you post your wiring and sketch?
Logged

Have you upgraded the Yún? If you've just got it, then it needs to be upgraded! Check out the tutorial

Offline Offline
Edison Member
*
Karma: 38
Posts: 1233
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have run your sketch https://gist.github.com/ffissore/cd046750f16a9c308360 and successfully published a tweet
https://twitter.com/fridrik/status/390780735789228033
It also started printing mentions
Logged

Have you upgraded the Yún? If you've just got it, then it needs to be upgraded! Check out the tutorial

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes but that's my point, the sketch WILL run but...

ONLY when NOT using any I2C device, try using a IIC (I2C) lcd display or a led matrix (adafruit or something)
and in the loop part, try to put something on the display or the led matrix,
just try to use the same sketch (that runs fine WITHOUT IIC devices) AND use a IIC device with it,
I am very very curious if it will work in that case!
Because the only thing I do is (uncomment the lcd related lines in my sketch) and it stops working ...
I still can not find out why but I assure you that when I do find it I will share it immediately with this forum

kind regards,
Philippe
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe I am on the right path to finding out how to get these things working, and
now I can send a tweet and put a smiley on my adafruit 8x8 bicolor matrix, BUT when I try
to use the temboo thing twice then it doesn't work, if I want to send a tweet AND get the mentions
then I get errors, there must be something I am doing wrong with the Temboo library but I don't know what
for the time being.


/*
  SendATweet

  Demonstrates sending a tweet via a Twitter account using Temboo from an Arduino Yun.

  Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino

  A Temboo account and application key are necessary to run all Temboo examples.
  If you don't already have one, you can register for a free Temboo account at
  http://www.temboo.com

  In order to run this sketch, you'll need to register an application using
  the Twitter dev Serial at https://dev.twitter.com. Note that since this
  sketch creates a new tweet, your application will need to be configured with
  read+write permissions. After creating the app, you'll find OAuth credentials
  for that application under the "OAuth Tool" tab. Substitute these values for
  the placeholders below.

  This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
  to the Internet.

  Want to use another social API with your Arduino Yun? We've got Facebook,
  Google+, Instagram, Tumblr and more in our Library!
 
  This example code is in the public domain.
*/


#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
static const uint8_t PROGMEM
  smile_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10100101,
    B10011001,
    B01000010,
    B00111100 },
  neutral_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10111101,
    B10000001,
    B01000010,
    B00111100 },
  frown_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10011001,
    B10100101,
    B01000010,
    B00111100 };

#include <Bridge.h>
#include <Serial.h>
#include <Temboo.h>
#include "TembooAccount.h"

// om te debuggen
#define dothisthing 0   // activate show mentions part
#define dothatthing 1   // activate send a tweet tomboo part

void setup() {

  matrix.begin(0x71);
  matrix.clear(); 
  matrix.writeDisplay();
 
  Bridge.begin();
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Yun is ready and awaiting your command! ");

}

const String TWITTER_ACCESS_TOKEN = "blablablabla";
const String TWITTER_ACCESS_TOKEN_SECRET = "blablablabla";
const String TWITTER_CONSUMER_KEY = "blablablabla";
const String TWITTER_CONSUMER_SECRET = "blablablabla";


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

String tweetje="";
String command;
char karakter;


void loop()
{


    if (dothatthing) { 
          // only try to send the tweet if we haven't already sent it successfully
          if (numRuns <= maxRuns) {
         
                while (Serial.available()<=0) {};   
                command ="";   
                karakter = Serial.read();
                while (karakter != '\n') {
                  command += karakter;
                  karakter = Serial.read();
                } //while loop
               
              // define the text of the tweet we want to send
             
              tweetje = "@XHQRTS Device Tweeting (";
              tweetje += command;
              tweetje += ")";
              Serial.println("now sending tweettext:  ");
              Serial.println(tweetje);
              numRuns++;
              String tweetText(tweetje);
             
              // TembooChoreo MyChoreoInstance;
         
              // invoke the Temboo client
              // NOTE that the client must be reinvoked, and repopulated with
              // appropriate arguments, each time its run() method is called.
              TembooChoreo MyChoreoInstance;
     
              MyChoreoInstance.begin();
             
              // set Temboo account credentials
              MyChoreoInstance.setAccountName(TEMBOO_ACCOUNT);
              MyChoreoInstance.setAppKeyName(TEMBOO_APP_KEY_NAME);
              MyChoreoInstance.setAppKey(TEMBOO_APP_KEY);
              // identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
              MyChoreoInstance.setChoreo("/Library/Twitter/Tweets/StatusesUpdate");
         
              // set the required choreo inputs
              // see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
              // for complete details about the inputs for this Choreo
           
              // add the Twitter account information
              MyChoreoInstance.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
              MyChoreoInstance.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
              MyChoreoInstance.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);   
              MyChoreoInstance.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET);
              MyChoreoInstance.addInput("StatusUpdate", tweetText);

              // for debugging
              Serial.print("following text will be tweeted >> ");
              Serial.println(tweetText);
                 
         
              // tell the Process to run and wait for the results. The
              // return code (returnCode) will tell us whether the Temboo client
              // was able to send our request to the Temboo servers
              unsigned int returnCode = MyChoreoInstance.run();
         
              // a return code of zero (0) means everything worked
              if (returnCode == 0) {
                  Serial.println("Success! Tweet sent!");
                  matrix.clear();
                  matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_GREEN);
                  matrix.writeDisplay();
                  delay(500);
                  } else
                     {
                      // a non-zero return code means there was an error
                      // read and print the error message
                      matrix.clear();
                      matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_RED);
                      matrix.writeDisplay();
                      delay(500);
         
                      while (MyChoreoInstance.available()) {
                        char c = MyChoreoInstance.read();
                        Serial.print(c);
                      } // while loop
                     } // else           
              MyChoreoInstance.close(); 
          } // number of runs   
    }

   if (dothisthing) {   
           
        if (numRuns <= maxRuns) {
          // now show the mentions...
          Serial.println("showing mentions ");
          // invoke the Temboo client
          // NOTE that the client must be reinvoked, and repopulated with
          // appropriate arguments, each time its run() method is called.
          TembooChoreo MyMentionChoreoInstance;
         
          MyMentionChoreoInstance.begin();
         
          // set Temboo account credentials
          MyMentionChoreoInstance.setAccountName(TEMBOO_ACCOUNT);
          MyMentionChoreoInstance.setAppKeyName(TEMBOO_APP_KEY_NAME);
          MyMentionChoreoInstance.setAppKey(TEMBOO_APP_KEY);
         
          // identify the Temboo Library choreo to run (Twitter > Tweets > Mentions)
          MyMentionChoreoInstance.setChoreo("/Library/Twitter/Timelines/Mentions");
         
          // add the Twitter account information
          MyMentionChoreoInstance.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
          MyMentionChoreoInstance.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
          MyMentionChoreoInstance.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);   
          MyMentionChoreoInstance.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET);
          MyMentionChoreoInstance.addInput("Count", String(2)); // only show two
 
     
         
          MyMentionChoreoInstance.run();
          // set the required choreo inputs
          // see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
          // for complete details about the inputs for this Choreo
       
     
          Serial.println("after executing MENTIONS Choreo.");
     
          while(MyMentionChoreoInstance.available()) {
            char c = MyMentionChoreoInstance.read();
           
            // process JSON
            if (c=='[') Serial.println("    ");
            if (c=='{') Serial.println("   ");
            if (c==']') Serial.println("");
            if (c=='}') Serial.println("");
            if (c==':') Serial.println("  ");         
           
            Serial.print(c);
            }
            MyMentionChoreoInstance.close(); 
         numRuns++;   
         }       
   }
}




kind regards and thanx to Frederico Fissore for those quick replies!

Philippe

* Temboothing and IIC devices.txt (8.43 KB - downloaded 17 times.)
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got an email from the Temboo team today, explaining that the ATmel in the Yun is very limited in ram size
and indeed, I used lots of libraries like the wire lib, the adafruit gfx and ledbackpack AND I did lots of printing to the
console and I'm afraid I just ate to much ram, so the Yun reacts strange and sometimes the sketch worked and sometimes
it didn't, I must say I didn't even think about the memory limits on the Yun but now that I am aware of this I can take it into account so I removed the adafruit libs and just use a tinkerkit led to do something and it works perfectly now.

So, the advice is, watch your ram when developing for the Yun, it is important!
I knew the days of the TRS80 so I should have been aware of it :-) but these days with the luxury of gigabytes everywhere
one tends to just forget these things...

kind regards and many thanks to the Temboo team!
Philippe
Logged

Pages: [1]   Go Up
Jump to: