Enginursday: Monitor Twitter With a Raspberry Pi


If you were at Endgadget Expand in November (or perhaps follow the engineers on Twitter), you might have seen SparkFun’s booth. If you saw SparkFun’s booth, you might have seen an interesting display with several racing honey badgers. We affectionately named this “The Great American Tweet Race,” which you can follow on Twitter. The race is down right now, so there will not be much activity on Twitter. However, you can view the outcome of all the races from Endgadget Expand on its Twitter page.

The Great American Tweet Race

In The Great American Tweet Race, we used a Raspberry Pi to monitor the Twitterverse for Tweets containing specific hashtags. As each hashtag would appear, the honey badger corresponding to that hashtag would incrementally move along its track. The first honey badger to the end of the track would be declared the winner (unsurprisingly, the honey badger still did not care).

Several SparkFun engineers contributed to the creation of The Great American Tweet Race, and I was in charge of creating a Python script to monitor Twitter for specific hashtags. Whenever a Tweet appeared containing a hashtag of interest, the Python script displayed the Tweet on the monitor and made a call to some C code running in the background, which handled moving the honey badgers (calling C from Python is another topic for another day).

If you have ever been curious about how to connect to Twitter to monitor, search, and post Tweets, I created a tutorial to help you get started, which you can view here: https://learn.sparkfun.com/tutorials/raspberry-pi-twitter-monitor

Twitter LED

A Raspberry Pi used as a Twitter monitor

Granted, this simply blinks an LED whenever a Tweet appears with a specific hashtag, but think of all the possibilities! You would be well on your way to creating your own Twitter Race!

What fun projects have you seen or created using Twitter? Something that posts to Twitter? Or maybe something that searches Tweets?


Comments 13 comments

  • Programming on the Raspberry Pi is always really fun :)

    I’ve made something pretty simmilar at the beginning of this year. It’s written on python I called it “rpitwit”, it monitors your twitter account for a keyworkd and executes a command stored on a pre-defined directory.

    https://pypi.python.org/pypi/rpitwit/0.2.0

    The funny thing is that it comes pre-configured, ready to use and you can use python or bash scripts. The funny thing is that I wrote it for work with the Raspberry Pi but later I realized that it works on any Linux distribution with Python and PiPy :) I hope that you find it useful.

  • I’m in the middle of a similar project using a Pi to remotely monitor an aquaponics system. I’m using a waterproof DS18B20 and an AtlasScientific pH sensor to collect the data. I then tweet the data every hour so it can be checked any time, any place with a smartphone.

    I’m still prototyping, so it’s just tweeting the temperature of my basement right now. In the spring it will get hooked up to the system. By that time I hope to also have it logging data to a database and capable of displaying basic graphs on the local netwrok. We will also probably include some additional components like water flow and soil moisture sensors, and maybe some solenoid valves. It’s an evolving idea.

    • Cool! I would love to see photos when you have it all set up. Would you be willing to share the Twitter handle so we could follow your project’s data?

      • @salem_ponics

        Like I said, it’s just spitting out the temperature every hour right now. I just ordered the pH sensor from you guys today, so I hope to have it hooked up next week or the week after. I’ll probably shut it down in January to solder everything together and then we will get it installed onsite.

  • Why use a Raspberry Pi and not an Arduino? SFE in the past had many thing monitoring Twitter using the ethernet shield and an Arduino.

    (This is just my curiosity since I know there are more than 1 way to do this).

    • Like you said - more than one way to do it. Flashing an LED is really pretty simple, and it could easily be done with an Arduino. Python opens up the world of easy-to-use string manipulations, which really shines on the Pi. The tutorial is just a getting started.

      On the Twitter Race, we had to use a Pi because we needed the processing power. Even then, the poor Pi couldn’t keep up with the flood of Tweets.

      • The arduino yün also support python on the linux side. You can also install php on it.

        • You can also install php on it.

          Although you will then have only yourself to blame if you wind up using PHP.

          (I kid, I kid.)

          • Of course, you must choice wathever languaje fit better in your proyect. But it’s always good to have options.

            In my case, I use C for a fast embeded project, but i will use C++ for a more robust project. In a PC enviroment, I preffer C# / VB.NET.

            In the web world, I preffer ruby, but most of my previous proyects were PHP based.

            In the arduino.cc/yun forum, many of the topic are php / sqlite related. There a lot of PHP fans out there…

            • In the arduino.cc/yun forum, many of the topic are php / sqlite related. There a lot of PHP fans out there…

              Yes indeed. We’re pretty much doing ok running SparkFun on it, though we grouse a fair bit from time to time.

              I should play around with serving PHP apps off a Raspberry Pi one of these days. Might be sort of perversely amusing to teach a class on the theme…

        • Good to know. I haven’t actually played with a Yun yet.

    • This could certainly be done with an Arduino + Ethernet Shield, but the RPi is a much cheaper solution.


This Week

This Month

Heartbleed

Happy Arduino Day!

SXSW Create 2014