Vous êtes sur la page 1sur 46

Chapter 1

1.1 Introduction:

For the last few years the wireless world has been bombarded daily with information
about a new generation of radio frequency(RF) technologies that would profoundly impact ,if
not revolutionize,the way we live and contact our businesses.

The wireless-networking standard technology called Bluetooth has quietly become a

common way to replace the wires on short distances. With a gadget such as a smart phone
(Android Phone) or a tablet featured with a Bluetooth module, a wireless connection is the
easiest way to send and receive information. And because this technology spread in the
prototyping culture, its often used to control things wirelessly.

This project work explains how to control the electrical appliances using an Android
device. Operating conventional wall switches is difficult for physically handicapped or elder
people. This project provides the solution to this problem by integrating all the electrical
appliances to a control unit that can be operated by an Android application device (Android
smart phone or Tablet). Proposed system controls the electrical loads based on the data
transmitted by the Android device. An android application should be installed in users
mobile or tablet to control the electrical loads. Using this android application user can send
the commands to the Bluetooth module to control the electrical loads. Wireless technology
used in this project is Bluetooth. It can also be called as Android based Home Automation
System or Remote Password Operated Electronic Home Appliances Control System.

1.2 Motivation and Background:

Bangladesh is a developing country. In fact Bangladesh is under developing

country. Still we are lagging behind from our neighboring countries. There are various

reasons for this situation. It is not possible to make change Bangladesh over night. But
if we can take and do some pragmatic job step by step then it will be possible to
transform Bangladesh into a progressive country. As a Bangladeshi civilian we should
do it.

To build Bangladesh as a progressive country we have to keep eyes and make

improve must those which are still being ignored. As an Engineer our focus firstly
goes on Improving Technology .The term Improving Technology really means a
lot to do with it. If we look a little bit on the facilities for elderly and handicapped
people of our country, we see a poor picture of their struggling life still in this modern
age of technology.

There is no statistics of buildings which have facilities and structures for the
conveniences of the elderly and people with moving disabilities. So we have tried a
little bit to facilitate their way of life using technology which really makes them feel
independent and relax. It actually eases their life style with a single touch on the
screen of a smart phone.

Lets have a look on the aim of this project from technological point of view. If we
think how cool it would be if we are able to control our AC appliances just with a
touch of our Android smart phone. All we need to tap on our phone and we can easily
switch ON/OFF our lights, fans and other home appliances. AVR micro-controllers
provide a great platform to build such interesting projects and we have used
ATMEGA32 micro-controller which is based on AVR.

Why prefer Bluetooth??

1. Its Secured.
2. Easy to use.
3. It works in short distance range (i.e. up to 10mtrs.)
4. Anyone can find free blue tooth apps on android and many more.

Another joking reason of making such a project would be simple because some of us
are way too lazy and want to control things sitting at one place. Don't want always to
get up to the switch boards just to switch things ON and OFF.

Chapter 2

2.1 Project outline:

Chapter 2 briefly outlines the working principle of the project with associated block
diagrams to facilitate the understanding of rest of the project work.

In chapter 3 detail descriptions of each and every component are discussed with
necessary working principle, circuitry, block diagrams and pin diagrams.

Chapter 4 introduces the simulation software required for the project. This chapter
also explains the software features and uses in the project with associated sample

In chapter 5 ,the coding of the circuit and simulation of the main control circuit is
introduced. Here it is also showed with screenshots that coding is successfully
compiled or not on software.

Chapter 6 contains Experiment and results of the hardware implementation. We have

also discussed on the limitations of the project circuit.

Basides limitations there are many advantages of the project and the last chapter 7 of
this paper contains the applications, advantages and related works of the project. It
also attaches the references from where we have collected some ideas and outlines of
this projects.

2.2 Brief description of working principle:

This project is a fine combination of Android mobile technology and embedded
system. User can control Home appliances using Android mobile. An application
should be installed on his/her Android mobile handset to control various home
appliances. User can send commands using that application. Wireless controlling
technique used in this project is Bluetooth technology. This project consists Bluetooth
receiver. This Bluetooth device is connected to the circuit which has a decoder. This
decoder sends code for respective command sent by user. Then the respective device
connected to the circuit will be turned on or off depending on the command given.

2.3 Functional Block Diagram:

Block Diagram:

Real life Functional block diagram

So from the above description and two block diagrams its very clear that which
components are required for hardware implementation of this project.

Now we can enlist the necessary equipments on the following section.

2.4 Required Equipments:

This project mainly consists of following blocks:

Atmega32 microcontroller
Bluetooth Module HC05
Relay(5V DC SPDT Relay)
BC 547 transistor
Android phone
Bluetooth controller app Android app
1k resistor
7805 Power Supply circuit

This chapter briefly describes the fundamental components with associated images,
pin diagrams and also explains internal configurations. It also explains the main
functioning of these equipments.

Chapter 3
3.1 Microcontroller

Before describing the components of the project a question arises on our mind that
what is Microcontroller? So lets start answering this question.

A device which includes a central processing unit (CPU), memory, and (generally)
an assortment of I/O peripherals (UART, ADC, DAC, general-purpose I/O, I2C, etc.)
in a tightly-coupled standalone package.

ATmega32 microcontroller
The ATmega32 is a low-power CMOS 8-bit microcontroller based on the AVR
enhanced RISC architecture. By executing powerful instructions in a single clock
cycle. The ATmega32 achieves throughputs approaching 1 MIPS per MHz allowing the
system designer to optimize power consumption versus processing speed.

3.1.1 Features :

High-performance, Low-power AVR 8-bit Microcontroller

Advanced RISC Architecture
131 Powerful Instructions Most Single-clock Cycle Execution
32 x 8 General Purpose Working Registers
Fully Static Operation
Up to 16 MIPS Throughput at 16 MHz
On-chip 2-cycle Multiplier

Nonvolatile Program and Data Memories

32K Bytes of In-System Self-Programmable Flash

Endurance: 10,000 Write/Erase Cycles

Optional Boot Code Section with Independent Lock Bits

In-System Programming by On-chip Boot Program

True Read-While-Write Operation

1024 Bytes EEPROM
Endurance: 100,000 Write/Erase Cycles
2K Byte Internal SRAM
Programming Lock for Software Security

JTAG (IEEE std. 1149.1 Compliant) Interface

Boundary-scan Capabilities According to the JTAG Standard
Extensive On-chip Debug Support
Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface

Peripheral Features
Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Real Time Counter with Separate Oscillator
Four PWM Channels
8-channel, 10-bit ADC

8 Single-ended Channels
7 Differential Channels in TQFP Package Only
2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
Byte-oriented Two-wire Serial Interface
Programmable Serial USART
Master/Slave SPI Serial Interface
Programmable Watchdog Timer with Separate On-chip Oscillator
On-chip Analog Comparator

Special Microcontroller Features

Power-on Reset and Programmable Brown-out Detection
Internal Calibrated RC Oscillator
External and Internal Interrupt Sources
Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby
and Extended Standby

I/O and Packages

32 Programmable I/O Lines
40-pin PDIP, 44-lead TQFP, and 44-pad MLF

Operating Voltages
2.7 - 5.5V for ATmega32L
4.5 - 5.5V for ATmega32

Speed Grades
0 - 8 MHz for ATmega32L
0 - 16 MHz for ATmega32

Power Consumption at 1 MHz, 3V, 25 C for ATmega32L

Active: 1.1 mA
Idle Mode: 0.35 mA
Power-down Mode: < 1 A

3.1.2 Pin configuration

Fig.3.1.1 Atmega32 Microcontroller IC

Fig.3.1.2 pin diagram of Atmega32 IC

3.1.3 Pin Descriptions

VCC Digital supply voltage

GND Ground

Port A (PA7.. PA0) :

Port A serves as the analog inputs to the A/D Converter.

Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not
Port pins can provide internal pull-up resistors (selected for each bit).
The Port A output buffers have symmetrical drive characteristics with both high
sink and source capability.
When pins PA0 to PA7 are used as inputs and are externally pulled low, they will
source current if the internal pull-up resistors are activated.
The Port A pins are tri-stated when a reset condition becomes active, even if the
clock is not running.

Port B (PB7.. PB0) :

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected
for each
The Port B output buffers have symmetrical drive characteristics with both high
and source capability.
As inputs, Port B pins that are externally pulled low will source
current if the pull-up resistors are activated.
The Port B pins are tri-stated when a reset
condition becomes active, even if the clock is not running.

Port C (PC7..PC0) :

Port C is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each
The Port C output buffers have symmetrical drive characteristics with both
high sink
and source capability.
As inputs, Port C pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port C pins are tri-stated when
a reset
condition becomes active, even if the clock is not running.
If the JTAG interface is enabled, the pull-up resistors on pins PC5(TDI),
PC3(TMS) and PC2(TCK) will be activated even if a reset occurs.
The TD0 pin is tri-stated unless TAP states that shift out data are entered.

Port D (PD7..PD0) :

Port D is an 8-bit bi-directional I/O port with internal pull-up resistors

(selected for each
The Port D output buffers have symmetrical drive characteristics with both
high sink
and source capability.
As inputs, Port D pins that are externally pulled low will source current if the
pull-up resistors are activated.
The Port D pins are tri-stated when a reset condition becomes active, even if
the clock is not running.

Reset Input. A low level on this pin for longer than the minimum pulse length
will generate a reset, even if the clock is not running.
Shorter pulses are not guaranteed to generate a reset.

Input to the inverting Oscillator amplifier and input to the internal clock
operating circuit.

Output from the inverting Oscillator amplifier.


AVCC is the supply voltage pin for Port A and the A/D Converter. It should be
externally connected to VCC, even if the ADC is not used. If the ADC is used, it
should be connected to VCC through a low-pass filter.

AREF is the analog reference pin for the A/D Converter.

Why we have chosen Atmel AVR based microcontroller over others microcontroller?

There are many others Family of Microcontrollers but we have used AVR based
microcontroller for the above reasons.

The AVR family has a lot of good, inexpensive, hobbyist-friendly devices with
nice peripherals, low power consumption, and good cross-platform support.

Good: They work well. Easy to program in C for most basic functions. Adequate
Inexpensive: Lots of $3-$5 parts, available from major distributors in small
Hobbyist friendly: Parts in through-hole packages-- a big contrast to many of
the chip families out there today. Newer AVR (e.g., xmega) devices are less so.
Nice peripherals: Built-in oscillator, flash memory, on-board RAM, serial ports,
ADC, EEPROM, and the other goodies that make it possible to run a single
MCU on a protoboard to do basic stuff, without too much hassle.
Low power consumption. AVR's major pitch point these days. Suckers can run
on a battery almost forever if you know what you're doing.
Good cross-platform support: The AVR was designed with C support in mind--
not as an afterthought. GCC support came early, and a big open source
community developed around that. It's still one of the best MCUs that you can
develop from any platform with free tools. This is a big one with respect to the
other families, many of which use proprietary compilers or have lackluster gcc
support. Even PIC was pretty late to the game with good free C compilers.

3.2 Bluetooth Module HC -05

The Bluetooth module used in this project is HC-05 V1.02 .HC-05 module is an easy to
use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless
serial connection setup.

Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data
Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It
uses CSR Bluecore 04-External single chip Bluetooth system with CMOS technology
and with AFH(Adaptive Frequency Hopping Feature). It has the footprint as small as
12.7mmx27mm. Hope it will simplify your overall design/development cycle.

3.2.1 Hardware Features

Typical -80dBm sensitivity

Up to +4dBm RF transmit power
Low Power 1.8V Operation ,1.8 to 3.6V I/O
PIO control
UART interface with programmable baud rate
With integrated antenna
With edge connector

Fig.3.2.1 pin configuration Bluetooth Module HC-05

Fig.3.2.2 PCB connection of HC-05 module IC

3.2.2 Software Features

Default Baud rate: 38400, Data bits:8, Stop bit: 1,Parity:No parity.
Supported baud rate: 9600,19200,38400,57600,115200,230400,460800.
Given a rising pulse in PIO0, device will be disconnected.
Status instruction port PIO1: low-disconnected, high-connected.
PIO10 and PIO11 can be connected to red and blue led separately. When master
and slave are paired, red and blue led blinks 1time/2s in interval, while
disconnected only blue led blinks 2times/s.
Auto-connect to the last device on power as default.
Permit pairing device to connect as default.
Auto-pairing PINCODE:0000 as default .
Auto-reconnect in 30 min when disconnected as a result of beyond the range of

3.3 Relay
3.3.1: What are relays ?

A relay is an electromagnetic switch operated by a relatively small electric

current that can turn on or off a much larger electric current. The heart of a
relay is an electromagnet (a coil of wire that becomes a temporary magnet
when electricity flows through it).

We can think of a relay as a kind of electric lever : switch it on with a tiny

current and it switches on ("leverages") another appliance using a much bigger

Why is that useful? As the name suggests, many sensors are incredibly sensitive
pieces of electronic equipment and produce only small electric currents. But
often we need them to drive bigger pieces of apparatus that use bigger currents.

Relays bridge the gap, making it possible for small currents to activate larger
ones. That means relays can work either as switches (turning things on and off)
or as amplifiers (converting small currents into larger ones).

3.3.2 Pin configuration of relay

The relay switch connections are usually labeled as COM ,normally closed (NC)
and normally open (NO).

COM/POLE= Common, NC and NO always connect to this, it is the moving

part of the switch. NC = Normally Closed, COM/POLE is connected to this
when the relay coil is not magnetized. NO = Normally Open, COM/POLE is
connected to this when the relay coil is MAGNETIZED and vice versa.

General purpose relays operate with AC or DC current, at common voltages

such as 12V, 24V, 48V, 120V and 230V, and they can control currents ranging from 2A-
30A. These relays are economical, easy to replace and allow a wide range of switch

1,3= Coil connected Pins

2= Movable contact

2,5= Normally Closed

2,3= Normally open

Fig.3.3.1 Pin configuration of relay

It is seen that there is coil between
pin 1 & 3.
If the coil is not drawn there, then
another way to understand the coil
connected pins is to put a ohm
meter across pin 1 and 3 and observe
the resistance between these 2 pins.
The resistance is too low in this
point as it is only 2 ends of a coil.

Fig:3.3.2 Pin Description of relay

3.3.3 Testing of NC/NO connection

To understand the normally close and normally open connection we need a voltmeter.
And it should be set in the diode mood.

Fig.3.3.3 When the voltmeter is connected Fig.3.3.4 When the voltmeter is connected
across pin 2 & 5 is seen the voltage across it is across pin 2 & 4 is seen the voltage across it is
ZERO.which means they are shorted. ZERO.which means they are OPEN.

3.3.4 How relays work
Here are two simple animations illustrating how relays use one circuit to switch on a
second circuit.When power flows through the first circuit (1), it activates the
electromagnet (brown), generating a magnetic field (blue) that attracts a contact (red)
and activates the second circuit (2). When the power is switched off, a spring pulls the
contact back up to its original position, switching the second circuit off again.

Fig.3.3.5 Switching on the second circuit. Fig.3.3.6 Switching off the first circuit.

This is an example of a "normally open" (NO) relay: the contacts in the second circuit
are not connected by default, and switch on only when a current flows through the
magnet. Other relays are "normally closed" (NC; the contacts are connected so a
current flows through them by default) and switch off only when the magnet is
activated, pulling or pushing the contacts apart. Normally open relays are the most

Here's another animation showing how a relay links two circuits together. It's
essentially the same thing drawn in a slightly different way. On the left side, there's an
input circuit powered by a switch or a sensor of some kind. When this circuit is
activated, it feeds current to an electromagnet that pulls a metal switch closed and

activates the second, output circuit (on the right side). The relatively small current in
the input circuit thus activates the larger current in the output circuit:

Fig. 3.3.7 Animation of relay on-off switching circuit

So this is the main working principle of relay which we have discussed elaborately
with associated circuitry. Now the question is that how the relay is driven? Answer
sounds simple .The relay requires a driving circuitry using Transistor. So the next topic
will be on Relay Driving Circuitry.

3.3.5 How to drive a relay using Microcontrollers

This post will outline how we can drive a relay using micro-controllers like AVR.
Concepts are same for any other micro-controller too. Working principle of relay have
been already discussed.So now we can come to the point.

Before you connect a relay to a microcontroller, you need to first make a few decisions.
Key ones are listed below:

1. What will be connected to the relay output and how much current is required for
the relay output.

2. How much current is required to energize the relay and what is the voltage rating.

The voltage and current required to energize the relay should be in range (e.g. 5V DC
12 VDC). We should pick the ones that can run on 5V (since we can use the same
power supply as microcontroller). Most relays we have come across are rated 6V, but
work fine on 5V too.

In our project the relay which we have used is rated as 5VDC, 5A. This means, that the
coil needs about 5V to energize can take a load current of upto 5A. One question
remains, how much current is required to energize the relay. Some sellers will write

the Coil Rated Current else we have to check the datasheet. The rated coil current
for this model as per the datasheet was about 40mA. Therefore, we need to provide 5V
DC and a flow of about (max.) 40mA should be enough to energize the relay.

This is where, the next item comes is a power transistor. We will use a transistor as a
driver to provide the required current to the relay. Ensure that the ratings of the
transistor, far exceed the coil ratings of the relay (meaning, the CE voltage must be
much larger than 5V DC and the collector current must be much larger than 40mA).

3.3.6 How to create the driver circuit

Once such transistor is BC 547. We will use this transistor as a switch. The
microcontroller will provide the on/off signal to the base of this transistor. This
transistor will be driven to saturation and full current will start to flow. The picture
below outlines the circuit.

Fig.3.3.8 Relay driver Circuit

The transistor collector is connected to the relay coil. The transistor base is driven
by a microcontroller pin. When the microcontroller wants to switch on the relay, it
provides 5V (logic high) at its output pin. The output pin is connected to the base of
the transistor. The transistor goes into saturation and current starts to flow from Vcc
to ground (logically) via the coil and the transistor (CE). This energizes the relay and
point C now switches and connects to point A, completing the LED circuit.

If no signal is present, then the transistor is cut-off, no current flows through the
relay coil and thus, point C is in contact with point B, keeping the LED off.

3.3.7 How to calculate component values

One crucial aspect to note here is what is the value of the resistor R. Consider it
this way, if you are driving the point M in Fig 3 from a microcontroller that works on
5V (as these days, they also work on 3.3 V), then the drop across the resistance is 5V
0.7V = 4.3 V (0.7 V drops across BE of the transistor).

If the hFE of the transistor (typical value) is 9.3 (from the datasheet of our transistor
for this), then it means, that based current is amplified 9 times and that is the current
flows in the collector. Now, for the given relay, we need about 40mA. Therefore, the
base current should be:

Ib = IC/9
Inserting the values we get Ib = 40 mA/9
Or Ib = 4.3 mA

Now, you need 4.3 mA across 4.3 V, which translates to a resistance of about 1k
Final point 0.2 mA is what is needed at the base and that should be sourced from the
microcontroller. Any microcontroller will be able to deliver this !

So now following topic will briefly describe the BC547 transistor .

3.4 BC547 Transistor

BC547 is an NPN bi-polar junction transistor. A transistor, stands for transfer of
resistance, is commonly used to amplify current. A small current at its base controls a
larger current at collector & emitter terminals.

BC547 is mainly used for amplification and switching purposes. It has a maximum
current gain of 800. Its equivalent transistors are BC548 and BC549.

The transistor terminals require a fixed DC voltage to operate in the desired region of
its characteristic curves. This is known as the biasing. For amplification applications,
the transistor is biased such that it is partly on for all input conditions. The input
signal at base is amplified and taken at the emitter. BC547 is used in common emitter
configuration for amplifiers. The voltage divider is the commonly used biasing mode.

For switching applications, transistor is biased so that it remains fully on if there is a
signal at its base. In the absence of base signal, it gets completely off.

3.4.1 Pin Diagram:

Fig.3.4.1 Pin diagram of BC547 transistor IC

3.5 Android Phone/Smart Phone

The main hardware component on which the whole project is dependent is
nothing but an Android Phone. So now the question is what special feature an android
phone can provide us to automate home appliances?

An Android phone is a smartphone running on Google's open-source Android

Operating system. Many different manufacturers make Android phones, including
HTC, Motorola, and Samsung. Dozens and dozens of different Android phones are
now available.

With over 1 billion Android devices already activated, Android represents an

incredible opportunity for developers. Developers develop Android Apps which can be
easily run using Android Mobile and its the main functioning of Android Phone in our

Now we can come to the point that how an Android App can be developed. The next
topic will elaborately describe the procedure of developing an android app with proper

3.6 Bluetooth controller apps (Android apps)

The procedure of developing Bluetooth controller apps (Android Apps) is illustrated
in this article .

The steps are stated as follows :

1. Getting started with MIT App Inventor 2 through browsing.

2. Create Apps using ones itself email id.

3. Then create new project importing .aia file from pc/laptop.

4. The code is either built in or someone can develope himself/herself learning

tutorial of developing Android apps through Browsing.

The following diagram illustrates the steps accordingly stated above.

Step 1:

Step 2 :

Step :3

3.7 BULB
A 60W bulb has been used as a test light in our project to observe wheather the circuit
works or not .

Fig.3.7.1 Test Bulb (60W) used in the project

3.8 HOlDER
To hold the bulb a holder made of plastic on the outside has been used in the circuit.

Fig.3.8.1 Holder

3.9 Resistor
In this project resistors has been used mainly for limiting the base current thus biasing
the transistor BC547.

1k resistors has been used to drive 4 different loads (2 lights,2 fans).

Fig 3.10.1 1k Resistor used in the circuit .

3.10 Power Supply

Five volts power supply w.r.t ground is needed for the operation of the
microcontroller. Fig 3.11.1 shows the schematic of the power supply used by the

Fig.3.11.1 7805 power supply circuit

Chapter 4
To successfully complete the task of Hardware implementation ,Software simulation
is required greatly.

What actually Software simulation facilitates? Now we can come to the point.

Simulation software is based on the process of modeling a real phenomenon with a set
of mathematical formulas. It is, essentially, a program that allows the user to observe
an operation through simulation without actually performing that operation.

If we think professionally that using software simulations, one can show their
customer how everything works in his/her program. Also he/she can make it
interactive, clients will be able to take a closer look at the features that interest them

In our project we have mainly used Proteus version 8 as Simulation Software. Other
associated required software along with it are stated below.

4.1Circuit Software Requirements:

Atmel Studio 7 software

4.1.1 Proteus version 8

Proteus ISIS is the best simulation software in the world for various designs with
electronics & microcontroller. It is mainly popular because of availability of almost all
microcontrollers in it. So it is a handy tool to test programs and embedded designs for
electronics hobbyist & expert. We can simulate our programming of microcontroller
in Proteus 8 Simulation Software. After simulating our circuit using Proteus Software
we can directly make PCB design with it so it could be an all in one package for
students and hobbyists.


For an example we can observe a simple circuit of Led Brightness control

in Proteus Simulation software. So lets see how it works. A screenshot of such
schematic simulation is shown here.

Led Brightness Control using Microcontroller

Fig.4.1.1 Simulation circuit in Proteus of

4.1.2 Atmel Studio 7 software

Atmel Studio 7 is the integrated development platform (IDP) for developing and
debugging Atmel SMART ARM-based and Atmel AVR microcontroller (MCU)
applications. Studio 7 supports all AVR and Atmel SMART MCUs. The Atmel Studio 7
IDP gives you a seamless and easy-to-use environment to write, build and debug your
applications written in C/C++ or assembly code. It also connects seamlessly to Atmel
debuggers and development kits.

Additionally, Atmel Studio includes Atmel Gallery, an online apps store that allows
you to extend your development environment with plug-ins developed by Atmel as
well as by third-party tool and embedded software vendors. Atmel Studio 7 can also
able seamlessly import our Atmega32 sketches as C++ projects, providing a simple
transition path from Maker space to Marketplace.

Key Features
Support for 300+ Atmel AVR and Atmel SMART ARM-based devices
Vast source code library, including drivers, communication stacks, 1,600+
project examples with source code, graphic services and touch functionality
through Atmel Software Framework (ASF)
IDE extensions through Atmel Gallery, the online apps store, for development
tools and embedded software from Atmel and third parties
Tune capacitive touch designs, validate system performance, monitor power
consumption, and real-time data and trace graphing with Atmel QTouch
Configure and test the performance of wireless designs with the Wireless
Composer running on the target
Write and debug C/C++ and assembly code with the integrated compiler
Advanced debugging features include complex data breakpoints, nonintrusive
trace support (SAM3 and SAM4 devices), statistical code profiling, interrupt
trace/monitoring, polled data tracing (Cortex-M0+ devices), real-time variable
tracking with optional times tamping, and integration of Percepio Tracealyzer
for leading-edge debug data visualization and RTOS awareness
Integrated editor with visual assist
New project wizard allowing projects created from scratch or from a large
library of design examples
In-system programming and debugging provides interface to all Atmel in-
circuit programmers and debuggers
Create transparent debug views into CPU and peripherals for easy code
development and debugging
Full chip simulation for an accurate model of CPU, interrupts, peripherals, and
external stimuli

Chapter 5
From the previous chapter we have already come to know the details of each hardware
components regarding in this project. We have also observed the procedure of
executing software simulators too. So now we have a rough idea about the project .
Lets focus on the detail view.

In this chapter we are going to explain elaborately the whole procedure of

implementing the project step by step with associated circuit diagram and algorithm.

5.1 Bluetooth Operated Electronic Home Appliances Control

Circuit Principle

In this project Bluetooth module HC-05 is interfaced to ATmega32 microcontroller.

This Bluetooth receives the commands from the Android application device using
wireless communication. The program which is written to the ATmega32
microcontroller communicates with Bluetooth module serially to receive the
commands. Microcontroller switches the electrical loads automatically based on the
commands received from the Bluetooth.

5.2 Android Based Home Automation System Circuit Block Diagram

Fig.5.2.1 Block diagram of Home Automation System using Android Apps

5.3 Proposed Circuit of Android Based Home Automation Project

Fig.5.3.1 Proposed circuit

5.4 Android Based Home Automation System Circuit Design

This project consists of a microcontroller, three 5V relays, two lamps, a DC motor and
Bluetooth module. Here Atmega32 microcontroller is used. It is an 8 bit
microcontroller and it requires supply voltage of 5V DC. Use 7805 power supply circuit
to provide 5V DC to the microcontroller showed in Fig.3.11.1. We can use 9V DC
battery or 12V, 1A adapter to provide the supply to the circuit. For the above circuit
additionally it needs to connect reset circuit and crystal circuit to the controller to
work properly.

Bluetooth module TX and RX pins are connected to the RXD and TXD pins of
controller. Vcc pin is connected to the 5V and GND pin is connected to ground.
Controller communicates with Bluetooth module using serial communication (UART
protocol). Use a baud rate of 9600 to communicate with Bluetooth. If anyone wants to
change the Bluetooth name and password then he/she needs to use Bluetooth AT

Below are the few Bluetooth AT commands:

AT Responds OK. (Used to test the Bluetooth module)

AT+RESET Responds OK. (Used to reset the module)
AT+NAME? Responds with the module name.
AT+NAME = <name> Responds OK. Name should be less than or equal to 20
AT+PSWD? Responds with the existing password.
AT+PSWD =<password> Sets module pairing password.

AT Responds OK. (Used to test the Bluetooth module)

AT+RESET Responds OK. (Used to reset the module)
AT+NAME? Responds with the module name.
AT+NAME = <name> Responds OK. Name should be less than or equal to 20
AT+PSWD? Responds with the existing password.
AT+PSWD =<password> Sets module pairing password.

Electrical loads (Lamp and DC motor) are connected to the P2.1 and P2.0 through the
relays. Here relays are used to switch AC loads using small DC voltages. NPN
transistors are used to drive the relays.

5.5 Home Appliances Control Project Algorithm

1. Initialize UART protocol.

2. Now read the data from Bluetooth module.
3. Compare the received string with predefined strings and accordingly switch the
electrical loads.

Very simple Algorithm! But still now a lot of works have to be done before
implementation of hardware or real life control circuit.

To write a program on Atmel Studio7 and create a hex file.

Then Need to check the circuit design on Proteus Simulation Software.
If software runs successfully we can finally implement the hardware.
Test the circuit using Led Bulbs
Then connect to the main control board of our home and lastly
Enjoy the Apps .

5.5.1 Program Code on Atmel Studio 7

#include <avr/io.h>

#include "UART.h"

#include "Servo_16_BitPWM.h"

#include <util/delay.h>

int main(void)

MCUCSR|= (1<<JTD);// disable JTAG

MCUCSR|= (1<<JTD);//JTAG interface shares PC2, PC3, PC4 and PC5 of


// To use these four pins for general I/O operations, JTAG must be disabled.


DDRA |=0xff;

DDRD |=1<<PD6;

unsigned char byte_received;

uart_init(); //Initialize UART communication

Servo_init();//Initialize PWM for servo


PORTA |=1<<PA7;

if ((UCSRA) & (1<<RXC))



USART_Flush(); //After receiving one byte FIFO buffer is cleared

switch (byte_received)

case 1 :

PORTA |= 1<<PA0;


case 2 :

PORTA &=~(1<<PA0);


case 3 :

PORTA |= 1<<PA1;


case 4 :


PORTA &=~(1<<PA1);


case 5 :

PORTA |= 1<<PA2;


case 6 :

PORTA &=~(1<<PA2);


case 7 :

PORTA |= 1<<PA3;


case 8 :

PORTA &=~(1<<PA3);


case 9 :

PORTA |= 1<<PA4;


case 10 :

PORTA &=~(1<<PA4);


case 11 :

PORTA |= 1<<PA5;


case 12 :

PORTA &=~(1<<PA5);




if (received_byte==1)

PORTC |=1<<PC1;

PORTC |=1<<PC0;

PORTC |=1<<PC3;

else if(received_byte==2)

PORTC &=~(1<<PC1);

PORTC &=~(1<<PC0);

PORTC &=~(1<<PC3);


}//end of switch

}//end of if

}//end of while

return 0;

5.5.2 Run Program on Atmel Studio 7

Fig.5.5.2 Program screenshot on Atmel Studio

Fig 5.5.3: Program successfully compiled

Its now just time to check the circuit design using a simulation software.As our
program is successfully compiled now we can create a hex file which is the prerequisite
for both simulation and hardware implementation.

5.5.3 Software Simulation On Proteus

We can now simulate the Home Appliances Control Circuit on Proteus Version 8
Software. The screenshot of Simulation circuit is attached here too.

Fig. 5.5.1 Simulation Circuit

We have already come to the end. The next topic will be on the Experiment and
Result of the project circuit illustrated on the following chapter.

Chapter 6:
We have finally reached our goal. we have to implement the hardware as all
equipments are at our hand. So in a nutshell the whole procedure is as follows :

6.1 How Bluetooth Controlled Electronic Home Appliances Circuit


1. Write the program to the Atmel Studio 7 software and create .hex file.
2. Burn program to the controller with help of flash magic.
3. Now give the connections as per the circuit diagram.
4. While making the connections, ensure that there is no any common connection
between DC and AC supplies.
5. Use 7805 power supply circuit to provide regulated 5V DC to the
6. Switch on the both AC and DC supplies.
7. Now relay output pins gets 220V so do not touch the load connected pins.
8. Install Bluetooth apk file in android device.
9. Now pair android device with Bluetooth module.
10. Send data to switch on the electrical loads.

Experiment : Steps are stated below with associated screenshots .Step 1 and 2 are
already explained in the previous chapter.

Step 3: Circuit Connection

Step 4: Bluetooth Connection

Connection established

Controlling 60W bulb (Light1)

Controlling another Device (Light/Fan/Door)

6.2 Results
Finally we have successfully implemented the circuit. Now it has to be
synchronized to the main control circuit board at our home. 32 different types of
loads can controlled using this device.

6.3 Limitations of this Project Circuit

In this project the distance between control unit and android device is limited. As
bluetooth technology works only for short range say 10m.
Only Android/Smart phone supports this Android App. So normal multimedia,
windows phone cant activate this apps thus they are not benefited anyway.
Manual Switch should be changed otherwise ambiguous situation may result .
Say someone wants to switch off the fan, he/she touches the option F1 on apps.
The fan switches on but whats about the switch of the main control board? Is it
still off or on? We have to solve this problem using SPDT switch.

Chapter 7
We have already observed the experiments and discussed about the results of the
project circuit. Limitations of the circuit have also explained too. Nevertheless this
circuit has also some advantages, future scope of improvement and now we are going
to focus on it.

7.1 Bluetooth Controlled Electronic Home Appliances Project

Applications & Advantages :

Home automation - This project can be used to control various devices in the
Can also be used for security purpose after modification (we can control gate
system or we can interface wireless camera and can control it using our mobile)
Can control device from a long distance, thus it gives ease of access.
Faster operation and efficient.
No need to carry separate remote or any other controlling unit.
Using this project we can control all the loads using a single touch on a
Android based handset.

7.2 Future Plan Based on this project

We have successfully developed the Bluetooth controlled Home Appliances System.

Which has few limitations due to short range of bluetooth technology. The activation
of this controlling requires ones presence at home. Isnt it too good if we can control
light, fan,ac of our home sitting in our office??

Ya, answer is here. Our next plan is The development of Global System for Mobile
Communication(GSM)-based home appliance control for smart home system. The
main aim of the prototype development will be to reduce electricity wastage. GSM
module is used for receiving short message service (SMS) from users mobile phone
that automatically enable the controller to take any further action such as to switch
ON and OFF the home appliances such as light, air-conditioner etc. The system will be
integrated with microcontroller and GSM network interface using embedded C
language. MicroC software can be utilized to accomplish the integration. The system
will be activated when user sends the SMS to controller at home. Upon receiving the

SMS command, the microcontroller unit then automaticallyll control the electrical
home appliances by switching ON or OFF the device according to the user direction.
In other words, itll read message from the mobile phone and respond to control the
devices according to the received message. The prototype can be successfully
developed and implemented as it seems as like as the recent one. It can provide an
effective mechanism in utilizing the energy source efficiently.


In conclusion, this low cost system is designed to improve the standard living in home.
The remote control function by smart phone provides help and assistance especially to
disabled and elderly. In order to provide safety protection to the user, a low voltage
activating switches is replaced current electrical switches. Moreover, implementation
of wireless Bluetooth connection in control board allows the system install in more
simple way. The control board is directly installed beside the electrical switches
whereby the switching connection is controlled by relay. Furthermore, flexible types of
connections can be designed as backup connections to the system. The connected
GUIs(Graphical User Interface) are synchronized to the control board. They indicate
the real-time switches status. The system is designed in user-friendly interface. The
easy to use interface on Window and Android GUI provides simple control by the
elderly and disabled people. For future work, GSM technology based Home
Automation can be developed which has been already discussed in the previous
section. All the future work is expected without spending extra cost, makes sure of
safety and security too.

Related Works :
There are many related works . we can enlist them as follows :

1. Remote Control operated Home Automation System with microcontroller.

2. Remote Control operated Home Automation System without microcontroller.

3. Cellular phone controlled Home Automation System without microcontroller.

4. GSM technology based Home Automation System with microcontroller.

[1] J. Mander, and D. Picopoulos, Bluetooth Piconet Applications.
[2] R. Piyare, and M. Tazil, Bluetooth Based Home Automation System using Cell
Phone, in Consumer Electronics, pp. 192-195, 2011.
[3] Kailash Pati Dutta, Pankaj Rai, and Vineet Shekher, Microcontroller Based Voice
Activated Wireless Automation System in Proc. VSRD-IJEE,
[4] https://developer.android.com/guide/topics/connectivity/bluetooth.html


[3] http://circuitdigest.com/microcontroller-projects/bluetooth-controlled-home-

[6] http://www.electronicshub.org/bluetooth-controlled-electronic-home-appliances/

[7] http://www.projectsof8051.com/home-appliances-controlling-using-android-

[8] http://www.datasheetcatalog.com/datasheets_pdf/A/T/M/E/ATMEGA32.shtml


[10] https://vsblogs.wordpress.com/2014/03/02/how-to-drive-a-relay-using-


[13] http://www.electronicshub.org/mobile-controlled-home-appliances-without-

[14] http://www.circuitsgallery.com/2015/04/bluetooth-android-home-