Twitter bots: automated programs that interact with a popular social network, often responding to hashtags and events based on predefined settings. For example, I could use a Twitter bot to track down mentions of my posts and retweet them.
But what if you have a Twitter bot running on hardware like the Raspberry Pi? This would enable real-world alerts and notifications from the copycat’s virtual Facebook microblogging; You can look at a physical count of the number of hashtag mentions, perhaps, or flash a few lights.
Users have found many ways to interact with Twitter using the Raspberry Pi. To get started, check out our very own Raspberry Pi Twitter bot project, then read about the following 10 projects to see how you can spin your own…
Tweet the status of your pi
When we came up with the idea of Twitter bot projects, our own expert James Bruce suggested using the Raspberry Pi to tweet hardware status (such as CPU temperature) and photos from the device’s webcam. (see link above).
It uses a custom Python application built with the Twitter API and uses the crontab command to schedule repeat tweets. We recommend that you take a look at this guide before moving on to the other projects listed here, as it will give you a good idea of the basics required to build a Twitter bot.
Simple retweet bot
One of the most important things you can do on Twitter is retweet. This may be to show your support for a cause, highlight your admiration for something, or promote a business venture. Whatever the reason, it can be a little distracting doing manual retweets all the time.
Luckily, there are various tools to help you automate the retweet process, not least creating a Raspberry Pi retweet bot that will do the job for you. With a simple Python script and the Twitter API, you can create a bot that retweets based on the hashtag of your choice.
Tweet your Speedtest results
If you need to convince yourself of the power and potential of a Twitter bot, take a look at this tweet:
The idea behind the bot, created by a Twitter bot programmed by Reddit user AlekseyP, is to determine the download speed of the Comcast network, of which he is a subscriber. When the downgrade rate drops below 50 Mbps (the user pays 150 Mbps down and 10 Mbps up), a tweet is sent.
The code is available on Pastebin. As AlekseyP points out, «I know some people might say that I shouldn’t complain about 50Mbps, but when they advertise 150 and I get 10-30, I’m not satisfied.» Interestingly, this approach seems to have worked.
“I set it up because I was frustrated with a period of constant drops and outages. Much better now. Previously, we couldn’t stream Netflix and I wouldn’t be able to connect to CSGO matches [Counter-Strike: Global Offensive] «.
Flash LED when you receive a direct message or retweet
Instead of tweeting and retweeting, how about using your Pi as a Twitter monitor that physically responds to triggers from other tweets? To do this, you will need a Raspberry Pi, a breadboard, a resistor, and an LED, as shown in this tutorial.
While projects earlier on this list used hashtags for selective retweeting, this project uses them to light up an LED. It’s fair to say that this isn’t the most imaginative use of a Raspberry Pi and some LEDs, but it’s really just the tip of the iceberg of what can be achieved by connecting a Raspberry Pi to Twitter. Other notification options could include playing a sound (perhaps even a car horn, as shown on the project page!), and this project is a good place to start if you have an aspiration to control a Pi-connected robot via Twitter.
Tweet my roar
Based on a standard dinosaur toy, this project is sort of a continuation of the previous one. However, instead of blinking, it uses Python code to detect @mentions of Boris the dinosaur’s dedicated Twitter account and make him roar in response.
This is well demonstrated in this video.