CuHead/Uno R3 and Twitter

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...

and this is the code I’m starting out with…

/*
 * 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);
}

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

And the problem is?

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

And the problem is?

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

Ditto.

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

Then the kid should be doing the work.

PaulS:

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

And the problem is?

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

And the problem is?

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

Ditto.

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.

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.

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…

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?

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

The question is too broad, sorry.

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.

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

[u]What I have Left to Figure Out[/u] 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?

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).

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.

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?

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.

@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.

Frederic_Plante:
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.

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.

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.

I was to curious so I got the Cuhead from Robotshop. Im supposed to get it by tuesday, cause monday is St-jean Batiste so no mail service.

I got to work with the library before buying it, got alot of bug, but it seam all good now.

So has soon i get the board, just cant wait, ill get on the problem also. It will be fun.

So talk to you about this nightmare on tuesday :)

Simple question @andersoncentral, did you went in the file apps-conf.h to configure it to your need?

Got my CuHead today, already done some stuf like lighting on and off a led on pin 4

Super cool device allready happy.

Startin to work on your thing, give you news soon hopefully :)

Ok

Use your SimpleClient.pde example,

Twitter IP can be found by doing:

Ping -t twitter.com on you run box. I really suggest to use the “-t” ption, other way’s it will ping 3 times and close the console without giving you time to note the ip

uint8 ip = {140,90,113,200}; ← replance by twitter IP(Make sure to use “,” séparator and not “.”)

GETrequest getWeather(ip, 80, “www.weather.gov”, “/data/METAR/KLAX.1.txt”); ← replace by

twitter.com” /search?q=%23 + the hashtag your looking for without the “#” ex: “bikehugger” + “&src=typd”

And of coarse it would look more pro if you replace “getWeather” by “getTweet” since it’s you who choose how the function will be called. If you do change the function name, you must make shure to replace the “getWeather” bu “getTweet” every where else in your programe. Use the find/replace, in the edit menu, to make sure you have replaced them all.

So it give out some thing like this:

GETrequest getTweet(ip, 80, “twitter.com”, “/search?q=%23bikehugger&src=typd”);

The rest will come out in the serial console. you can then do some text analyse

then the blinking is simple. you can simply use the example name blink without delay that come with the Arduino software.

Any more qustion just let me know :slight_smile:

I love my CuHead

I think i gave you a good head start. I dont want to spoil all the pleasur to find the awnser your self :slight_smile:

Oh! i forgot

you will put you text analise in this section:

void printData(char* data, int len) {

// Print the data returned by the server // Note that the data is not null-terminated, may be broken up into smaller packets, and // includes the HTTP header. while (len-- > 0) { Serial.print(*(data++)); } }

The varable to analyse is "data" simply.

It will need a if() { } you could also go with a for() { Blink;Delay;} it would be ok but i dont like delay, it's my style.

¸I say no more.