Google+

Monday, December 23, 2013

Controlling Raspberry Pi GPIO using Twitter Direct messages

Hi Readers ,

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.

download it here

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).

    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.

Saturday, November 16, 2013

Before Setting Up a New Raspberry Pi

In this blog I am going to discuss about the key points you want to consider before setting up your new Raspberry Pi for the first time use.

Targeted Audience:

             I am a newbie to the Pi. And I have just started experimenting with it. So this Post aimed at newbies like me who just have their Pi's on their hands.

Finding the things you need:

        Since Pi doesn't come with 'all batteries included'. I had to think and search a lot on the Internet before purchasing gadgets that make the Pi work. This blog is for easing off the head ache of other beginners of Pi like myself. Although you would find the official documentation for setting up a Pi,there are some other facts you have to care.

  1. Power Supply 5V,micro USB  port
  2. SD Card above Class 4,capacity >=4Gb
  3. Monitor with HDMI connectivity,or old TV monitor with RCA,USB keyboard,mouse(optional for headless setup


    1.Power Supply for the Raspberry Pi
              Before choosing a Power supply for your Pi, look for the specifications for it. Any high end mobile phone charger with micro usb port might well be serve as a power supply for your Pi,provided it can provide sufficient current.

    For a Model A Raspberry : choose a charger with current rating >= 800mA.Although the official documentation says,only 500mA is required :- it is for running the Pi alone.In the near future you will have to connect peripherals like keyboard,mouse,camera,USB flash drives etc... which also draws current from the power supply. So some extra current rating won't harm your Pi(But extra Voltage will!). And check the Volage provided by the charger before you connect it to Pi, it should be less than 5.25V(above may result in overcooked Pi) and greater than 4.75V(lesser will result in corruption in the SD card).

    For Model B Raspberry the current rating should be >= 1000mA.

    2.SD Card 

            Before buying a SD Card for your Raspberry Pi. Look not only at the specification but also look whether it is supported by your RPi. For that visit the following link whose data base is updated with the RPi users around the world,which list the working and non-working SD cards. I would recommend you to choose a SD card of class 6 or greater for good performance of the Pi. 

    3.Monitor for the Pi

           Actually I don't have a monitor for the Pi. But I found a solution for that : You can run your Pi headless(without its own monitor). You can your computer monitor,keyboard and mouse for accessing your Pi.This will be discussed in my upcoming blog posts.

    Doubts, feed backs if any are always welcomed. Thank you.:)



    Raspberry Pi

    What is a Raspberry Pi ?

     


          Raspberry Pi is an ARM based Credit Card sized Computer which runs Linux OS customized to run on the ARM process with ARM v6 instruction set.

          The main objective of the Founders of the Raspberry Pi is to provide a cheap computer affordable for new learners of computer programming(Though what you can think and make use of Raspberry Pi is unlimited).It is available as cheap as $25 for model A and $35 for model B. So even if you break it you won't be loosing much and the Pi gives most of the functionality of Personal Computer.

         Since it is cheap in cost it has the limitation on the computing power it can provide,hence don't expect it to match the performance of your PC(still it can match the computing power of iPhone 4S!).But it can provide of something that cannot be provided by your computer : The Hardware hacking .You can make your programs interact with the real world through the GPIO and various other ports on board.

    There are other boards out there in the market with better performances (like Beagle board)than Raspberry Pi,which use more powerful ARMv7 instruction set and more GPIO ports,but for beginners Raspberry Pi is what I will recommend owing to its cheap cost and a HUGE community it have to help you out.And add-on boards are available for the Raspberry Pi to extend its capability.


    To sum up whats a Raspberry Pi is :

    Raspberry Pi = Low Cost,Small size Computer + Development Board


    And from now on this blog is going to feature my experiments with Raspberry Pi(Hardware + Software) with the touch of Python of course.(In fact the founders of the Pi was actually trying to make a Development board which runs only Python...!!,Only after that they decided to make it capable of a full featured OS)

    Thanks to Svea & James xo of  lovers' Tif for making me  Raspberry Pi owner.:)

    Introduction

    Dear Reader,

                 I am an Electronics enthusiast just like you.I am also writing a blog on My Python Projects , which discuss my spare time programming on Python language.I love programming in Python as well.I always like to do some projects which involves both python and some hardware hacking,you know what? I just found the right tool for it a Raspberry Pi.

               Through this blog I like to share such projects,and I would appreciate your responses to this blog very much.

    Thank you. :)