I did this project as part of my "documenting applications for Raspberry Pi" work as an Intern for Ensemble Tech. All code/work is not original and based on this work by Ahmad Khattab. I have learnt the "how- to" from his documentation of Buidling a doorbell and have implemented and documented the small part of tweeting the time. Check it out!
The first thing you have to do is create an app for the twitter API. Sounds scary, but it’s not. Just go to https://apps.twitter.com/ and log in with your twitter account id and password. Once logged in, hover over your avatar and click My Applications, then click Create a new Application
Then you’ll have to complete four fields in the form. Name, Description, website and callback URL. The last two don’t much matter for what we’re doing here. Then you have to tick the box agreeing to their terms and then complete the CAPTCHA. Then click Create Your Twitter Application.
It creates a “Read only” app by default. You can change that later if you want (by clicking the OAuth tab) but we’ll leave it as is for now because we only need read-only access for this program. Further down the page it looks like this.
Create Access Token. In order for your program to talk to twitter, it needs a way of authenticating. The system used is called OAuth, and it uses access tokens (codes). So you need to click the “Create My Access token” button…
…to make this happen. Soon after that, you should have an additional section at the bottom of the page (you might need to refresh the page (F5) to see it)…
Keep this page open. You will need to copy these codes into your program.
Install tweepy
Before you can use tweepy, you need to get it onto your Pi. Fortunately, it’s a Python extension, so easy to install.
sudo apt-get update updates Raspbian package lists
sudo apt-get install python-dev python-pip
Install pip and dev
(You may not need python-dev for pip and tweepy, but I installed it anyway.)
You could try to install tweepy and sometimes it fails. The reason appears to be an older version of pip in the Raspbian repo. You can get round this with…
sudo pip install -U pip
(this will uninstall pip and replace it with a version that works). …before you install tweepy. sudo pip install tweepy install tweepy itself You now have all you need to make your Python script talk to twitter.
PCF8574T Module | Raspberry Pi Pin |
---|---|
GND | Pin 6 (GND) |
Vcc | Pin 4(5V) |
SDA | Pin 3(SDA1) |
SCL | Pin 5(SCL1) |
Button | Raspberry Pi Pin |
---|---|
One end | Pin 13(GPIO 27) |
Other end | Pin 6(GND) |