Go Down

Topic: CuHead/Uno R3 and Twitter (Read 1 time) previous topic - next topic

andersoncentral

I'm hoping someone can help an Arduino brother out. I have an Uno R3 I've been playing around with. I've added the CuHead WiFi shield (that everyone loves so much) and got the static web page up and running on it. Now I'm looking to use the Uno/CuHead combo to log onto Twitter and light up a green LED when a specific Twitter user posts a tweet and/or light up the green LED when a specific # is used.

I'm a total hack when it comes to this stuff and I've been searching for anything to help me accomplish the above task by using what others have done but I need some guidance. Specifically, I need help with the correct libraries and code. Someone with patience for a person learning would be much appreciated as I get my fair share of abuse from my wife for blowing off as much time as I do with this stuff...

thanks in advance

btw... this is for a science project for my kid...

andersoncentral

and this is the code I'm starting out with...

Code: [Select]
/*
* A simple sketch that uses WiServer to send a tweet with the current system time every 5 minutes
*/

#include <WiServer.h>

#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {XXX,XXX,X,XX}; // IP address of WiShield
unsigned char gateway_ip[] = {XXX,XXX,X,X}; // router or gateway IP address
unsigned char subnet_mask[] = {XXX,XXX,XXX,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"network name"}; // max 32 bytes

unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"password"}; // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


// Auth string for the Twitter account
char* auth = "@twittername:password"; // Base64 encoded USERNAME:PASSWORD


// This function generates a message with the current system time
void currentTime() {
   WiServer.print("Arduino has been running for ");
   WiServer.printTime(millis());
}

// A request that sends a Tweet using the currentTime function
TWEETrequest sentMyTweet(auth, currentTime);


void setup() {
    // Initialize WiServer (we'll pass NULL for the page serving function since we don't need to serve web pages)
  WiServer.init(NULL);
 
  // Enable Serial output and ask WiServer to generate log messages (optional)
  Serial.begin(57600);
  WiServer.enableVerboseMode(true);
}


// Time (in millis) when the next tweet should be sent
long tweetTime = 100;

void loop(){

  // Check if it's time to sent a tweet
  if (millis() >= tweetTime) {
    sentMyTweet.submit();   
    // Send next tweet 5 minutes from now
    tweetTime += 1000 * 60 * 5;
  }
 
  // Run WiServer
  WiServer.server_task();

  delay(10);
}

PaulS

Quote
Now I'm looking to use the Uno/CuHead combo to log onto Twitter

And the problem is?

Quote
and light up a green LED when a specific Twitter user posts a tweet

And the problem is?

Quote
and/or light up the green LED when a specific # is used.

Ditto.

Quote
btw... this is for a science project for my kid...

Then the kid should be doing the work.

andersoncentral


Quote
Now I'm looking to use the Uno/CuHead combo to log onto Twitter

And the problem is?

Quote
and light up a green LED when a specific Twitter user posts a tweet

And the problem is?

Quote
and/or light up the green LED when a specific # is used.

Ditto.

Quote
btw... this is for a science project for my kid...

Then the kid should be doing the work.




Really?? What I wrote before was... "Specifically, I need help with the correct libraries and code. Someone with patience for a person learning would be much appreciated as I get my fair share of abuse from my wife for blowing off as much time as I do with this stuff..."

BTW, my kid is 7 and he and I are learning together. I figured we would try this forum for help, not "sarcasm"... If you're not going to attempt to be helpful, why reply? Now I will need to explain to my 7-year old the concept of trolling on the internet. I'm trying to teach him how to use a forum to solve a problem.


PaulS

Quote
BTW, my kid is 7 and he and I are learning together.

Programming an Arduino to talk to twitter, etc. is far beyond the skills of 99.999% of all 7 year olds. You are not doing him, or his fellow students, any favors by having him submit a project that he clearly didn't (and couldn't) complete on his own.

andersoncentral

thank you once again PaulS for being less than helpful... I don't need an internet lecture on how to approach a Father/Son science fair project at his school. The point is for us both to see the elements of what we're trying to accomplish and see how the code makes this happen.

It might be best if you just ignore this request for help... you're not capable it appears. Good job you...

Nick Gammon

Putting that aside for the moment (perhaps you will motivate him to become really enthusiastic about electronics) your (first) post does not really indicate your problem.

How to use this forum

What happens, compared to what you expect to happen?

Quote
Specifically, I need help with the correct libraries and code.


The question is too broad, sorry.
http://www.gammon.com.au/electronics

andersoncentral

Here's what I want the Arduino to do...

~Connect to a Wifi network
~Query Twitter for the hashtag "#bikehugger"
~Blink an LED 10 times
~Repeat

I'm looking for those that have actually done this project.

What I've Figured Out So Far
I have the correct code for connecting to a network using my CueShield and I have the ability to set the LED to blink.

What I have Left to Figure Out
How to query Twitter for a hashtag
Send a result back to the Arduino
Print to or run the LED loop

Asking questions of people I have no problem with... systematically, debating sentences and intent, I do have a problem with...

so... 1. Has anyone done what I describe?    and 2. Would they be willing to share their sketch or experience?

Nick Gammon

A quick Google search revealed this:


http://forum.arduino.cc/index.php?topic=93480.0

Broad questions like "how do I get an Arduino to work with Twitter?" can usually throw up a lot of hits (over 900,000 in this case).
http://www.gammon.com.au/electronics

andersoncentral

ok... thanks Nick... That gets me closer to see that someone approached this. I'll show my son that sketch tonight to see if he can identify which parts of it we can use and which parts we have to omit.

Frédéric_Plante

#10
Jun 14, 2013, 04:13 pm Last Edit: Jun 14, 2013, 05:11 pm by Frederic_Plante Reason: 1
If I may,

It as no relevance with the project what so ever, but it's common for some people to have this crappy attidude. Probably because there jealous cause they have no point in life.

I'm 100% in favor that a parent push there kid to do uncommon stuff, since childhood is a period when the brain is very plastic(flexible) and learning to programme is some thing that is painful to do at an older age, just like learning a second or third language.

I say Bravo! to you for going thru a process that is much harder for you then it is for your kid, you are showing a good example.

I say don't get influence by those people who probably did not have the chance to have good parents whom were willing to give some of there time to the benefit of there child

Keep up the good work.

Finally I have a question, I was considering buying a CuHead, do you think i should?? So far are you satisfy?
As we fight our way northward into the great unknown, only that one thing remains certain...

Frédéric_Plante

#11
Jun 14, 2013, 05:20 pm Last Edit: Jun 15, 2013, 05:17 pm by Frederic_Plante Reason: 1
And to Pauls

I dont think that doing:

~Connect to a Wifi network
~Query Twitter for the hashtag "#bikehugger"
~Blink an LED 10 times
~Repeat

Would be a full science project on it's own. I believe the Man want to give a minimum to his kid, then let him go with his own project.

I sure hope you are not a teacher cause i would be afraid to let you teach anything to my kids.

I let you think about this, have a good life.
As we fight our way northward into the great unknown, only that one thing remains certain...

TM

@andersoncentral

If you are using "search.twitter", like me, than you might get into problems as Twitter spotted it on the 11th of June. You have now to use api.twitter.com/1.1/search, register your app, and do an auth. It's a bit more complicated as you need to submit two keys to get a token that you will include in your queries to the API.

I am starting to adapt my php test to arduino. Will post the results if I'm successful. 

andersoncentral


Finally I have a question, I was considering buying a CuHead, do you think i should?? So far are you satisfy?


Thanks Frederic... we've made some progress and when we're done I'll post the specs and details

I'm about 60% happy with the CuHead. There just isn't much documentation from the manufacturer on it for setup, etc. Once I found someone else who had successfully got it up and working as a server, the rest came easier. It cost me about half of what the regular Wifi shield costs so I guess I got what I paid for... lol.

andersoncentral


@andersoncentral

If you are using "search.twitter", like me, than you might get into problems as Twitter spotted it on the 11th of June. You have now to use api.twitter.com/1.1/search, register your app, and do an auth. It's a bit more complicated as you need to submit two keys to get a token that you will include in your queries to the API.

I am starting to adapt my php test to arduino. Will post the results if I'm successful. 



cool... thanks for the heads up. We did hit this roadblock... We're getting closer to it working and I'll post our work when we're done.

Go Up