A list of methods for reading tweets from Twitter that don’t work.

I’ve tried several different methods for reading tweets now. I may currently be onto a winner and if it works by gum will it be documented to save others the hassle. This post however, is basically a list of things that don’t work since Twitter changed to API 1.1 and implemented OAuth 2.0, which will hopefully save some people time.

Method 1: Twitter libraries for Arduino.

There are two Twitter libraries that I know of for the Arduino. The library listed on Arduino.cc and the Markku Rossi twitter library. Neither of these have methods for retrieving tweets.

Method 2: Hook the Arduino up to Processing via Firmata and use the Twitter4j library.

I was sold the Twitter4j library was going to be the solution. One of the biggest problems anyone trying to check Twitter from the Arduino seems to have is memory. Using Processing on say a Raspberry Pi and then communicating with the Ardino would solve this. Setting up Twitter4j and Processing is a bit weird, Processing has some very strict conventions about how it reads libraries so a few file names and folders have to be changed. There are some very good examples with Twitter and Processing on the Carnegie Mellon University website. Using these I was able to tweet when a button was pressed on the Arduino. Sadly the examples for checking for tweets use an older version of the Twitter4j library and trying to use them I had authentication errors, I suspect from Twitters overzealous implementation of OAuth 2.0. There is still some hope for resolving this but I abandoned it for the moment as I thought stumbling upon method 3 I had found the solution…

UPDATE: This method works! Copypasta from here is getting results.

Method 3: Back to the Arduino, this time Frankenstein-ing Adafruit code.

So I discovered this example of using tweets to control an RGB LED. After a little Googling I also found the code used on the Arduino website. Using a Twitter API endpoint this searches tweets and then parses the returned JSON files. I converted it to work with the Ethernet Shield and was able to successfully reach the endpoint. I just couldn’t get any results from it. Eventually I realised this was actually still using the 1.0 API, but as it is said in the video the actual Twitter part of the code is taken from an Adafruit library for their Internet of Things printer so I went searching for this hoping it had been updated to work with the current 1.1 version of Twitters API. It had! Sadly, an issue was raised two months ago that it had stopped working. This sadly coincides with Twitter changing it’s API again so it can only be queried via https, which as far as I can tell the ethernet shield is incapable of handling. Sadly here ended any real hope I had that this project could be implemented solely on Arduino. Good thing I got Processing working on the Pi!

Additionally…

Method 4: The Arduino Yún.

The Arduino Yún is an Arduino made specifically for Internet of Things type applications. It’s a bit of a beast, alongside the micro-controller is a separate processor which runs a Linux distribution. I’m 98% sure if you wanted to use this for Twitter you could. I’m not sure if the https only scuppers the WiFi as it does the Ethernet shield but there are separate libraries from Temboo to handle things like Twitter timelines.  It’s just a shame you’d have to spend ~£55 on a new board to be able to use it.