- Category: Raspberry Pi
- Last Updated on Monday, 01 July 2013 16:09
If you have not read it already, please first refer to the Pi-Lite Users Guide.
Pi-LITE Twitter Display
The Pi Lite is a Raspberry Pi plug-in board sporting a large LED matrix display for scrolling text and doing graphics. You can display all sorts of data and graphics and in this example we show you how to scroll your tweets in real time across the display.
You won't need to code anything, but you will need to follow some simple steps to make sure it all works well.Here is a summary of the steps we will take you through:
- Set up your Pi to work with Ciseco hardware and the Pi-Lite examples
- Arrange for access to your Twitter account, keeping your Twitter account safe
- Authenticate your Pi-Lite Twitter app, making sure only your app can have access to your twitter feed
- Run the example and have fun showing it to your friends!
We will take you through each of these steps now. Please be sure to follow the steps carefully. It is always best to do it right first time as correcting mistakes can be confusing and error prone. You may wish to read through the whole document before you actually start following each step. It is always better to know where you going than blindly following your guide.
We have prepared a separate guide that sets up your Raspberry Pi to work with all our examples. Please carefully follow the steps in this document. They will help you
- Set up your Pi to work with Ciseco hardware
- Install the Git version control system, so you can download the Python libraries we keep on github for you.
- Download the Pi-Lite libraries, code we have written for you.
You need to allow applications such as the Pi-Lite Twitter app you just built access to your Twitter feed. Twitter has an API that allows developers access to the feed. It is protected by authentication and security keys. These need to be set up, so that access to your Twitter feed remains secure. Here is what to do:
In a browser navigate to http://dev.twitter.com an and log in using your normal username and password.
Select My Applications
Click on “Create a new application”
Give it a name, description and website (any web site will do here).
Leave the callback URL blank.
Read the rules of the road and check the “Yes, I agree” box.
Enter the captcha and press “Create your Twittter Application”.
You will see a screen that contains a Consumer Key and a Consumer Secret. You need to copy both of these for use in a resource file we will create later.
Press the button to create an access token.
You also need to copy the Access token Key and the Access token Secret
We are going to create a resource file that has the various keys and secrets that we have got from the Twitter web site in the previous step.
In your home directory, copy the skeleton .tweetrc file we provide
$ cd ~
$ cp git/PiLite/Python-Examples/twitter/sampletweet.rc ~/.tweetrc
Note the dot in front of tweetrc (all resource files start with a dot).
Then edit this file, using nano or your favourite editor:
$ nano .tweetrc
Paste in your consumer key, consumer secret, access token key and access token secret into the indicated places
Your .tweetrc file should now look something like this – with the key and secrets that you obtained from dev.twitter.com
[Tweet] consumer_key: dadkalAsfsadfkafl2aD consumer_secret: dadkalAsfsadfkafl2aD access_key: dadkalAsfsadfkafl2aD access_secret: dadkalAsfsadfkafl2aD
Save the .tweetrc file (in nano this is done with control-X, Y <enter>)
You have done all the hard work and you are ready to run the Twitter app:
$ cd ~/git/PiLite/Python_Examples
$ python PiLiteTwitter.py
Send yourself some tweets and see them scroll over the PiLite.