Modified Twitter Library for the Arduino WiFi Shield

Hey all,

I’m not sure if this has been done before but I’ve been doing some work with the newly-released Arduino WiFi shield; it doesn’t have much user-generated content available for it at this time. I needed to get the Arduino to tweet over WiFi as a part of my project, and didn’t want to bother getting into OAuth, so I did a simple modification of the Twitter Library already present for the Ethernet Shield to port it over. Hope it helps someone out.


  1. Install the Arduino Twitter Library at
  2. Overwrite the Twitter.h and Twitter.cpp files within the newly installed library with the attached files.
  3. Enjoy.

Note that at this rudimentary stage this will make your twitter library no longer compatible with the Ethernet Shield. To restore, just re-install.

Sample code to tweet, note you will still need to grab a token as was needed with the original library.

 #include <SPI.h> // needed in Arduino 0019 or later
#include <WiFi.h>
#include <Twitter.h>

char ssid[] = "Network Name";
char pass[] = "Secret Password"; 

// Your Token to Tweet (get it from
Twitter twitter("Your Token Here!");

// Message to post
char msg[] = "Automatic tweet!";

void setup()
  WiFi.begin(ssid, pass);
  // or you can use DHCP for automatic IP address configuration.
  // WiFi.begin(mac);
  Serial.println("connecting ...");
  if ( {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
    } else {
      Serial.print("failed : code ");
  } else {
    Serial.println("connection failed.");

void loop()

Twitter.h (520 Bytes)

Twitter.cpp (1.59 KB)

Just want to say thanks for posting this. Just used it and it worked great!

Has anyone used this with the WiFLY Shield from Sparkfun? Just curious.


I’ve changed the header names to Twitter_WiFi.h and Twitter_WiFi.cpp (The files are attached.)
So you can choose to include either one of them depending on whether you’re using the Ethernet or WiFi module.
Hope this makes things easier and neater.

Bryan (3.83 KB)

Thanks, I think that works out a lot better.

edit: added a github link, for anyone who wants to continue working on this snippet of code

/libraries/Twitter/Twitter.h:35: error: 'EthernetClient' does not name a type

I get this error ;S Why?