Saath
Saath
Abstract— Using the inexpensive Raspberry Pi to automate Raspberry Pi. This automation system is capable of sensing
the tasks at home such as switching appliances on & off over Wi- the presence of a human being in the area of deployment so as
Fi (Wireless Fidelity) or LAN(Local Area Network) using a to turn on & off the necessary loads like lights and fans when
personal computer or a mobile or a tablet through the browser. it senses human presence. Its sense is overridden by using the
This can also be done by using the dedicated Android Android app or any browser to fit the needs of the user. A
application. The conventional switch boards will be added with a capacitive multi-touch screen can be added to the system
touch screen or replaced with a touch screen to match the taste of which will act as a touch switch board.
the user's home decor. PIR (Passive Infrared Sensor) sensor will
be used to detect human detection and automate the on and off
functionality. A. Hardware Components
The hardware components for this system essentially
Keywords— Raspberry Pi; Android Application; PIR sensor; comprises of the Raspberry Pi, PIR motion sensor, 4 channel
human detection; LAN; automate; touch screen photo coupled relay board for Raspberry Pi, 7” or 10”
capacitive multi-touch screen for Raspberry Pi and other
I. INTRODUCTION necessary components like power adapter, HDMI ( High-
Definition Multimedia Interface ) cable for the touch screen,
Modern days are the ones where we, the human beings Micro SD card, connecting wires etc.
exploit the technical knowhow at each level possible so as to
simplify and ease our lives. IoT and SoC are among such The Raspberry Pi being the heart of the project controls the
knowhow. The IoT (Internet of Things) is a group a devices above mentioned 4 channel relay which achieves the
connected over a network using cloud computing, web switching operation for us as per the output of the
applications and network communications in order to share corresponding GPIO pin to which it is connected to. The relay
information, store and retrieve data.[1] The SoC (System on board being photo coupled and having its own relay driver
Chip) is an electronic chip or an integrated circuit that has the integrated circuit like ULN2003A, makes it extremely safe to
whole computing system on it. This very innovation (SoC) has use with the very sensitive and low current output Raspberry
led to a tremendous drop in the production cost of computing Pi GPIO pins.
systems and in turn a much reduced cost for the end user for a
complete computing system. Such a system is the Raspberry A 7” or 10” capacitive multi-touch screen for Raspberry Pi
Pi. is used here to provide the feature of a digital touch enabled
switch board. This screen actually displays the beautifully
The Raspberry Pi is a very low cost small credit card sized designed buttons in the web page. This design is fully
computer (single board) developed in the United Kingdom by customizable and depends completely upon the user’s taste.
the Raspberry Pi Foundation. The price ranging from $20 to This hardware or feature of the project is optional as other
modes of controlling (through browser and Android
$35. Since its first release, the foundation has released application) are available.
several models with different hardware features. The latest one
being the Raspberry Pi - 3 released in February 2016 which The PIR motion sensor is used to sense the presence of
has on board Wi-Fi and Bluetooth. The Raspberry Pi 3 uses a human being as it detects the infra red rays emitted by the
Broadcom BCM2837 SoC with a 1.2 GHz 64-bit quad- core human body and processes it with it’s on board circuitry and
ARM Cortex-A53 processor, with 512 KB shared L2 cache, provides a high or low as an output indicating the presence of
1GB of RAM, providing a great thrust over its predecessor a human being or absence. This high and low output is used as
(Raspberry Pi – 2), about 80% faster in parallelized tasks.[2] a trigger to a predefined Python script on the Raspberry Pi
Equipped with 40 general purpose input output pins and web server which in turn performs a set of operations such as
consuming ultra low power of 800mA (4.0 W) it is very well switching certain GPIO pins of the Raspberry on or off thus
suited for various IoT projects and its usage is limited by turning the relay on or off.
imagination.
The Raspberry Pi being the heart of the project captures The relay when connected to any load such as a light or a
our attention a lot in this project of Intelligent Android fan or any load of such sort necessarily must be compatible
Application & Browser Controlled Appliances Using
B. Software Components
The project essentially comprises of the current version of
Raspberry Pi operating system, the Raspbian Jessie, (version
May 2016), Flask (version 0.11), Python 3, HTML and CSS.
Raspbian Jessie is the official operating system for the
Raspberry Pi based on Debian Linux. It is extremely user
friendly and the GUI is awesome though we have very little or
nothing to do with the GUI of the OS. We may use the OS
headless after deploying the project. The Raspberry Pi and all
other mentioned components except the display is exactly Figure 1: Functional Block Diagram of the System
what we need. From the very beginning of the project itself we
may go headless and SSH(Secure Shell) into our Raspberry Pi
to configure it as per our project specifications.
With the Micro SD card having loaded with the Raspbian
Jessie image in it, we need to first assign a static IP(Internet
Flask is a web framework for Python which we can use to Protocol) to our Raspberry Pi so that it always remains same
create website using Python. The best thing is Flask is BSD as we will be using this IP as the URL to the website for the
licensed.[4] interface to switch the lights on and off. This static IP
assignment can be done in two ways.
Python is one of the most widely used high-level, general-
purpose, interpreted, object oriented, dynamic programming Firstly, we can configure a static IP in the router it is
language created by Guido van Rossum. It’s power, connected to. Secondly, we can change the configuration file
simplicity, flexibility & robustness is incredible. Whatever of the Raspberry Pi to assign it a static IP. Whatever way it is,
way you praise the mighty Python it’s less! Our project uses it has to have a static IP else it would be very taxing later on to
Python 3 all along. find its IP and visit the webpage. Over that, the Android app
would be assigned the static IP while building, so we don’t
Python provides a module named the RPi.GPIO which is want it to change later on. Once the static IP is set, we go
dedicated to control the GPIO on a Raspberry Pi. Current headless and simply SSH into the Raspberry Pi.
version of RPi.GPIO available is 0.6.2.[3] This module does
the trick for us. We simply import the module in our Python
A. Installing flask
script and create the magic in the project’s codes.
Installing Flask is too simple; it’s just a matter of one line
HTML (Hypertext Markup Language) is the standard command. Issuing the following command completes the
markup language used for creating web pages. Each HTML Flask installation.
document has a set of tags that describe the structure of the
page along with the contents. Along with HTML, CSS sudo apt-get install python3-flask
(Cascading Style Sheets) is used to describe the way the
contents are presented. The CSS is the element that adds the
beauty to the web page. CSS is optional in our case it is just To check if working properly post successful installation,
for a pleasant feeling to our eyes while using the website or we create a very simple ‘Hello IEMCON’ app. We create a
the application. new folder and name it as IEMCON. Inside IEMCON folder
we now create a new Python file and name it as hello.py and
write the following code inside this hello.py file.
B. The Final Project Implementation
hello.py In this project we are using four GPIO pins of the
Raspberry Pi for each room. We are configuring the system
from flask import Flask for two rooms. In total we will be using 4+4 = 8 GPIO pins for
app=Flask( name ) output purposes and two GPIO pins for two PIR sensor for
@app.route(‘/’) two rooms. The input GPIO pins for Room 1 are pin #17, #27,
def index(): #22 & #23 and for Room 2 the pins are pin #5, #6, #13 & #19.
return ‘Hello IEMCON’ We name our final project app as IEMCON_PI. So we
if __name == “ main ”: create a new folder with same name i.e. IEMCON_PI. Inside
app.run(host=’0.0.0.0’, debug=True) IEMCON_PI we create two more folders with names
‘templates” and “static”.
Now to run the recently created Hello IEMCON app we The “templates” folder will contain the html files which
change our present working directory to the IEMCON will serve as a blue-print for the output of our app i.e. the User
decretory where the hello.py file is present and issue the Interface. The “static” folder will contain the CSS file and the
following command. pictures used in the User Interface. All python scripts will be
present in the IEMCON_PI folder.
sudo python3 hello.py
Since we need the User Interface for two rooms, we copy
Upon issuing the above command we get the following in the IEMCON_PI folder and paste it in the same directory with
the terminal representing the running state of the Hello a new name, IEMCON. So, now we have two apps for each of
IEMCON app. the two rooms.
We will be using single Raspberry Pi for both the rooms.
We simply assign the python files of the two rooms different
port numbers as shown in the code snippet below.
.
.
.
if name == "__main__":
app.run(host='0.0.0.0', port=5000, debug=True)