This time I am going to share you about how I did use twitter direct messages to control the raspberry GPIO (actually you can control whatever you want by modifying the script).
Here is the list of things you need:
- Raspberry Pi with Internet connectivity
- A twitter account for your Raspberry pi
- Access token and secret keys of that account (will be explained later)
- wires,LED
And of course for sending direct message you must have a twitter account and you and your Pi must follow each other.I have chosen Direct message for controlling the Pi, though you can control using tweets mentioning the Pi (but DMs avoid spamming).
Step 1 : Create Twitter account for RPi , Create an Application API from https://dev.twitter.com/ .Obtain its API access credentials (do not disclose these to others)
Step 2 : Install tweepy (link has the installation instructions) and RPi.GPIO
(use sudo apt-get install RPi.GPIO from your Pi)
Step 3 : Put the API credential and Username of Pi and Account from which you wish to DM in my python script.
Step 4 : Connect LED to GPIO4 as shown in diagram.
Step 5 : Test it with instructions send through Direct Messages sent to your Pi's account.
This program also returns confirmation as a direct message back to you.The frequency with which the Pi checks for the new DMs are limited(here it is 4 mins.) due to regulation on API requests that can be sent to the Twitter account.So your Pi will respond to your DM command at the worst delay of 4 minutes.
As you can see, to turn on the LED DM "ON" to your Pi's account to turn off LED DM as "OFF"(without the quotes).
As you can see, to turn on the LED DM "ON" to your Pi's account to turn off LED DM as "OFF"(without the quotes).
This script can be modified for projects remote home automation, since u can access twitter anywhere in the world and the only thing you need is to your Pi be online.
So thats it, and as always feedbacks and questions are appreciated.