I've been trying to get my arduino to tweet over wifi. I have the WiFly shield set up from sparkfun which is working, but I haven't been able to successfully send tweets over it. As far as I can tell, the twitter libraries (I've been looking at http://arduino-tweet.appspot.com/) are set up to work with the ethernet shield.
I haven't been able to port the library (code doesn't compile). I'm not entirely sure I'm up to porting the twitter library to work with the WiFly library unfortunately. I was wondering if any had done it at some point and maybe never shared it online.
Remove under two line in the your sketch and Twitter.h
-#include <Ethernet.h>
-#include <EthernetDNS.h>
and
in the Twitter.cpp, comment out below code.
DNSError err = EthernetDNS.resolveHostName(LIB_DOMAIN, server);
if (err != DNSSuccess) {
return false;
}
and you need to hardcode for "arduino-tweet.appspot.com"
-static uint8_t server[] = {0,0,0,0}; // IP address of LIB_DOMAIN
+static uint8_t server[] = {74,125,127,141}; // IP address of LIB_DOMAIN
#include <SPI.h>
#include <SC16IS750.h>
#include <WiFly.h>
#include "Credentials.h"
char token[] = "YOUR TOKEN HERE"; //@normbot
char msg[140];
char url[] = "arduino-tweet.appspot.com";
int hour = 3600000;
WiFlyClient client( url, 80 );
void setup() {
Serial.begin(9600);
SC16IS750.begin();
WiFly.setUart(&SC16IS750);
WiFly.begin();
if (WiFly.join(ssid, passphrase)) {
Serial.print("Associated with ");
Serial.println(ssid);
}
else {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
}
void loop() {
Serial.print("connecting to ");
Serial.println( url);
String starDate( millis());
String startOfMsg("Normbot Log: Stardate " + starDate);
String fullMsg( startOfMsg + ". Still no sign of WD40" );
for ( int i = 0; i < sizeof( msg ); i++ ) {
msg[i] = '\0';
}
fullMsg.toCharArray( msg, fullMsg.length() + 1 );
if (client.connect()) {
Serial.println("connected");
client.println("POST http://arduino-tweet.appspot.com/update HTTP/1.0");
client.print("Content-Length: ");
client.println(strlen(msg)+strlen(token)+14);
client.println();
client.print("token=");
client.print(token);
client.print("&status=");
client.println(msg);
}
else {
Serial.println("connection failed");
}
if ( client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
delay(600000);
}
It's not perfect - I cobbled the code together as a proof of concept. I will work on porting the Twitter library to WiFly when I get more time. The code above works though.