You are on page 1of 10

CHAPTER THREE

3.0 DESIGN AND IMPLEMENTATION

3.1 Introduction

This chapter presents the various methods used in developing the android controlled appliance

using GSM and Bluetooth for home automation. The steps taken in designing the system were

in two phases; the first phase is the design of the relay switching system, interfacing of GSM

to the system to receive control commands from the android phone from far distances and

interfacing of Bluetooth with the system to receive control commands from near distances. The

second phase was the design of the android application that sends control to the system via

Bluetooth.

The materials used in the whole system are:

1. Atmega328P Microcontroller

2. GSM800L module

3. Bluetooth module

4. LCD display

5. Power supply unit

6. Relay

7. Android phone

3.2 Relay Switching Circuit Design

The switching circuits consists of different components working together to achieve the

purpose of switching ON and OFF the appliances based on the control commands received

from the GSM and Bluetooth and display the status of the whole system through the LCD

display in the
The relay switching circuit is the circuit that switch ON and OFF the appliances connected to

circuit. The switching circuit showing how these component are interconnected to achieve the

purposes above is shown in Figure 3.1

Figure 3.2. Switching circuit diagram

3.2.1 Relay

The relay is an electrical switch that uses an electromagnet to mechanically operate a like a

switch, other operating principles are employed too such as SSR (Solid State Relays). Relays

are made use of in circuits where it is necessary to separate low-power signal, or where several

circuits need to be controlled by just one signal. Relays were primarily used in telephone

exchanges and early computers to perform logical operations.

A simple relay consists of a coil of wire wrapped around a soft iron core, an iron yoke which

provides a low reluctance path for magnetic flux, a movable iron armature, and one or more
sets of contacts. When an electric current is passed through the coil, it generates a magnetic

field that activates the armature, and the consequent movement of the movable contacts(s)

either makes or breaks a connection with a fixed contact. If the contacts were in contact before

the current was passed through it, they are separated and one contact may now be connected to

another contact and vice versa. A picture of a latching magnetic relay is shown in Figure 3.1.

Figure 3.2. Latching Magnetic Relay

The relays used in the relay switching circuit is a 5V, 240V magnetic relay. This is a low power

and efficient relay.

3.2.2 Liquid Crystal Display (LCD)

A liquid crystal display is a flat-panel display which uses light-modulating properties of liquid

crystals to display data in printed forms. Liquid crystals do not emit light directly. LCDs are

available to display arbitrary images (as in a general-purpose computer display) or fixed images

with low information content, which can be displayed or hidden, such as preset words, digits,

and 7-segment displays, as in a digital clock.

LCDs are used in a wide range of applications including computer monitors, televisions,

instrument panels, aircraft cockpit displays, and indoor and outdoor signage. Small LCD
screens are common in portable consumer devices such as digital cameras, watches,

calculators, and mobile telephones, including smartphones. LCD screens are also used on

consumer electronics products such as DVD players, video game devices and clocks. LCD

screens have replaced heavy, bulky cathode ray tube (CRT) displays in nearly all

applications. LCD screens are available in a wider range of screen sizes than CRT and plasma

displays, with LCD screens available in sizes ranging from tiny digital watches to huge, big-

screen television set.

LCD module was employed in this project to display the status of appliances and the mode

through which the last command was received. A LCD module is shown in Figure 3.3

Figure 3.3 LCD Module

3.2.3 Atmega328 Microcontroller

The Atmel 8-bit AVR RISC-based microcontroller combines 32 kB ISP flash memory with

read-while-write capabilities, 1 kB EEPROM, 2 kB SRAM, 23 general purpose I/O lines, 32

general purpose working registers, three flexible timer/counters with compare modes, internal

and external interrupts, serial programmable USART, a byte-oriented 2-wire serial interface,

SPI serial port, 6-channel 10-bit A/D converter (8-channels in TQFP and QFN/MLF

packages), programmable watchdog timer with internal oscillator, and five software
selectable power saving modes. The device operates between 1.8-5.5 volts. The device

achieves throughput approaching 1 MIPS per MHz.

The program that controls the general behaviour of the system is burned onto an Atmega328P

microcontroller. It is written in arduino C programming language. The microcontroller

receives command from the Bluetooth and GSM and then in turn turns ON or OFF the relays

depending on the control command received. The microcontroller is also responsible for

sending status messages to the LCD module which is presented to users.

Figure 3.4. Atmega328P Microcontroller

3.2.4. GSM800L module

GSM/GPRS module is used to establish communication between a computer and a GSM-

GPRS system. Global System for Mobile communication (GSM) is an architecture used for

mobile communication in most of the countries. GSM has the capability of receiving messages,

control command is sent to the GSM module interfaced with the Atmega328 via SMS from the

android phone that controls the appliances. A figure of the GSM module employed in this

project work is shown in Figure 3.5.


Figure 3.5 GSM800L Module

3.2.5 Bluetooth module

Bluetooth is a wireless technology standard for exchanging data over short distances (using

short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz) from fixed and

mobile devices, and building personal area networks (PANs). Invented by telecom vendor

Ericsson in 1994, it was originally conceived as a wireless alternative to RS-232 data cables.

It can connect several devices, overcoming problems of synchronization.

Bluetooth is managed by the Bluetooth Special Interest Group (SIG), which has more than

25,000 member companies in the areas of telecommunication, computing, networking, and

consumer electronics. The IEEE standardized Bluetooth as IEEE 802.15.1, but no longer

maintains the standard. The Bluetooth module adopted in this project is the HC-06 that

receives data from another Bluetooth device and transfer it to the Atmega328 microcontroller

using TTL logic via a TX and RX pin. The control commands sent to the Bluetooth is in form

of String which is then analysed by the Atmega328 microcontroller and the proper control

action is carried out by the microcontroller through the relays. The Bluetooth module is

shown in figure 3.6.


Figure 3.6 Bluetooth Module

3.3 Android Application Development

Android software development is the method through which new programs are created to run

on the Android operating system. Applications for Android operating system are mostly

developed using Java programming language and the Android software development kit

(SDK), although other development environments are also available for use.

To develop an android application, an IDE (integrated development environment) which is the

platform on which the android application source code is written is needed, the written code is

then compiled and exported to an installable for users in the android .apk format.

Figure 3.1 shows a flowchart of the steps to be carried out when developing an android

application through the eclipse IDE which was used for this project.

The XML design projects all the graphical user interface (GUI) designs and the Java engine is

responsible for linking the android OS to the GUI and processing the events triggered by users

when they touch a part of the screen.


Start

Design graphical user


interface with xml

Design application
engine with java

Interface the GUI with


the java engine

Set permissions in the


manifest file

Export to
.apk file for
installation

Stop

Figure 3.7 Android development flowchart

3.3.1 Eclipse IDE

Eclipse is an integrated development environment (IDE) used in computer programming to

develop programs or applications in especially Java. It has a workspace where programs are

written and compiled to. Eclipse is developed mainly in Java and it is made primarily for

writing Java applications. Eclipse can be used to develop applications in other programming

languages such as Ada, ABAP, C, C++, COBOL, D, Fortran, Haskell, JavaScript, Julia,

Lasso, Lua, NATURAL, Perl, PHP, Prolog, Python, R, Ruby (including Ruby on Rails

framework), Rust, Scala, Clojure, Groovy, Scheme, and Erlang. The Eclipse software
development kit (SDK), which includes the Java development tools, is meant for Java

developers. Users can extend its abilities by installing plug-ins 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 application that sends control commands to the switching circuit via Bluetooth

or GSM was developed using Eclipse and the GUI of Eclipse is shown in Figure 3.8

Figure 3.8 Eclipse IDE

3.3.2 Extensible Markup Language (XML)

Extensible Markup Language (XML) is a markup language that defines a set of rules for

encoding documents in a format that is both human-readable and machine-readable. The

design goals of XML emphasize simplicity, generality, and usability across the internet. It is

a textual data format with strong support via Unicode for different human languages.

Although the design of XML focuses on documents, the language is widely used for the

representation of arbitrary data structures such as those used in web services.


The android application graphical user interface was developed using XML which makes it

readable, understandable and simple.

3.3.3 Java Programming Language

Java programming language is a general multipurpose computer programming language that is

concurrent, class-based, object oriented, and specifically designed to have as few

implementation dependencies as possible. It is popularly known as write once, run anywhere

(WORA), meaning that compiled Java code can run on all platforms that support Java without

the need for recompilation. Java applications are typically compiled to byte code that can run

on any java virtual machine (JVM) regardless of the computer architecture.

Java is the primary language that android OS supports and about 80% of all android

applications are designed using java. Java was used in this project to link the GUI to the main

application and the most important part of the application is the java source code.

Java has the capabilities of all object oriented programming languages; inheritance is a process

of inheriting variables from other classes. This paved the way for the use of libraries. A library

is a collection of non-volatile resources used by computer programs often to develop software

and they are mostly reusable since they are meant for software development. Software

developers, companies who make large scale software driven devices or applications usually

provide libraries for programmers who may want to integrate the application into his own new

application. Applications such as Facebook, Dropbox, Twitter and LinkedIn have libraries for

app developer for easy integration between several programs.

Java was used to write the classes that sends the control command to the switching circuit via

the Bluetooth or GSM on the phone on which the android application is installed.

You might also like