You are on page 1of 63

Home Automation System using Raspberry PI

2014-15

CHAPTER 1

INTRODUCTION
1.1 Overview
The Internet of Things (IoT) can be described as connecting everyday objects like
smart-phones, Internet TVs, sensors and actuators to the Internet where the devices are
intelligently linked together enabling new forms of communication between things and
people, and between things themselves. Building IoT has advanced significantly in the last
couple of years since it has added a new dimension to the world of information and
communication technologies.
The Internet has come a long way over the last 30 years. Old-fashioned IPv4 is giving
way to IPv6 so that every device on the Internet can have its own IP address. Machine-tomachine (M2M) communication is on the rise, enabling devices to exchange and act upon
information without a person ever being involved. The scope and scale of the Internet have
changed as well: industry leaders predict that the number of connected devices will surpass
15 billion nodes by 2015 and reach over 50 billion by 2020. The challenge for the embedded
industry is to unlock the value of this growing interconnected web of devices, often referred
to as the Internet of Things (IoT), describing it as the ultimate tool in our future surveillance.

Dept. of CSE, PESCE, Mandya

Page 1

Home Automation System using Raspberry PI

2014-15

Fig 1.1: Internet of Things

Fig 1.1 shows the environment of Internet of Things. Potentialities offered by the
IoT make possible the development of a huge number of applications, of which only a
very small part is currently available to our society. Many are the domains and the
environments in which new applications would likely improve the quality of our lives: at
home, while travelling, when sick, at work, when jogging and at the gym, just to cite a
few. These environments are now equipped with objects with only primitive intelligence,
most of times without any communication capabilities. Giving these objects the
possibility to communicate with each other and to elaborate the information perceived
from the surroundings imply having different environments where a very wide range of
applications can be deployed. These can be grouped into the following domains:
otiaprnsT
n ad oglistc ndm.a
Healthcr ndom.i
Smart enviromt (home, ofce, plant) ndom.ai
oPnersal d social ndm.
At the edge of the IoT are the appliances and equipment we use every day. These
things are interconnected across an infrastructure or backbone using combinations of
ZigBee, sub-GHz, Wi-Fi or power line communications (PLC) connectivity to provide a
robust bi-directional communications link with relatively long range, low latency for fast
responsiveness, low power and a sufficient data rate to aggregate information from many
connected devices. This infrastructure also serves as the gateway to the Internet and enables
remote monitoring and control of devices by other networks, utility companies and end users.
Home automation or Smart Homes can be described as introduction of technology
within the home environment to provide convenience, comfort, security and energy
efficiency to its occupants. Adding intelligence to home environment can provide increased

Dept. of CSE, PESCE, Mandya

Page 2

Home Automation System using Raspberry PI

2014-15

quality of life. With the introduction of the Internet of Things (IoT), the research and
implementation of home automation are getting more popular.

Problem statement
The objective of our system is to take care of several domestic systems that may

normally be difficult for those who are handicap or elderly to take care of. The proposed idea
will allow a user with any android enabled device to run a piece of downloadable software on
any mobile device such as a smartphones. This application will allow the user to control a
device that is connected to any home appliance that is Pi enabled. The focus of this
application will be to direct a security system with webcam surveillance, door sensor
notification and a light control system. Sensors will be connected to the home appliances
with Pi so that they can be monitored and controlled. Suppose an employee who has gone to
work and during this period a thief sneaks up into the house breaking through a window.
The proposed system would enable the client to monitor home when a door or a
window sensor triggers the alarm. Client monitors home with webcam and could
immediately inform local authority or a policeman. The Client could also check the status of
the outside light and turn on and off the light without the need to get out of bed. These
devices would also benefit users with limited mobility that may have a difficult time getting
to or even reaching their light switch. These objectives require a large amount of technology.
The user interface must be as simple and powerful as possible and operate in a self-organized
way.

Solution
Innovative designs were produced wherein a Magnetic Door Sensors, a Microsoft

LifeCam webcam and LEDs could interact with Raspberry Pi with help of an Android
Smartphone. These applications rely on the use of smartphones, microprocessors and
magnetic door sensors to collect signals through a wireless network to provide users with a
Dept. of CSE, PESCE, Mandya

Page 3

Home Automation System using Raspberry PI

2014-15

simple interface to interact with appliances in the home. The smartphone enables the user to
control the appliances using pre-existing devices such as their mobile phone. The interfaces
are intuitive and easy to use and provide the user with a more accessible interface than those
found in the home. The devices are also very easy to integrate into existing applications and
require only a small amount of expertise to install.

OBJECTIVES

The following lists of objectives must be completed with this in mind:

Raspberry Pi: A microprocessor will interface with the android module to perform
the automation. A simple microprocessor will receive signals from the smartphone

and it will be processed.


Develop Software Interface Mobile Device: An android application to be developed
using the ADT (Android Developer Tools) java platform for programs running on

mobile devices that communicates between pi and home devices easily.


Integrate the Sensors to a Device: The Raspberry Pi needs to be integrated with the
lighting, door sensors and webcam control systems at a low cost with easy

installation.
Conduct Experiments and Analyse Data: Using the mobile device and the
appliance controller, conduct tests on usability and product range for a home
environment.

1.5

Existing system
Most commercially available home automation systems are all-in-one solutions which

require that all controllable appliances are from the same company, or must be approved as
compatible with said companys system. Moreover these systems normally come with a
proprietary, dedicated device which acts as the control center. To control the system from
multiple locations, additional control devices must be purchased. These complex systems
usually need to be integrated when the building is constructed and must be planned in
advance. They are also difficult to upgrade or replace once installed. The overall investment
adds up considerably and is financially infeasible in most cases. These drawbacks hinder the
popularity of such systems.
Dept. of CSE, PESCE, Mandya

Page 4

Home Automation System using Raspberry PI

1.6

2014-15

Proposed system
Every user who is experienced in the existing system may think of a system that may

add more flexibility and run with some common applications such as android. The proposed
system is designed in such a way to avoid the limitations of the existing system. The
proposed system supports more flexibility, comfort ability and security. This home
automation system is working with very popular android phones. It is having mainly three
components; the android enabled user device, a Wi-Fi router having good scalable range and
a raspberry pi board. Here the users have provision to control the home appliances through
android enabled device. This will improve the system popularity since there is no need for a
wired connection, internet etc. The instructions from the user will be transmitted through the
Wi-Fi network. The raspberry pi board is configured according to the home system and it will
enable the relay circuit as per user request. The relay circuit can control the home appliances
also. We can add appliances to the system which will boost additional security features.
Advantages of Proposed system
The new system will provide the following features
It allows more flexibility through android device.
It allows a good range of scalability.
It provides security and authentication.
Additional vendors can be easily added.

Dept. of CSE, PESCE, Mandya

Page 5

Home Automation System using Raspberry PI

2014-15

CHAPTER 2

LITERATURE SURVEY
2.1 Survey papers
1. 1Sarthak Jain, 2Anant Vaibhav [1] Proposed That Home automation is becoming more and
more popular day by day due to its numerous advantages. This can be achieved by local
networking or by remote control. This paper aims at designing a basic home automation
application on Raspberry Pi through reading the subject of

E-mail and the algorithm for

the same has been developed in python environment which is the default programming
environment provided by Raspberry Pi. Results show the efficient implementation of
proposed algorithm for home automation. Here LEDs were used to indicate the switching
action.
The popularity of network enabled home automation has been increasing greatly in recent
years due to simplicity and much higher affordability. Introduction of technology within the
home to enhance the quality of life of its occupants, through the provision of different
services such as tele health, multimedia entertainment and energy conservation. This paper
presents a basic application of Raspberry Pi in home automation control through internet (Email) where subject of the received e-mail is read by the developed algorithm fed into
raspberry Pi and system responds to the corresponding instructions. The presented system in
this paper is interactive, efficient and flexible according to the consumer needs. It
immediately replies the status of work done by raspberry Pi to the consumer.

Dept. of CSE, PESCE, Mandya

Page 6

Home Automation System using Raspberry PI

2014-15

2. 1Nausheen Belim, 2Harshada Bhambure, 3Priyanka Kumbhar, 4Simranjit Tuteja [2]


proposed the design of an automation system that uses switch and get to know status of the
home appliances by using computer and Zigbee wireless technology. Zigbee is a new
technology, whose goal is to eliminate wired connections between electrical appliances and
computer. Instead of connecting with wires, every electrical appliance has small Zigbee. The
home appliances are connected to the ports of the microcontroller board and their status are
passed to the home server. The combination of NetBeans and EmbeddedC is used for
monitoring and controlling software.

The home Appliances can be monitored and accessed remotely by user via SMS or EMAIL
where GSM Modem comes into use. Multi-vendor appliances can be added to the system
with no major changes and hence system is scalable. Password protection is one of the
functionality of the system so that unauthorized user can be denied from accessing home
appliances. Another important feature is the security system that will continuously monitor
the status of home appliances and take adequate actions if required. The system will carry out
the goal of modernized home integration system of automation control and management,
house burglarproof and security and remotely control the household electric appliances
through internet. The basic target of intellectual home automation system is to provide people
a comfortable, safe, convenient and high efficient life environment and a humanistic service.
3. 1Dr. S. Kanaga suba raja, 2C. Viswanathan, 3Dr. D. Sivakumar, 4M. vivekanandan [3]
proposed the system that deals with the design and implementation of Secure Home
Automation using Raspberry Pi for mobile devices that leverage mobile technology to
provide essential security to homes and associated control operations. The proposed home
security solution hinges on novel integration of cameras and motion detectors into web
application. Raspberry Pi operates and controls motion detectors and video cameras for
remote sensing and surveillance, streams live video and records it for future playback, and
finally manages operations on home appliances, such as turning ON/OFF a television or
microwave. For instance, when motion is detected, the cameras automatically initiate

Dept. of CSE, PESCE, Mandya

Page 7

Home Automation System using Raspberry PI

2014-15

recording operation and the Raspberry Pi device alerts the homeowner of the possible
intrusion.
This paper looks into the development of an ANDROID application which interprets the
message a mobile device receives on possible intrusion and subsequently a reply SMS which
triggers an alarm/buzzer in the remote house making others aware of the possible intrusion.
With the widespread diffusion of mobile devices and their integration with new autoidentification technologies, the need to control and manage the smart home through these
devices is increasing. In this context, the main goal of this work is to develop and validate an
architecture, both hardware and software, able to monitor and manage a KNX based home
automation system through an Android mobile device in an efficient and safe way.
4. 1Ali Ziya Alkar [4] proposed that home automation is to control home devices from a
central control point. In this paper, the author has presented the design and implementation of
a low cost but yet flexible and secure internet based home automation system. The
communication between the devices is wireless. The protocol between the units in the design
is enhanced to be suitable for most of the appliances. The system is designed to be low cost
and flexible with the increasing variety of devices to be controlled.
The control of the devices when completely taken over by the machines, the process of
monitoring and reporting becomes more important. The power for simple but routine tasks
while we need to maintain as much control as we can over the automated processes.
Automation lowers the human judgment to the lowest degree possible but does not
completely eliminate it. This paper suggests a framework of the communication protocol
between the devices to be used in home automation. To be used in this framework they
proposed a novel communication protocol to control devices with more than just the
switching functionality. The designed system will be open to expansion and will enable
control of different types of devices. The system is designed to be low cost however at the
same time more flexible alternative with respect to similar systems.
5. 1R.A.Ramlee [5] proposed the overall design of Home Automation System (HAS) with
low cost and wireless remote control. This system is designed to assist and provide support in
order to fulfill the needs of elderly and disabled in home. Also, the smart home concept in the
Dept. of CSE, PESCE, Mandya

Page 8

Home Automation System using Raspberry PI

2014-15

system improves the standard living at home. The main control system implements wireless
Bluetooth technology to provide remote access from PC/laptop or smart phone. The design
remains the existing electrical switches and provides more safety control on the switches
with low voltage activating method. The switches status is synchronized in all the control
system whereby every user interface indicates the real time existing switches status. The
system intended to control electrical appliances and devices in house with relatively low cost
design, user-friendly interface and ease of installation.
In order to improve the standard living in home, this system provides three different types of
physical control methods to the Main Control Board. The first physical control method is by
pressing on the modified Low Voltage Activating Switches. The conventional high voltages
switches will be replaced by the modified 5 Volt push buttons as the activating switches. The
low voltage switch eliminates the risk of dangerous electrical shock by wet hand. The second
and third control methods are performed as wireless remote control to the appliances. The
second control method is by clicking on Window GUI on PC/laptop by using mouse or touch
pad. This method provides facility to the computer user to control the home appliances
without walk to the switches on the wall. Third control method is done by Android GUI
installed in Smart Phone. The user can easily touch on the screen of the phone to control the
home appliances. This portable method is able to assist the disabled people who have
problem with locomotion difficulty.
6. 1Ali Ziya Alkar [6] proposed that Smart Home is an emerging technology growing
continuously which includes number of new technologies which helps to improve humans
quality of living. This paper proposes an adaptive home system for optimum utilization of
power, through Artificial Intelligence and Wireless Sensor network. Artificial Intelligence is a
technology for developing adaptive system that can perceive the environment, learn from the
environment and can make decision using Rule based system. Zigbee is a wireless sensor
network used to efficiently deliver solution for an energy management and efficiency for
adaptive home. An algorithm used in adaptive home system is based on software agent
approach that reduce the energy consumption at home by considering the users occupancy,
temperature and users preferences as input to the system.
A Smart Home refers to a home with intelligent to control, monitoring and automate the
home system. The Intelligent System proposed is based on the rule-based expert system and
Dept. of CSE, PESCE, Mandya

Page 9

Home Automation System using Raspberry PI

2014-15

unsupervised learning techniques where the problem is how to adapt to new knowledge
without destroying the existing knowledge. The core controller unit is equipped with
distributed sensors i.e., intelligent agents, which use the rule-based expert system and
artificial intelligence concepts to learn and adapt. The proposed system in this paper enables
the comfort zone adjustment, i.e., the control of heating/cooling of individual rooms and/or
of the entire house; and is capable of processing inputs to and from the EGU Utility/Smart
Meter to the core controller unit. The goal of the Adaptive Learning System is to adapt to the
occupants pattern and schedule changes by providing comfort, while not ignoring the energy
conservation aspect.
7. 1Raveendra.k [7] proposed simple, low cost, low power consumption and an energy
efficient image capturing novel method for implementing the intruder security using ZigBee
(802.15.4) standard and also a security protocol for detecting and localizing identity based
attacks in the system. It consists of PIR sensor node, cmos camera deployed in the location as
well as the doors/ windows of the shopping malls, railway station together with the ZigBee
modules which act as end devices that monitor continuously and send the security status of
each location to the coordinator node connected to a PC which acts as the master. It
sends/informs over sms to the concerned department in case of most wanted person
detection. The software has been implemented using Embedded and application program for
image authentication using Mat lab.
8. 1Rajeev Piyare [8] proposed a low cost and flexible home control and monitoring system
using an embedded micro-web server, with IP connectivity for accessing and controlling
devices and appliances remotely using Android based Smart phone app. The proposed system
does not require a dedicated server PC with respect to similar systems and offers a novel
communication protocol to monitor and control the home environment with more than just
the switching functionality. To demonstrate the feasibility and effectiveness of this system,
devices such as light switches, power plug, temperature sensor and current sensor have been
integrated with the proposed home control system.
A low cost and flexible home control and monitoring system using an embedded micro-web
server, with IP connectivity for accessing and controlling devices and appliances remotely
using Android based Smart phone app. The proposed system does not require a dedicated
Dept. of CSE, PESCE, Mandya

Page 10

Home Automation System using Raspberry PI

2014-15

server PC with respect to similar systems and offers a novel communication protocol to
monitor and control the home environment with more than just the switching functionality.
The author have utilized RESTful based Web services as an interoperable application layer
that can be directly integrated into other application domains like e-health care services,
utility, distribution, or even vehicular area networks.
9. 1Armando Roy Delgado, 2Rich Picking and 3Vic Grout [9] proposed remote controlled
operation of home automation systems. It considers problems with their implementation,
discusses possible solutions through various network technologies and indicates how to
optimize the use of such systems. The home is an eternal, heterogeneous, distributed
computing environment (Greaves, 2002) which certainly requires a careful study before
developing any suitable Home Automation System (HAS) that will accomplish its
requirements. Nevertheless the latest attempts at introducing Home Automation Systems in
actual homes for all kinds of users are starting to be successful thanks to the continuous
standardization process that is lowering the prices and making devices more useful and easier
to use for the end user. Even so several important issues are always to be handled strictly
before developing and installing a Home Automation System; factors like security, reliability,
usefulness, robustness and price are critical to determine if the final product will accomplish
the expected requirements.
10. 1Y.Usha Devi [10] proposed that Home Automation industry is growing rapidly; this is
fuelled by provide supporting systems for the elderly and the disabled, especially those who
live alone. Coupled with this, the world population is confirmed to be getting older. Home
automation systems must comply with the household standards and convenience of usage.
This paper details the overall design of a wireless home automation system (WHAS) which
has been built and implemented. The automation centers on recognition of voice commands
and uses low-power RF ZigBee wireless communication modules which are relatively cheap.
The home automation system is intended to control all lights and electrical appliances in a
home or office using voice commands. The system has been tested and verified. The
verification tests included voice recognition response test, indoor ZigBee communication
test. The tests involved a mix of 10 male and female subjects with different Indian languages.
Dept. of CSE, PESCE, Mandya

Page 11

Home Automation System using Raspberry PI

2014-15

7 different voice commands were sent by each person. Thus the test involved sending a total
of 70 commands and 80.05% of these commands were recognized correctly.
The Wireless Home Automation System (WHAS) is an integrated system to facilitate elderly
and disabled people with an easy-to-use home automation system that can be fully operated
based on speech commands. The system is constructed in a way that is easy to install,
configure, run, and maintain. The speech recognition system is a completely assembled and
easy to use programmable speech recognition circuit. Programmable, in the sense that you
train the words (or vocal utterances) you want the circuit to recognize. This board allows you
to experiment with many facets of speech recognition technology. It has 8 bit data out which
can be interfaced with any microcontroller for further development. Some of interfacing
applications which can be made are controlling home appliances, robotics movements,
Speech Assisted technologies, Speech to text translation.

11. 1Mitali Patil, 2Ashwini Bedare, 3Varsha Pacharne [11] proposed that Intelligent Home
Automation Systems are gaining importance in todays technology dependent world. Home
Automation Systems provide a sense of security and comfort. Using Wireless technology like
ZigBee the cost of wiring of Home Automation System can be reduced as well as a reliable
and secure communication can be achieved. ZigBee is a low data rate wireless network
standard with added features like low-cost, low power consumption and fast reaction. ZigBee
is most suitable for small area networks like homes. This System also allows controlling of
devices using Voice commands which reduce user interaction with system directly. This
System uses SAPI (Speech Application Programming Interface) a Microsoft Application to
enable voice recognition when a user gives voice command to the system. This system
contains of three main components: i) Intelligent Home Server with ZigBee module, ii)
Intelligent environment detection sensor modules and iii) Voice command controlling
module. The various features of the system include turning any home appliances or devices,
playing media applications, downloading RSS feeds, sending mail.
The Intelligent Home System is a voice-controlled home automation system which controls
home appliances over a ZigBee wireless network. Voice controlling enables users a sense of
comfort as no direct operation with the home automation system is required. ZigBee helps in
Dept. of CSE, PESCE, Mandya

Page 12

Home Automation System using Raspberry PI

2014-15

achieving a rapid rate, low power consumption and low cost network for the server to
communicate with the devices. The future work for Intelligent Home System can be porting
the system to the cloud so that any device eventually could be used to control and monitor
the Intelligent Home System remotely over cloud.
12. 1Sharon Panth, 2Mahesh Jivani [12] proposed home appliances are connected to the on/off
relay via microcontroller ports and controlled through two ways: one way is conventional
domestic switch and second is through mobile phone. The communication between the
mobile phone and the home automation system is through Bluetooth wireless technology.
This system is designed to be economical and scalable allowing one to twenty four
appliances to be controlled with minimum efforts. Password protection is being used to only
allow authorized users to control the appliances at home. Discovery method where the device
discovers other Bluetooth enabled devices. In second case, is the Known method which
allows direct connection to be established between the remote devices that are already
known.
The application works using the second method. The advantage of using the second method
is that we can establish connection directly by specifying the known devices address (here
Bluetooth Serial Adapter) within very less time as compared to the first method where it
searches for Bluetooth enabled devices first in its range and then establishes connection, if
wanted. The JABWT implementation includes the support for btspp protocol over RFCOMM
service. For the communication between the mobile phone and the embedded system (i.e.
Home Automation system) the connection string must contain the btspp protocol in the URL.
This is implemented by using the Connector class in the GCF Hierarchy. The Connector class
creates new connections dynamically using the protocol implementation class formed from
platform name and protocol name.
13. 1Faisal Baig, 2Saira Beg and 3Muhammad Fahad Khan [13] proposed Home automation is
a wide and varied field that involves devices as small as temperature, light and motion
sensor, and as powerful as modern home appliances. In todays world technology is available
for home automation but these technologies are incompatible with each other and addresses
only communication and physical media, the main objective of this work is to facilitate the
Dept. of CSE, PESCE, Mandya

Page 13

Home Automation System using Raspberry PI

2014-15

user to control appliances by two ways one is remotely via voice command, second is using
remote control to control the appliances which is also an override control.
For that purpose a mobile application is developed that convert the user voice command into
SMS and send through GSM network. Such application is developed using java for mobile
technology and MPLAB for microchip family of controller. This proposed system is
affordable to everyone, cheap and easy to install.
A low cost and flexible home control and monitoring system using an embedded micro-web
server, with IP connectivity for accessing and controlling devices and appliances remotely
using Android based Smart phone app. The proposed system does not require a dedicated
server PC with respect to similar systems and offers a novel communication protocol to
monitor and control the home environment with more than just the switching functionality.
14. 1Rajeev Piyare and 2Seong Ro Lee [14] proposed that Home automation or smart homes
(also known as domotic) can be described as introduction of technology within the home
environment to provide convenience, comfort, security and energy efficiency to its
occupants. With the introduction of the Internet of Things, the research and implementation
of home automation are getting more popular. Various wireless technologies that can support
some form of remote data transfer, sensing and control such as Bluetooth, Wi-Fi, RFID, and
cellular networks have been utilized to embed various levels of intelligence in the home. The
studies have presented Bluetooth based home automation systems using Android Smart
phones without the Internet controllability. The devices are physically connected to a
Bluetooth sub-controller which is then accessed and controlled by the Smart phone using
built-in Bluetooth connectivity. Researchers have also attempted to provide network
interoperability and remote access to control devices and appliances at home using home
gateways. Proposed mobile IP based architecture and its potential applications in Smart
homes security and automation without any actual deployment and testing.
15. 1Basma M. Mohammad El-Basioni,

Sherine M. 3Abd El-kader and 4Mahmoud

Abdelmonim Fakhreldin [15] proposes a new design for the smart home using the wireless
sensor network and the biometric technologies. The proposed system employs the biometric
in the authentication for home entrance which enhances home security as well as easiness of
Dept. of CSE, PESCE, Mandya

Page 14

Home Automation System using Raspberry PI

2014-15

home entering process. The proposed smart home Wireless Biometric Smart Home (WB-SH)
design is one of the few designs or it is the only design that addresses the integration between
the wireless sensor network and biometric in building smart homes. The structure of the
system is described and the incorporated communications are analyzed, also an estimation
for the whole system cost is given which is something lacking in a lot of other smart home
designs offers. The cost of the whole WB-SH system is determined to be approximately
$6000, which is a suitable cost with respect to the costs of existing systems and with respect
to its offered services. WB-SH is designed to be capable of incorporating in a building
automation system and it can be applied to offices, clinics, and other places.
16. 1Ulya Sabeel, 2Nidhi Chandra [16] proposed that Security is the major part of home
automation systems for the people. With the development of network and automatic control
technology, a home security monitoring and alarming system becomes more and more
practicable today. In this paper they have proposed simple, low cost, low power consumption
and a novel method for implementing the home security using Zigbee (802.15.4) standard
and also a security protocol for detecting and localizing identity based attacks in the system.
They have named the scheme as Wireless Home Security System (WHSS) and protocol as
Wireless Home Security Protocol (WHSP). It consists of many sensor nodes deployed in the
rooms as well as the doors/ windows of the house together with the zigbee modules which act
as end devices that monitor continuously and send the security status of each room to the
coordinator node connected to a PC which acts as the master.
The communication in this case is multi-hop which provides unlimited range. Here they have
used the XBEE Pro series1 (XBP24-AWI-001) radios for RF communication, DYP-ME003
PIR sensor, and Contact Door / window sensor based on magnetic reed switch
(ORD221).The hardware implementation has been tested for validation successfully. The
software has been implemented using C#. Also the performance of the proposed security
protocol has been analysed using NS2 and is found to be satisfactory. Passive Infrared (PIR)
sensor has been used to sense human motion by detecting the IR radiations emitted from
human body. The door/ window sensor is basically a magnetic contact reed switch. The
switch remains open when no magnetic field is present.

Dept. of CSE, PESCE, Mandya

Page 15

Home Automation System using Raspberry PI

2014-15

CHAPTER 3

SOFTWARE REQUIREMENT SPECIFICATIONS


3.1 Functional requirements
The goal was to develop a robust application which would allow a user to turn on and
off a light or that triggers an alarm with door sensors. The application required both user
input and feedback which takes user input and sends a signal to the Raspberry Pi. The Pi then
performs the desired action and returns a response to the application. The application also
needs to be memory and processor conscious as both these factors are often limited on most
smartphone devices. Also, the server application would be stored on open shift cloud
interface i.e. stored in a client/server architecture where the code for the interface is on the
open shift server application and is communicated to smartphone device and Pi, when user
connects. Creating an interface that is too large results in increased download time and this
needed to be avoided. With these factors in mind, the initial prototype of the application was
produced.

3.2 Non-functional requirements


The interface needs to be simple so that it could still be used by customers that were
not technically savvy. The end user may be someone very familiar with mobile applications
or it may be an elderly person who is new to the technology. The goal was to produce a

Dept. of CSE, PESCE, Mandya

Page 16

Home Automation System using Raspberry PI

2014-15

product that would be easy to use for all users while still maintaining an atheistically pleasing
interface which was similar to the common look and feel of other mobile applications.

3.3 System requirements


3.3.1 Software Requirements
As mentioned earlier, the android application communicates with Raspberry Pi
microprocessor created with Broadcom SoC. They provide a simple development interface
language python which can be used to write software for the microprocessor. A backend code
is written to communicate between the user interface and the electronic devices.
Pre-defined Toothpick Services
Several Toothpick services are preinstalled in the Raspberry Pi module in protected
memory which helps aid in programming for the module. Several of these functions were
used in generating the backend code and are explained in detail below.
Raspbian
Raspbian is a free operating system based on Debian optimized for the Raspberry Pi
hardware. An operating system is the set of basic programs and utilities that make your
Raspberry Pi run. However, Raspbian provides more than a pure OS: it comes with over
35,000 packages, pre-compiled software bundled in a nice format for easy installation on
your Raspberry Pi.
Python ide
Python is a widely used general-purpose, high-level programming language. Its
design philosophy emphasizes code readability, and its syntax allows programmers to express
concepts in fewer lines of code than would be possible in languages such as C. The language
provides constructs intended to enable clear programs on both a small and large scale.
Raspberry pi GPIO
The Raspberry Pi GPIO uses a development interface called RPi GPIO library to
interact with the Raspberry Pi GPIO pins. Therefore we need to set up a setting up a Python
library to allow access to the GPIO. RPi.GPIO is a small python library that takes some of
Dept. of CSE, PESCE, Mandya

Page 17

Home Automation System using Raspberry PI

2014-15

the complexity out of driving the GPIO pins. Installing the library is almost as simple, either
at a text console or using LXTerminal we need to enter the following commands.

sudo apt-get update


sudo apt-get upgrade
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio

3.3.2 Android Developer Tools (ADT)


Android software development is the process by which new applications are created
for the Android operating system. Applications are usually developed in the Java
programming language using the Android Software Development Kit, but other development
tools are available.
Android SDK
The Android software development kit (SDK) includes a comprehensive set of
development tools. These include a debugger, libraries, a handset emulator based on QEMU,
documentation, sample code, and tutorials. Currently supported development platforms
include computers running Linux (any modern desktop Linux distribution), Mac OS X 10.5.8
or later, Windows XP or later; for the moment one can develop Android software on Android
itself by using [AIDE - Android IDE - Java, C++] app and [Android java editor] app. The
officially supported integrated development environment (IDE) is Eclipse using the Android
Development Tools (ADT) Plugin, though IntelliJ IDEA IDE (all editions) fully supports
Android development out of the box. Android applications are packaged in .apk format and
stored under /data/app folder on the Android OS (the folder is accessible only to the root user
for security reasons). APK package contains .dex files (compiled byte code files called
Dalvik executable), resource files, etc.

3.3.3 Hardware
The various hardware components which are used mainly are listed below
Dept. of CSE, PESCE, Mandya

Page 18

Home Automation System using Raspberry PI

2014-15

Raspberry Pi
Wi-Fi router
Android device
Camera
Lights
Door sensor
SIM900A
Stepper motor

CHAPTER 4

DESIGN AND ANALYSIS


4.1 System analysis
Once the template is produced, it is time to integrate all the development work to
make a complete interface. The python code manages the list of controls that are to be
displayed to the user. The software package provides various views to control different
aspects of the controls, such as how they are managed and how they appear on specific client
software.

The Servlet application runs on OpenShift PAAS wherein the Raspberry Pi

microprocessor and the users are clients to it. Since OpenShift can provide more powerful
applications, a more advanced user interface can be created.

4.2 High level design


The backend code that we produce for the application is explained in this section.
The code flow charts will help describe the flow of the code. The server and client
application is written using Python code as the interface for Raspberry Pi to connect to lights
Dept. of CSE, PESCE, Mandya

Page 19

Home Automation System using Raspberry PI

2014-15

and sensors. The software produced utilizes both the built in functions as well as user
defined methods.
The application consists of several classes which will be discussed in detail in this
section. The first section describes the code produced by the interface design software and
several header files which must be included. The second section describes code we produced.

4.2.1 System Architecture


The Android client application was developed using Eclipse Kepler IDE which is an
integrated development environment (IDE). It contains a base workspace and an extensible
plug-in system for customizing the environment. Written mostly in Java, Eclipse can be used
to develop applications. The Eclipse software development kit (SDK), which includes the
Java development tools, is meant for Java developers.
The Android SDK provides you the API libraries and developer tools necessary to
build, test, and debug apps for Android. We can use ADT Bundle to quickly start developing
apps. It includes the essential Android SDK components and a version of the Eclipse IDE
with built-in ADT (Android Developer Tools) to streamline your Android app development.
The SDK has Eclipse with ADT plugin, Android SDK Tools, Android Platform-tools, the
latest Android platform and the latest Android system image for the emulator.
MOBILE DEVICE

WEB SERVICES

RASPBERRY PI

Dept. of CSE, PESCE, Mandya HOME CONTROL


Page 20
DEVICE

Home Automation System using Raspberry PI

2014-15

Fig 4.1: Data Flow Diagram


As shown in the above Fig 4.1, the mobile is connected to the Wi-Fi Router. The
message sent by the user will hit the router (Right IP addresses port number). Now the
message is sent to the system to which we would like to connect, whose IP address is
obtained.
Raspberry pi chip is a device in which an Operating System is installed and it
contains the IP address. Here we will connect the router to the Raspberry pi chip, as simple as
we plug in the wire. The appliances such as camera, lights are connected to the Raspberry pi
chip.

API Overview
The sections below provide a technical overview of new APIs in Android 4.0.3.
SOCIAL STREAM API IN CONTACTS PROVIDER
Applications that use social stream data such as status updates and check-ins can now
sync that data with each of the users contacts, providing items in a stream along with photos
for each.
The database table that contains an individual contacts social stream is defined by
ContactsContract.StreamItems,

due

to

the

Uri

is

nested

within

the

ContactsContract.RawContacts directory to which the stream items belong. Each social stream

table includes several columns for metadata about each stream item. Photos associated with a

Dept. of CSE, PESCE, Mandya

Page 21

Home Automation System using Raspberry PI

2014-15

stream are stored in another table, defined by ContactsContract.StreamItemPhotos, which is


available as a sub-directory of the ContactsContract.StreamItems Uri.
HOME SCREEN WIDGETS
Starting from Android 4.0, home screen widgets should no longer include their own
padding. Instead, the system now automatically adds padding for each widget, based the
characteristics of the current screen. This leads to a more uniform, consistent presentation of
widgets in a grid. To assist applications that host home screen widgets, the platform provides
a new method getDefaultPaddingForWidget(). Applications can call this method to get the
system-defined padding and account for it when computing the number of cells to allocate to
the widget.
BLUETOOTH
New public methods fetchUuidsWithSdp() and getUuids() let apps determine the features
(UUIDs) supported by a remote device. In the case of fetchUuidsWithSdp(), the system
performs a service discovery on the remote device to get the UUIDs supported, then
broadcasts the result in an ACTION_UUID intent.
UI TOOLKIT
New methods setUserVisibleHint() and getUserVisibleHint() allow a fragment to set a hint of
whether or not it is currently user-visible. The system defers the start of fragments that are
not user-visible until the loaders for visible fragments have run. The visibility hint is "true"
by default.

GRAPHICS
New method setDefaultBufferSize(int, int) in SurfaceTexture sets the default size
of the image buffers. This method may be used to set the image size when

Dept. of CSE, PESCE, Mandya

Page 22

Home Automation System using Raspberry PI

2014-15

producing images with Canvas (via lockCanvas(Rect)), or OpenGL ES (via an


EGLSurface).
Adds definitions for the enums of the GS_OES_EGL_image_external openGL ES
extension GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES.
ACCESSIBILITY
Clients of RemoteViews can now use the method setContentDescription() to set
and get the content description of any View in the inflated layout.
The methods getMaxScrollX(), getMaxScrollY(), setMaxScrollX(),

and

setMaxScrollY() allow apps to get and set the maximum scroll offset for an
AccessibilityRecord object.
When touch-exploration mode is enabled to the user, a new secure setting called
ACCESSIBILITY_SPEAK_PASSWORD indicates whether the user requests the
IME to speak text entered in password fields, even when a headset is not in use.
By default, no password text is spoken unless a headset is in use.
DATABASE
A new CrossProcessCursorWrapper class lets content providers return results for
a cross-process query more efficiently. The new class is a useful building block
for wrapping cursors that will be sent to processes remotely. It can also transform
normal Cursor objects into CrossProcessCursor objects transparently.
The CrossProcessCursorWrapper class fixes common performance issues and
bugs that applications have encountered when implementing content providers.
The CursorWindow(java.lang.String) constructor now takes a name string as
input. The system no longer distinguishes between local and remote cursor
windows, so CursorWindow(boolean) is now deprecated.
CAMERA
MediaMetadataRetriever adds the new constant METADATA_KEY_LOCATION
to let apps access retrieve location information for an image or video.

Dept. of CSE, PESCE, Mandya

Page 23

Home Automation System using Raspberry PI

2014-15

CamcorderProfile adds the QVGA (320x240) resolution profiles. Quality level is


represented by the QUALITY_QVGA.and QUALITY_TIME_LAPSE_QVGA
constants.
New methods setVideoStabilization() and isVideoStabilizationSupported() lets
you check and manage video stabilization for a camera.
PERMISSIONS
The following are new permissions:
READ_SOCIAL_STREAM and WRITE_SOCIAL_STREAM: Allow a sync adapter
to read and write social stream data to a contact in the shared Contacts Provider..

High level diagram

Fig 4.3: High Level Diagram

Dept. of CSE, PESCE, Mandya

Page 24

Home Automation System using Raspberry PI

2014-15

As shown in the above Fig 4.3, there are two users: actual user and the end user
(Raspberry pi chip). The user has the control over the appliances that is camera and lights.
The user sends the signal to the appliances. The signal sent by the user will be processed by
the Raspberry chip and it will send the appropriate response to the devices that are internally
connected to it. The signal sent by the user will be validated by the Raspberry pi chip. If the
validation made by the Raspberry pi chip is unsuccessful then there will be generation of
error messages, else the result will be generated, user request will be executed. If there is an
error in the creation of a response to the user then the appropriate error messages are
generated which are notified to the end user. This figure explains how the user will have
control over the devices connected to the device.

4.3

LOW LEVEL DIAGRAM

Sequence diagram
WIFI

SERVER/ACCESS

OTHER

RASPBERRY

CONNECT
APPLIANCES STATUS

CONTROL APPLIANCES

ACTIVATE/DECTIVATE APPLIANCES
APPLIANCES STATUS

PROPOGATE STATUS

Fig 4.4: Sequence Diagram

As shown in the above Fig 4.4 the actual user is connected to the server through
internet. The user will send a request to the server which will be processed by the raspberry
pi.The raspberry pi will reply the appliances status to the users device.
Dept. of CSE, PESCE, Mandya

Page 25

Home Automation System using Raspberry PI

2014-15

The message sent by the user will not be received by the Raspberry pi chip directly.
We will create a web page which use that as a web service that is the message sent by the
user to the Raspberry pi chip will be communicated through web page, where a service will
be created.
Python code will be running for the particular message that is sent by the user that
make sure that it is running on the command. Application status will be received through the
Server access point which is nothing but the web service. Here we use web service because,
it will be running in the background. Web service is used because, it provides the service
even though the web page is closed.
Since we cannot communicate directly with the Raspberry pi chip, the XML
document will be transmitted. We can activate/deactivate the appliances through the
raspberry pi chip.

4.4 User interface design


Fig 4.6 shows the prototype design of android application development. The initial
design had to be kept in mind the functional and non-functional requirements listed above.

Fig 4.6 Android Application Prototype

Dept. of CSE, PESCE, Mandya

Page 26

Home Automation System using Raspberry PI

2014-15

CHAPTER 5

IMPLEMENTATION
Implementation is the stage of the project when the theoretical design is turned out
into a working system. Thus it can be considered to be the most critical stage in achieving a
successful new system and in giving the user, confidence that the new system will work and
be effective. The implementation stage involves careful planning, investigation of the
existing system and its constraints on implementation, designing of methods to achieve
changeover and evaluation of changeover methods.

5.1 INTERFACE
Once the template was produced, it was time integrate all the development work to
make a complete interface. The python code manages the list of controls that are to be
displayed to the user. The software package provides various views to control different
aspects of the controls, such as how they are managed and how they appear on specific client
software.

The Servlet application runs on OpenShift PAAS wherein the Raspberry Pi

microprocessor and the users are clients to it. Since OpenShift can provide more powerful
applications, a more advanced user interface was created.

5.2 SOFTWARE
The backend code that we produced for the applications is explained in the next
section. The code flow charts will help describe the flow of the code. The server and client
application is written using Python code as the interface for Raspberry Pi to connect to lights
and sensors. The software produced utilizes both the built in functions as well as user
defined methods.

Dept. of CSE, PESCE, Mandya

Page 27

Home Automation System using Raspberry PI

2014-15

The application consists of several classes which will be discussed in detail in this
section. The first section describes the code produced by the interface design software and
several header files which must be included. The second section describes code we produced.
5.2.1

ANDROID CLIENT APPLICATION


The Android client application was developed using Eclipse Kepler IDE which is is

an integrated development environment (IDE). It contains a base workspace and an


extensible plug-in system for customizing the environment. Written mostly in Java, Eclipse
can be used to develop applications. The Eclipse software development kit (SDK), which
includes the Java development tools, is meant for Java developers. Users can extend its
abilities by installing plugins written for the Eclipse Platform, such as development toolkits
for other programming languages, and can write and contribute their own plug-in modules.
The Android SDK provides you the API libraries and developer tools necessary to
build, test, and debug apps for Android. We can use ADT Bundle to quickly start developing
apps. It includes the essential Android SDK components and a version of the Eclipse IDE
with built-in ADT (Android Developer Tools) to streamline your Android app development.
The SDK has Eclipse with ADT plugin, Android SDK Tools, Android Platform-tools, the
latest Android platform and the latest Android system image for the emulator.
An Android emulator is used to visualize the finally developed software using a
android in-built API level 15 known as Ice Cream Sandwich 4.0.x series. A mobile client is
used to simulated software on client side in real time.
ANDROID 4.0.3 APIS
Android 4.0.3 (ICE_CREAM_SANDWICH_MR1) is an incremental release of the
Android 4.x (Ice Cream Sandwich) platform family. This release includes new features for
users and developers, API changes, and various bug fixes. For developers, the Android 4.0.3
platform is available as a downloadable component for the Android SDK. The downloadable
platform includes an Android library and system image, as well as a set of emulator skins and
more. To get started developing or testing against Android 4.0.3, use the Android SDK
Manager to download the platform into your SDK.

Dept. of CSE, PESCE, Mandya

Page 28

Home Automation System using Raspberry PI

2014-15

5.3 Control flow diagram


WEB SERVICES
(URL)
APPLIANCE
S
CONSTAN
T CHECK

CONNECT 0

URL

DISCONNECT 1

RASPBERRY
PI

ANDROID
DEVICE

Fig 5.1: Control Flow diagram


The Fig 5.1 depicts the working of the home automation system using Raspberry Pi.
Initially there are several devices such as camera, magnetic door sensor and lights. As soon
as the door opens the magnet gets separated and a magnetic field is generated between the
Dept. of CSE, PESCE, Mandya

Page 29

Home Automation System using Raspberry PI

2014-15

magnets and thus sending a signal through the wires which are connected to the Raspberry
Pi. If a 0 is received the magnet is said to be connected or else if 1 the magnet is said to
be disconnected thereby sending a signal to the device. The camera and the lights works in a
similar fashion , if the input is 0 the lights and camera are set to off state and if the input
is 1 the lights and camera are set to on state.
The Raspberry Pi communicates with the web services through url which acts as an
interface between the application and the device. The web service application will be located
on the web service server i.e., on the raspberry pi.

The general syntax of the URL is given by


Protocol: //apploc:port/app/keyword
Where,
Protocol is the general HTTP protocol,
Apploc is the IP address of the Raspberry Pi,
Port is the port number,
App is the application name,
Keyword is the subject of the message sent to the user.
The keyword can be anything such as door-d, which gives an indication that the
dth door has been opened. The application keeps a constant check on the web services. The
web service is generally an XML file which is a platform for communication between
android applications as well as Raspberry Pi. All the android phones must be logged in to a
Gmail account to access the services. In order to get remote access, the user has to login
using the Gmail account.
The web service is generally located on the machine and works on web service
application server. The application in this context refers to the android application which is
used for communication or it can be any other source such as mail, messages or any other
source of information which can be easily conveyed to the user. If each device must point to
Dept. of CSE, PESCE, Mandya

Page 30

Home Automation System using Raspberry PI

2014-15

a specific application then there must be a static IP assigned to each Raspberry Pi. The
increasing demand for IPs as well as the usage of IPv6 in the near future will decrease the
cost of static IPs. Every user can buy a domain for himself to have a secure access to his
home or workplace.
The raspberry Pi is set up using Python code with certain networking concepts
embedded into it in order to connect to the internet as well as the other devices. We make use
of standard set of APIs to generate a python code which can perform user specified tasks.
Since Raspberry Pi can only interact through Python we make use of this language to
communicate with the server as well as the android device.

5.4 Pseudo code


Magnetic door sensor
The program for this project just loops round printing a message every time motion is
detected, or the magnet is moved away from the door.
import time
import RPi.GPIO as io
io.setmode(io.BCM)
pir_pin = 18
door_pin = 23
io.setup(pir_pin, io.IN)

# activate input

io.setup(door_pin, io.IN, pull_up_down=io.PUD_UP) # activate input with PullUp


while True:
if io.input(pir_pin):
print("PIR ALARM!")
if io.input(door_pin):
print("DOOR ALARM!")
Dept. of CSE, PESCE, Mandya

Page 31

Home Automation System using Raspberry PI

2014-15

time.sleep(0.5)
The program sets the pir_pin to be just a plain old input. This is because the PIR
sensor has a digital output of either 3.3V or 0V. By contrast, the door_pin, since it is a switch
does not generate a voltage for a digital input. So, that input pin uses the extra argument
(pull_up_down=io.PUD_UP). This activates an internal resistor that makes the input HIGH
(pulled-up) unless something stronger (like a switch connecting it to GND) pulls it LOW.
The loop then reads each of the inputs in turn and prints a message appropriately.
Remember that the door switch warning will be activated when the magnet is removed from
the sensor rather than the other way around.

Camera
First, at the Python prompt or at the top of a Python script, enter:
import picamera
This will make the library available to the script. Now create an instance of the PiCamera
class:
camera = picamera.PiCamera()
And take a picture:
camera.capture('image.jpg')
Horizontal and vertical flip
Like with the raspistill command, you can apply a horizontal and vertical flip if your
camera is positioned upside-down. This is done by changing the hflip and vflip properties
directly:
camera.hflip = True
camera.vflip = True
Be sure to use an upper case T in True as this is a keyword in Python.
Preview

Dept. of CSE, PESCE, Mandya

Page 32

Home Automation System using Raspberry PI

2014-15

You can display a preview showing the camera feed on screen. Warning: this will
overlay your Python session by default; if you have trouble stopping the preview, simply
pressing Ctrl+D to terminate the Python session is usually enough to restore the display:
camera.start_preview()
You can use the stop_preview method to remove the preview overlay and restore the display:
camera.stop_preview()
Alternatively, you can access the Pi using SSH from another computer, open a Python
prompt and enter these commands, displaying the preview on the monitor connected to the Pi
(not the computer you're connected from).
Camera settings
You can change other camera configuration by editing property values, for example:
camera.brightness = 70
This will change the brightness setting from its default 50 to 70 (values between 0 and 100).
Other settings are available. Here is a list with their default values:
camera.sharpness = 0
camera.contrast = 0
camera.brightness = 50
camera.saturation = 0
camera.ISO = 0
camera.video_stabilization = False
camera.exposure_compensation = 0
camera.exposure_mode = 'auto'
camera.meter_mode = 'average'
camera.awb_mode = 'auto'
camera.image_effect = 'none'
camera.color_effects = None
camera.rotation = 0
camera.hflip = False
camera.vflip = False
camera.crop = (0.0, 0.0, 1.0, 1.0)
Dept. of CSE, PESCE, Mandya

Page 33

Home Automation System using Raspberry PI

2014-15

Sleep
You can add pauses between commands using sleep from the time module:
import picamera
from time import sleep
camera = picamera.PiCamera()
camera.capture('image1.jpg')
sleep(5)
camera.capture('image2.jpg')
You can also use sleep in a preview to adjust settings over time:
camera.start_preview()
for i in range(100):
camera.brightness = i
sleep(0.2)
Video streaming
Record 5 seconds of video:
camera.start_recording('video.h264')
sleep(5)
camera.stop_recording()

Lights
In order to make our LEDs flash on and off we will be using python code, so open up
IDLE3, all code that you need to type in is indented into the page, make sure you get the case
and the indents exactly as I have typed them.
As we will be writing Python scripts you need to adjust IDLE3 (your code editor)
slightly so that it brings up the script edit window as well as the shell windows. to do this go
to Options > Configure IDLE > General > Startup Preferences and then select 'Open Edit
Window'. Now when you restart IDLE you will get two windows, one called 'Python Shell'
and the other called 'Untitled'. The 'Untitled' window is your python script which you will
want to save somewhere to you can find it later. To run this script select Run > Run Module
or just press F5.

Dept. of CSE, PESCE, Mandya

Page 34

Home Automation System using Raspberry PI

2014-15

The first code you will want to put in your script is


from time import sleep
import pifacedigitalio
This imports the sleep command which will come in handy later on and imports the PiFace
libraries. The next thing we do is create a PiFace Digital object so we can control the PiFace.
pfd = pifacedigitalio.PiFaceDigital()
pfd.output_port.all_off()
pfd is now our PiFace object and you will also notice we have turned all the ports off in case
any LEDs are still on. Next we need to make an LED flash on and off, we will also set a
small time delay between turning them on and off.
pfd.leds[0].turn_on()
sleep(0.05)
pfd.leds[0].turn_off()
sleep(0.05)
So that flashed the LED once, we can use a for loop to flash it more than once.
for x in range(0, 10):
pfd.leds[0].turn_on()
sleep(0.05)
pfd.leds[0].turn_off()
sleep(0.05)
In the for loop the first number is the starting number and the second is the ending
number, so if you want the light to flash more or less than 10 times, feel free to change the
number to suit. In the next step I'll show you how to get the lights to flash one after another
(chasing).
GSM
The code to send the message to the destination is specified by the following set of
lines. The command AT+CMGS sends a SMS message to a GSM phone. The phone number
is specified at the end of the file.
def sendMessage(self,phone_number, message):
flag = False
Dept. of CSE, PESCE, Mandya

Page 35

Home Automation System using Raspberry PI

2014-15

self.sendCommand('AT+CMGS=\"' + phone_number + '\"')


time.sleep(2)
print 'SUCCESS'
self.serialPort.write(message)
self.serialPort.write('\x1A') # send messsage if prompt received
flag = True
time.sleep(5)
return flag

The code for the message to be read is specified here. Both the message as well as the
phone number is specified at the end of the file.
def readMessage(self):
flag = False
message = ''
self.sendCommand('AT+CMGR=1')
self.serialPort.flushInput()
self.serialPort.flushOutput()
self.serialPort.readline().rstrip()
while True:
response = self.serialPort.readline().rstrip()
if len(response)>1:
if response == 'OK':
break
else:
message = message +" " + response
flag = True

Audio

Dept. of CSE, PESCE, Mandya

Page 36

Home Automation System using Raspberry PI

2014-15

Certain set of built-in functions have to be included in order to get the audio output
from the device.
import os
from os import listdir
import subprocess
from time import sleep
import RPi.GPIO as GPIO
The function to read the mp3 file from the file system is given below.
mp3_files = [ f for f in listdir('.') if f[-4:] == '.mp3' ]
The .mp3 file is stored in the index. Since we have used only 1 file it is stored at the
beginning of the index. The GPIO port is specified ehich is connected to the speaker and the
audio output device.
if (GPIO.input(24)):
subprocess.Popen(['mpg123', mp3_files[index]])
Stepper Motor
4 GPIO pins are used for the stepper motor. Two of them are used for the clockwise
rotation and the other two are used for the anti-clockwise rotation. Finally those 4 pins are
connected to a common pin which is enabled by the following code.
enable_pin = 18
coil_A_1_pin = 4
coil_A_2_pin = 17
coil_B_1_pin = 23
coil_B_2_pin = 24
GPIO.setup(enable_pin, GPIO.OUT)
GPIO.setup(coil_A_1_pin, GPIO.OUT)
GPIO.setup(coil_A_2_pin, GPIO.OUT)
GPIO.setup(coil_B_1_pin, GPIO.OUT)
Dept. of CSE, PESCE, Mandya

Page 37

Home Automation System using Raspberry PI

2014-15

GPIO.setup(coil_B_2_pin, GPIO.OUT)
The clockwise and anti-clockwise rotation is set accordingly using these set of lines
def forward(delay, steps):
for i in range(0, steps):
setStep(1, 0, 1, 0)
time.sleep(delay)
setStep(0, 1, 1, 0)
time.sleep(delay)
setStep(0, 1, 0, 1)
time.sleep(delay)
setStep(1, 0, 0, 1)
time.sleep(delay)
def backwards(delay, steps):
for i in range(0, steps):
setStep(1, 0, 0, 1)
time.sleep(delay)
setStep(0, 1, 0, 1)
time.sleep(delay)
setStep(0, 1, 1, 0)
time.sleep(delay)
setStep(1, 0, 1, 0)
time.sleep(delay)
The speed of the motor as well as the angle at which it rotates is set by using the following
code.
delay = 20

#raw_input("Delay between steps (milliseconds)?")

steps = 50

#raw_input("How many steps forward? ")

forward(int(delay) / 1000.0, int(steps))


steps = 50

#raw_input("How many steps backwards? ")

backwards(int(delay) / 1000.0, int(steps))


Dept. of CSE, PESCE, Mandya

Page 38

Home Automation System using Raspberry PI

2014-15

os.system("python gsm.py")

CHAPTER 6

TESTING
Software testing is a critical element of software quality assurance and represents the
ultimate service of specification design and coding. It provides a road map for the developer,
the quality assurance organization and the customer, a roadmap that describes the steps to be
conducted as path of testing, when these steps are planned and then undertaken and how
much effort, time and resources will be required. It is not unusual for a software development
to spend between 30 and 40 percent of total project effort in testing.
Testing demonstrates that software functions appear to be working according to specification
and that performance requirements appear to have been met. In addition, data collected as
testing is conducted provides a good indication of software. Testing cant show the absence
of defects, it can only show that software errors are present.

6.1 Aim of Testing

Dept. of CSE, PESCE, Mandya

Page 39

Home Automation System using Raspberry PI

2014-15

The main aim of testing is to analyse the performance and to evaluate the errors that occur
when the program is executed with different input sources.
In this project, we developed an automated system which focuses on supermarket Queue
prevention and automation. The main aim of testing in this project is to find the compatibility
issues as well as the working performance when different sources are given as the inputs.

6.2 Levels of testing:


6.2.1 Unit testing
Unit testing involves the design of test cases that validate that the internal program
logic is functioning properly, and that program inputs produce valid outputs. All decision
branches and internal code flow should be validated. It is the testing of individual software
units of the application. It is done after the completion of an individual unit before
integration. This is a structural testing, that relies on knowledge of its construction and is
invasive. Unit tests perform basic tests at component level and test a specific business
process, application, and/or system configuration. Unit tests ensure that each unique path of a
business process performs accurately to the documented specifications and contains clearly
defined inputs and expected results.

Dept. of CSE, PESCE, Mandya

Page 40

Home Automation System using Raspberry PI

2014-15

6.2.2 Integration testing


Integration tests are designed to test integrated software components to determine if
they actually run as one program. Testing is event driven and is more concerned with the
basic outcome of screens or fields. Integration tests demonstrate that although the
components were individually satisfaction, as shown by successfully unit testing, the
combination of components is correct and consistent. Integration testing is specifically aimed
at exposing the problems that arise from the combination of components.
6.2.3 System Testing
System testing ensures that the entire integrated software system meets requirements.
It tests a configuration to ensure known and predictable results. An example of system testing
is the configuration oriented system integration test. System testing is based on process
descriptions and flows, emphasizing pre-driven process links and integration points.

6.3 RASPBERRY PI COMPONENTS TESTING


Home App

Description

Door Sensors

No
arguments

GSM Module

No
arguments

Stepper Motor
Camera Monitoring
Lights

No
arguments
No
arguments

Dept. of CSE, PESCE, Mandya

Action
Check and
notify Pi
about door
open or
close
Send Alert
messages
when door
Triggered
Stepper
motor
Rotation
360 Degree
Relay live
stream to Pi
On and Off
LEDs

Page 41

Working

Yes

Yes

Yes
Yes
Yes

Home Automation System using Raspberry PI

2014-15

status to Pi
Table 6.1 - Raspberry Pi Component Testing

6.4 ANDROID CLIENT COMPONENT TESTING


Problem

Working

User tries to access camera


remotely with android

Action taken
Pi obtains the status of
door and reports back to
user
Pi obtains a live video
stream from the camera
and relays it back to user

User tries to turn on/off LED


Lights with android

Pi switches on/off the leds

Yes

The user gets notification from


Door Sensor on android

Yes

Yes

Table 6.2 - Android client component testing

6.5 Sample Test Cases


A Test Case (TC) is a set of test inputs, executions and expected results developed for
a particular objective.
An excellent test case satisfies the following criteria:

Reasonable probability of catching an error.


Does interesting things
Doesnt do unnecessary things

Dept. of CSE, PESCE, Mandya

Page 42

Home Automation System using Raspberry PI

Test
case ID

Test case
Name

TC-01
Testing

TC-02

Integration
Testing
TC-03

TC-04

Unit
Testing

Test case
description

A Wi-Fi Router
is used as a
method of
communication
between Pi and
android
Remote login
into Pi using
PuTTy for
configuration

2014-15

Test steps
Input Expected
Given Output

Actual
Output

Test Status P/F

Pass
Successfully user
commands are executed by
Raspberry Pi
The IP and Port number is
identified, configured and
successful connection
takes place

Pass

Integration is
checked with
Python
Programming

Input -> Lights


Output -> Turn On / Turn
Off lights using Pi
Input -> Camera
Output -> Live Stream
Input -> Door
Output -> Status
Input -> GSM Module
Output -> Alert messages
Input -> Door triggered
Output -> Stepper motor
Rotation 360 Degree

Pass

Executing
main program
which involves
all the modules

Successful execution of
program

Pass

CHAPTER 7

SNAPSHOTS AND RESULT DISCUSSION

Dept. of CSE, PESCE, Mandya

Page 43

Table 6.3 Sample


test cases

Home Automation System using Raspberry PI

Fig 7.1: Authentication screen

2014-15

Fig 7.2: Main screen

This is the start-up screen of the android application. It is the authentication page of the user
where the user gives his username and password.
This is the second screen of the application. As soon as the user logins to his account
there are two options which appear on the screen. i.e., one option is to control the devices
such as camera, door sensors and lights. The other option is to view the live streaming
content on the users smartphone. It also provide the option such as to set the host ip address
and the port number to view the stream. Along with these option, we also have provided the
option to change the resolution of the video.

Dept. of CSE, PESCE, Mandya

Page 44

Home Automation System using Raspberry PI

Fig 7.3: Appliances used

2014-15

Fig 7.4: Light Notification

After clicking on the home devices option he will be directed to the page where you will see
three options to control the lights, door sensors and camera. The user can select the desired
options depending upon his requirements.
The user can access the accessories like camera, light and door sensor magnet by
sending the signal from the application to raspberry pi. If the user sends the signal to
light,then the raspberry pi sends the signal back with necessary action that the light is ON or
OFF.

Dept. of CSE, PESCE, Mandya

Page 45

Home Automation System using Raspberry PI

Fig 7.5: Door notification

2014-15

Fig 7.6: Camera notification

The user sends the signal to raspberry pi to check on door and the raspberry sends
back the signal as follows, if the magnet is separated the message will be displayed as door is
OPEN or if the magnets are joined then the message will be displayed as door is CLOSED.
Now if the user wants to access the camera for live feed, then the user sends the
signal to raspberry pi to switch on the camera and to send back the message that the camera
is ON or OFF. If the camera is on then the live feed of the view inside the hall will be
displayed on the mobile device and user can see the live feed.

Dept. of CSE, PESCE, Mandya

Page 46

Home Automation System using Raspberry PI

2014-15

CONCLUSION AND FUTURE ENHANCEMENT


The system as the name indicates, Android based home automation makes the system more
flexible and provides attractive user interface compared to other home automation systems.
In this system we integrate mobile devices into home automation systems. A novel
architecture for a home automation system is proposed using the relatively new
communication technologies. The system consists of mainly three components is a Wi-Fi
module, raspberry pi board and relay circuits. Wi-Fi is used as the communication channel
between android phone and the raspberry pi board. We hide the complexity of the notions
involved in the home automation system by including them into a simple, but comprehensive
set of related concepts. This simplification is needed to fit as much of the functionality on the
limited space offered by a mobile devices display.

FUTURE ENHANCEMENT
Predicting the future of just about anything is very risky business. Home automation is an
industry that largely started with X10 devices in 1980. Today, we believe the future of home
automation will very much ride the digital age and develop along with the computer and
networking systems in the years to come. Initially it appeared, companies such as Microsoft
and Exceptional Innovation with their Life/ware software were positioning the Windows
Media Centre PC as the heart and soul of a complete solution for home automation relying on
web services to seamlessly interface with lighting controls, climate controls, security panels,
and IP surveillance cameras to compliment the digital media management capabilities of
Windows Media Centre.

Dept. of CSE, PESCE, Mandya

Page 47

Home Automation System using Raspberry PI

2014-15

BIBILIOGRAPHY
[1]1Sarthak Jain, 2Anant Vaibhav, 3Lovely Goyal Student member, Raspberry Pi based
Interactive Home Automation System through E-mail IEEE, ICROIT 2014, India, Feb 6-8
2014.
[2] 1Nausheen Belim, 2Harshada Bhambure, 3Priyanka Kumbhar, 4Simranjit Tuteja
Automate and Secure Your Home Using Zigbee Technology, International Journal of
Innovative Research in Computer and Communication Engineering Vol. 1, Issue 1, March
2013.
[3] 1Dr. S. Kanaga suba raja, 2C. Viswanathan, 3Dr. D. Sivakumar, 4M. vivekanandan Secured
smart home energy monitoring system (Schemes) using raspberry pi Journal of Theoretical
and Applied Information Technology 10th August 2014. Vol. 66 No.1.
[4] 1Ali Ziya Alkar, 2Umit Buhur, An Internet Based Wireless Home Automation System for
Multifunctional Devices Member, IEEE Volume: 51, Issue: 4
[5] 1R.A.Ramlee, 2M.H.Leong, 3R.S.S.Singh, 4M.M.Ismail, 5M.A.Othman, 6H.A.Sulaiman,
7

M.H.Misran, 8M.A.Meor Said Bluetooth Remote Home Automation System Using Android

Application, The International Journal of Engineering and Science (IJES) ||Volume|| 2 ||


Issue|| 01 ||Pages|| 149-153 ||2013.
[6] 1Jayarani Kamble, Adaptive Home System Using Wireless Sensor Network and Multi
Agent System Int. Journal of Engineering Research and Applications ISSN: 2248-9622, Vol.
4, Issue 3(Version 1), March 2014.
[7] 1Raveendra.k, Energy Efficient Intruder Detection and Alert (Eeida) System Using
Wireless Multimedia Sensor Networks International Journal of Innovative Research in
Computer and Communication Engineering Vol.2, Special Issue 4, September 2014.
[8] 1Rajeev Piyare, Internet of Things: Ubiquitous Home Control and Monitoring System
using Android based Smart Phone International Journal of Internet of Things 2013, 2(1): 5
[9] 1Armando Roy Delgado, 2Rich Picking,

Vic Grout Remote-Controlled Home

Automation Systems with Different Network Technologies, Centre for Applied Internet
Research (CAIR), University of Wales, NEWI, Wrexham, UK.
[10] 1Y.Usha Devi, II M.Tech, Wireless Home Automation System Using ZigBee
International Journal of Scientific & Engineering Research Volume 3, Issue 8, August-2012.
Dept. of CSE, PESCE, Mandya

Page 48

Home Automation System using Raspberry PI

2014-15

[11] 1Mitali Patil, 2Ashwini Bedare, 3Varsha Pacharne The Design and Implementation of
Voice Controlled Wireless Intelligent Home Automation System Based on ZigBee
International Journal of Advanced Research in Computer Science and Software Engineering.
Volume 3, Issue 4, April 2013 ISSN: 2277 128X
[12] 1Sharon Panth, 2Mahesh Jivani Designing Home Automation System (HAS) using Java
ME for Mobile Phone International Journal of Electronics and Computer Science
Engineering.
[13] 1Faisal Baig, 2Saira Beg and 3Muhammad Fahad Khan.Zigbee Based Home Appliances
Controlling Through Spoken Commands Using Handheld Devices, Vol. 7, No. 1, January,
2013
[14] 1Rajeev Piyare, 2Seong Ro Lee Department of Information Electronics Engineering,
Mokpo National University Smart Home-Control and Monitoring System Using Smart
Phone Volume 5, Issue 2, April 2014
[15] 1Basma M. Mohammad El-Basioni, 2Sherine M. Abd El-kader and 3Mahmoud
Abdelmonim Fakhreldin Smart Home Design using Wireless Sensor Network and Biometric
Technologies, Volume 2, Issue 3, March 2013
[16] 1Ulya Sabeel, 2Nidhi Chandra Department of Computer Science and Engineering,
Amity University An Ingenious Wireless Home Security System and Protocol based upon
Multi-hop 802.15.4 standard, Magnetic contact and PIR sensor, MECS Publisher 2013

Dept. of CSE, PESCE, Mandya

Page 49

Home Automation System using Raspberry PI

2014-15

APPENDIX A
Hardware components Description and Purpose
Raspberry Pi Microprocessor
The Raspberry Pi shown in Fig 1 is a series of credit card-sized single-board
computers developed in the UK by the Raspberry Pi Foundation. The Raspberry Pi shown in
fig 3.2 has a Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZFS 700 MHz processor, VideoCore IV GPU, and was originally shipped with 256 megabytes
of RAM, later upgraded to 512 MB. It does not include a built-in hard disk or solid-state
drive, but it uses an SD card for booting and persistent storage. The Raspberry Pi primarily
uses Linux-kernel-based systems. The ARM11 chip at the heart of the Pi is based on
version 6 of the ARM. The current releases of several popular versions of Linux,
including Ubuntu, will not run on the ARM11. It is not possible to run Windows on the
original Raspberry Pi, though the new Raspberry Pi 2 will be able to run Windows 10. The
Raspberry

Pi

currently

only

supports Ubuntu

Snappy

Core, Raspbian, OpenELEC and RISC OS. The install manager for the Raspberry Pi is
NOOBS.

Fig 1: Raspberry Pi Device


Dept. of CSE, PESCE, Mandya

Page 50

Home Automation System using Raspberry PI

2014-15

Raspberry Pi Pin out diagram


One powerful feature of the Raspberry Pi is the row of GPIO (general purpose
input/output) pins along the edge of the board, next to the yellow video out socket. These
pins are a physical interface between the Pi and the outside world. At the simplest level, you
can think of them as switches that you can turn on or off (input) or that the Pi can turn on or
off (output). Seventeen of the 26 pins are GPIO pins; the others are power or ground pins as
shown in Fig 2.

Fig 2: Pin out diagram of Raspberry PI


You can program the pins to interact in amazing ways with the real world. Inputs
don't have to come from a physical switch; it could be input from a sensor or a signal from
another computer or device, for example. The output can also do anything, from turning on
an LED to sending a signal or data to another device. If the Raspberry Pi is on a network, you
can control devices that are attached to it from anywhere and those devices can send data
back. Connectivity and control of physical devices over the internet is a powerful and
exciting thing, and the Raspberry Pi is ideal for this.

Dept. of CSE, PESCE, Mandya

Page 51

Home Automation System using Raspberry PI

2014-15

Android Smartphone and Router


There are several phones on the market currently that employ Android OS
technology. Most major smartphones are capable of working with this type of application.
For the testing and implementation, the Samsung Galaxy Trend smartphone was used.

Fig 3: Samsung Galaxy Smartphone


This phone provides android Jellybean OS version 3 support. An Android application
is developed that is compliant with the device. This phone was chosen because it provides the
tools needed to load and test our mobile application that is connected to Raspberry Pi through
a DLink-2750U Router.

Dept. of CSE, PESCE, Mandya

Page 52

Home Automation System using Raspberry PI

2014-15

Fig 4: Router

Magnetic Door Sensors


The Magnetic Door Sensors as shown in figure below contains a reed switch which is
an electrical switch operated by an applied magnetic field. It was invented at Bell Telephone
Laboratories in 1936 by W. B. Ellwood. It consists of a pair of contacts on ferrous metal
reeds in a hermetically sealed glass envelope. The contacts may be normally open, closing
when a magnetic field is present, or normally closed and opening when a magnetic field is
applied. The magnet sends a signal 1 when it is connected and it sends a signal 0 when the
magnets are disconnected. These door sensors are attached to the user which is helpful to
notify to the user about the doors status.

Dept. of CSE, PESCE, Mandya

Page 53

Home Automation System using Raspberry PI

2014-15

Fig 5: Magnetic Door Sensor


The switch may be actuated by a coil, making a reed relay, or by bringing a magnet
near to the switch. Once the magnet is pulled away from the switch, the reed switch will go
back to its original position. The reed switch contains a pair (or more) of magnetizable,
flexible, metal reeds whose end portions are separated by a small gap when the switch is
open. The reeds are hermetically sealed in opposite ends of a tubular glass envelope. A
magnetic field (from an electromagnet or a permanent magnet) will cause the reeds to come
together, thus completing an electrical circuit. The stiffness of the reeds causes them to
separate, and open the circuit, when the magnetic field ceases. One important quality of the
switch is its sensitivity, the amount of magnetic field necessary to actuate it. Sensitivity is
measured in units of Ampere-turns, corresponding to the current in a coil multiplied by the
number of turns. Typical pull-in sensitivities for commercial devices are in the 10 to 60 AT
range.
Microsoft Webcam VX-2000
A webcam is used with our hardware for a security surveillance module. The webcam
must be compatible with Raspberry Pi hardware for security monitoring program.

Fig 6 Camera
Any camera can be chosen for the video surveillance. The cameras resolution has to
be known in prior so that it can be given in the application. Better the quality of the camera
better will be the view to the user. The basic resolution which is used will be 640x480 pixels.

Dept. of CSE, PESCE, Mandya

Page 54

Home Automation System using Raspberry PI

2014-15

Another aspect which has to be looked onto is the internet speed which will have a major
influence on the streaming content. Fig 6 shows the Microsoft camera which is being used.
Breadboards and LEDs
Breadboards and a bunch of LEDs i.e. Light emitting diodes are used that can be
used to replicate the function of an actual Lighting devices in home automation system.
Router configuration
The Wi-Fi unit provides the medium for communication. It can be also configured to
make security services. The Wi-Fi should be configured with a certain address and user
commands will be directing through Wi-Fi unit. We may use sudo nano
/etc/network/interfaces for configuring Wi-Fi with raspberry-pi.
Audio configuration
The Raspberry Pi has two audio output modes: HDMI and headphone jack. You can
switch between these modes at any time.

Fig 7: Audio Configuration of Raspberry Pi device

Dept. of CSE, PESCE, Mandya

Page 55

Home Automation System using Raspberry PI

2014-15

If your HDMI monitor or TV has built-in speakers, the audio can be played over the
HDMI cable, but you can switch it to a set of headphones or other speakers plugged into the
headphone jack. If your display claims to have speakers, sound is output via HDMI by
default; if not, it is output via the headphone jack. This may not be the desired output setup,
or the auto-detection is inaccurate, in which case you can manually switch the output.
Changing the audio output

There are two ways of setting the audio output.


Command line
The following command, entered in the command line, will switch the audio output to
HDMI:
amixer cset numid=3 2
Here the output is being set to 2, which is HDMI. Setting the output to 1 switch to
analogue (headphone jack).The default setting is 0 which is automatic.
raspi-config
Open up raspi-config by entering the following into the command line:
sudo raspi-config.
This will open the configuration screen:

Fig 8: Configuration Screen 1


Select Option 8 Advanced Options and hit Enter, then select Option A6: Audio and hit Enter
Dept. of CSE, PESCE, Mandya

Page 56

Home Automation System using Raspberry PI

2014-15

Fig 9: Configuration Screen 2


Now you are presented with the two modes explained above as an alternative to the
default Auto option. Select a mode, hit Enter and press the right arrow key to exit the options
list, then select Finish to exit the configuration tool.
L293D pin configuration
L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as
current amplifiers since they take a low-current control signal and provide a higher-current
signal. This higher current signal is used to drive the motors.
L293D contains two inbuilt H-bridge driver circuits. In its common mode of
operation, two DC motors can be driven simultaneously, both in forward and reverse
direction. The motor operations of two motors can be controlled by input logic at pins 2 & 7
and 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will
rotate it in clockwise and anticlockwise directions, respectively.

Dept. of CSE, PESCE, Mandya

Page 57

Home Automation System using Raspberry PI

2014-15

Fig 10: Pin Configuration of L293D


Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to
start operating. When an enable input is high, the associated driver gets enabled. As a result,
the outputs become active and work in phase with their inputs. Similarly, when the enable
input is low, that driver is disabled, and their outputs are off and in the high-impedance state.

Pin
No
1
2
3
4
5
6
7
8
9
10
11
12

Function

Name

Enable pin for Motor 1; active high


Input 1 for Motor 1
Output 1 for Motor 1
Ground (0V)
Ground (0V)
Output 2 for Motor 1
Input 2 for Motor 1
Supply voltage for Motors; 9-12V (up to 36V)
Enable pin for Motor 2; active high
Input 1 for Motor 1
Output 1 for Motor 1
Ground (0V)

Enable 1,2
Input 1
Output 1
Ground
Ground
Output 2
Input 2
Vcc 2
Enable 3,4
Input 3
Output 3
Ground

Dept. of CSE, PESCE, Mandya

Page 58

Home Automation System using Raspberry PI


13
14
15
16

Ground (0V)
Output 2 for Motor 1
Input2 for Motor 1
Supply voltage; 5V (up to 36V)

2014-15
Ground
Output 4
Input 4
Vcc 1

Table 1: Pin description of L293D

Stepper motor
Stepper motors provide a means for precise positioning and speed control without the
use of feedback sensors. The basic operation of a stepper motor allows the shaft to move a
precise number of degrees each time a pulse of electricity is sent to the motor. Since the shaft
of the motor moves only the number of degrees that it was designed for when each pulse is
delivered, you can control the pulses that are sent and control the positioning and speed. The
rotor of the motor produces torque from the interaction between the magnetic field in the
stator and rotor. The strength of the magnetic fields is proportional to the amount of current
sent to the stator and the number of turns in the windings.
The stepper motor uses the theory of operation for magnets to make the motor shaft
turn a precise distance when a pulse of electricity is provided. You learned previously that
like poles of a magnet repel and unlike poles attract. The stator (stationary winding) has eight
poles, and the rotor has six poles (three complete magnets).

Fig 11: Stepper Motor

Dept. of CSE, PESCE, Mandya

Page 59

Home Automation System using Raspberry PI

2014-15

The rotor will require 24 pulses of electricity to move the 24 steps to make one
complete revolution. Another way to say this is that the rotor will move precisely 15 for
each pulse of electricity that the motor receives.
The number of degrees the rotor will turn when a pulse of electricity is delivered to
the motor can be calculated by dividing the number of degrees in one revolution of the shaft
(360) by the number of poles (north and south) in the rotor. In this stepper motor 360 is
divided by 24 to get 15. When no power is applied to the motor, the residual magnetism in
the rotor magnets will cause the rotor to detent or align one set of its magnetic poles with the
magnetic poles of one of the stator magnets. This means that the rotor will have 24 possible
detent positions. When the rotor is in a decent position, it will have enough magnetic force to
keep the shaft from moving to the next position. This is what makes the rotor feel like it is
clicking from one position to the next as you rotate the rotor by hand with no power applied.

GSM SIM900A

Dept. of CSE, PESCE, Mandya

Page 60

Home Automation System using Raspberry PI

2014-15

Fig 12: GSM SIM900A


GSM (Global System for Mobile) / GPRS (General Packet Radio Service) TTL
Modem is SIM900 Quad-band GSM / GPRS device, works on frequencies 850 MHZ, 900
MHZ, 1800 MHZ and 1900 MHZ. It is very compact in size and easy to use as plug in GSM
Modem. The Modem is designed with 3V3 and 5V DC TTL interfacing circuitry, which
allows User to directly interface with 5V Microcontrollers (PIC, AVR, Arduino, 8051, etc.) as
well as 3V3 Microcontrollers (ARM, ARM Cortex XX, etc.). The baud rate can be
configurable from 9600- 115200 bps through AT (Attention) commands. This GSM/GPRS
TTL Modem has internal TCP/IP stack to enable User to connect with internet through GPRS
feature. It is suitable for SMS as well as DATA transfer application in mobile phone to
mobile phone interface. The modem can be interfaced with a Microcontroller using USART
(Universal

Synchronous Asynchronous

Receiver

and

Transmitter)

communication).
Features

Quad Band GSM/GPRS : 850 / 900 / 1800 / 1900 MHz


Built in RS232 to TTL or viceversa Logic Converter (MAX232)
Configurable Baud Rate
SMA (SubMiniature version A) connector with GSM L Type Antenna
Built in SIM (Subscriber Identity Module) Card holder
Built in Network Status LED

Dept. of CSE, PESCE, Mandya

Page 61

feature

(serial

Home Automation System using Raspberry PI

2014-15

Inbuilt Powerful TCP / IP (Transfer Control Protocol / Internet Protocol) stack for

internet data transfer through GPRS (General Packet Radio Service)


Audio Interface Connectors (Audio in and Audio out)
Most Status and Controlling pins are available
Normal Operation Temperature : -20 C to +55 C
Input Voltage : 5V to 12V DC
LDB9 connector (Serial Port) provided for easy interfacing

APPENDIX B
PUBLICATION
Dept. of CSE, PESCE, Mandya

Page 62

Home Automation System using Raspberry PI

2014-15

Journal P BHASKAR RAO, S.K. UMA (Associate Professor, Department Of Computer


Science Engineering), RASPBERRY PI HOME AUTOMATION WITH WIRELESS
SENSORS USING SMART PHONE International Journal of Computer Science and Mobile
Computing (IJCSMC), Vol. 4, Issue. 5, May 2015, pg.797 803 available at:
www.ijcsmc.com

Dept. of CSE, PESCE, Mandya

Page 63

You might also like