Thursday, May 15, 2014

Home automaton - RPI - Software Needs - Post 3

Story board
Post 1 - Synopsys
Post 2 - Hwardware Requirements

Status: Just yesterday (14th May 2014), I completed this project and it is working liker a charm :) ... #feeling_achieved

Software design: 
Idea is to control the electrical switch (Relay) from anywhere.. So, we need to softwares in 2 parts

  1. One which triggers relay from Raspberry Pi
  2. The other which manages the web part of it. 

Software program in Raspberry Pi
One of most fascinating features of Pi board is that it has got GPIO (General Purpose Input Output) pins. We have got GPIO libraries, that can be imported into programs to work with GPIO pins in a very easy fashion. Most common programming language used in RPi is Python. The same is used in my project as well. 

Setting up GPIO pins and passing the commands to them. 
As the name suggests, we can set GPIO pins either as input or outputs. For our case we need to set one pin as Output pin. Following code snippet would do that

import RPi.GPIO as  GPIO
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(22,GPIO.OUT)

Above code initializes GPIO pins and sets pin #22 to Output mode.
Below pic can be used as a reference to GPIO pin layout. Note that the numbers are not in any sequence :) 



















To set a digital HIGH or digital LOW following code would help

GPIO.output(22, False)
GPIO.output(22, True)

The GPIO pin 22, 8th in the left side will be connected to Relay input pin as shown in my previous post.

Now logic can be written when to turn on relay or turn it off...
More on Software related to web control in next post

No comments: