Arduino Based Home Automation System Using Bluetooth Through An Android Mobile PDF
Arduino Based Home Automation System Using Bluetooth Through An Android Mobile PDF
Arduino Based Home Automation System Using Bluetooth Through An Android Mobile PDF
DEPARTMENT OF PHYSICS
2015 – 2019
DEPARTMENT OF PHYSICS
2015 – 2019
CERTIFICATE
We take great pleasure to express our deep sense of gratitude to our project guide Dr.
Nauman Usmani, Assistant Professor, for his valuable guidance during the course of our
project work.
We would like to thank Prof. Dr. Javed Ahmad, Head of the Department of Physics
for his encouragement.
We would like to express our heart-felt thanks to Mr. Maqsood, for providing all the
facilities for our project.
Our utmost thanks to all the Faculty members and Non-Teaching Staff of the
Department of Physics for their support throughout our project work.
Our Family Members and Friends receive our deepest gratitude and love for their
support throughout the academic year.
List of Figures Iv
List of Tables Vi
Abbreviations Vii
Abstract Viii
CHAPTER 1. INTRODUCTION TO EMBEDDED SYSTEMS 1
1.1 Introduction 1
1.2 Description 1
1.3 Requirements 1
1.3.1 Hardware Requirements 1
1.3.2 Software Requirements 2
1.4 Embedded Systems 2
1.4.1 System Design Calls 3
1.4.2 Embedded System Design Cycle 3
1.5 Characteristics of an Embedded Systems 4
1.6 Embedded Systems Software Architecture 4
1.6.1 Simple Control Loop 4
1.6.2 Interrupt-Controlled System 4
1.6.3 Cooperative Multitasking 5
1.6.4 Preemptive Multitasking 5
1.6.5 Microkernels or Exokernels 6
1.6.5.1 Monolithic kernels 6
1.6.5.2 Exokernels 7
REFERENCES 58
APPENDIX A 59
APPENDIX B 60
APPENDIX C 61
LIST OF FIGURES
FIG NO. FIGURE NAME PAGE NO.
iv
FIG NO. FIGURE NAME PAGE NO.
v
LIST OF TABLES
TABLE NO. TABLE NAME PAGE NO.
vi
ABBREVIATIONS
vii
ABSTRACT
The main objective of this project is to develop a home automation system with
Android application controlled remote. Remote controlled home automation system
provides a simpler solution with Android application technology. Remote operation is
achieved by any smart-phone/Tablet etc., with Android OS, upon a GUI (Graphical User
Interface) based touch screen operation. 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.
Our Aim is to design a kit that can be used for controlling AC Loads from
Android phone by using Arduino microcontroller. Home automation refers to the use of
computer and information technology to control home appliances and other features
(such as windows or lighting). Systems can range from simple remote control of lighting
through to complex computer/micro-controller based networks with varying degrees of
intelligence and automation. Home automation is adopted for reasons of ease, security
and energy efficiency.
In modern construction in industrialized nations, most homes have been wired for
electrical power, telephones, TV outlets (cable or antenna), and a doorbell. Many
household tasks were automated by the development of specialized appliances. For
instance, automatic washing machines were developed to reduce the manual labor of
cleaning clothes, and water heaters reduced the labor necessary for bathing.
viii
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-1
INTRODUCTION TO EMBEDDED SYSTEMS
INTRODUCTION
DESCRIPTION
REQUIREMENTS
Hardware Requirements
2. Arduino Uno
3. Bluetooth Module
4. Electrical Loads
DEPARTMENT OF PHYSICS 1
Arduino based Home Automation System using Bluetooth through an Android Mobile
Software Requirements
1. Arduino IDE
EMBEDDED SYSTEMS
DEPARTMENT OF PHYSICS 2
Arduino based Home Automation System using Bluetooth through an Android Mobile
• An embedded system is any computer system hidden inside a product other than a
computer.
• They will encounter a number of difficulties when writing embedded system
software in addition to those we encounter when we write applications.
– Throughput – Our system may need to handle a lot of data in a short
period of time.
– Response – Our system may need to react to events quickly.
– Testability – Setting up equipment to test embedded software can be
difficult.
– Debugability – Without a screen or a keyboard, finding out what the
software is doing wrong (other than not working) is a troublesome
problem.
– Reliability – Embedded systems must be able to handle any situation
without human intervention.
DEPARTMENT OF PHYSICS 3
Arduino based Home Automation System using Bluetooth through an Android Mobile
In this design, the software simply has a loop. The loop calls subroutines, each of
which manages a part of the hardware or software.
Interrupt-Controlled System
DEPARTMENT OF PHYSICS 4
Arduino based Home Automation System using Bluetooth through an Android Mobile
These kinds of systems are used if event handlers need low latency, and the event
handlers are short and simple. Usually, these kinds of systems run a simple task in a main
loop also, but this task is not very sensitive to unexpected delays.
Sometimes the interrupt handler will add longer tasks to a queue structure. Later,
after the interrupt handler has finished, these tasks are executed by the main loop. This
method brings the system close to a multitasking kernel with discrete processes.
Cooperative Multitasking
A non preemptive multitasking system is very similar to the simple control loop
scheme, except that the loop is hidden in an API. The programmer defines a series of
tasks, and each task gets its own environment to “run” in. When a task is idle, it calls an
idle routine, usually called “pause”, “wait”, “yield”, “nop” (stands for no operation), etc.
The advantages and disadvantages are similar to that of the control loop, except
that adding new software is easier, by simply writing a new task, or adding to the queue.
In this type of system, a low-level piece of code switches between tasks or threads
based on a timer (connected to an interrupt). This is the level at which the system is
generally considered to have an "operating system" kernel. Depending on how much
functionality is required, it introduces more or less of the complexities of managing
multiple tasks running conceptually in parallel.
As any code can potentially damage the data of another task (except in larger
systems using an MMU) programs must be carefully designed and tested, and access to
shared data must be controlled by some synchronization strategy, such as message
queues, semaphores or a non-blocking synchronization scheme.
DEPARTMENT OF PHYSICS 5
Arduino based Home Automation System using Bluetooth through an Android Mobile
device functionality rather than operating system services, at least for large systems;
smaller systems often cannot afford the overhead associated with a generic real time
system, due to limitations regarding memory size, performance, or battery life. The
choice that an RTOS is required brings in its own issues, however, as the selection must
be done prior to starting to the application development process. This timing forces
developers to choose the embedded operating system for their device based upon current
requirements and so restricts future options to a large extent The restriction of future
options becomes more of an issue as product life decreases. Additionally the level of
complexity is continuously growing as devices are required to manage variables such as
serial, USB, TCP/IP, Bluetooth, Wireless LAN, trunk radio, multiple channels, data and
voice, enhanced graphics, multiple states, multiple threads, numerous wait states and so
on. These trends are leading to the uptake of embedded middleware in addition to a real-
time operating system.
Monolithic kernels
DEPARTMENT OF PHYSICS 6
Arduino based Home Automation System using Bluetooth through an Android Mobile
resources, is often more expensive, and, because of the complexity of these kernels, can
be less predictable and reliable.
Despite the increased cost in hardware, this type of embedded system is increasing in
popularity, especially on the more powerful embedded devices such as wireless routers
and GPS navigation systems. Here are some of the reasons:
Exokernel
DEPARTMENT OF PHYSICS 7
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-2
BLOCK DIAGRAM
2.1 BLUETOOTH
Bluetooth is managed by the Bluetooth Special Interest Group (SIG), which has
more than 25,000 member companies in the areas of telecommunication, computing,
DEPARTMENT OF PHYSICS 8
Arduino based Home Automation System using Bluetooth through an Android Mobile
MICROCONTROLLER
DEPARTMENT OF PHYSICS 9
Arduino based Home Automation System using Bluetooth through an Android Mobile
Some microcontrollers may use four-bit words and operate at clock rate
frequencies as low as 4 kHz, for low power consumption (single-digit mill watts or
microwatts). They will generally have the ability to retain functionality while waiting for
an event such as a button press or other interrupt; power consumption while sleeping
(CPU clock and most peripherals off) may be just Nano watts, making many of them well
suited for long lasting battery applications. Other microcontrollers may serve
performance-critical roles, where they may need to act more like a digital signal
processor (DSP), with higher clock speeds and power consumption.
ELECTRICAL LOADS
The term is used more broadly in electronics for a device connected to a signal
source, whether or not it consumes power. If an electric circuit has an output port, a pair
of terminals that produces an electrical signal, the circuit connected to this terminal (or its
input impedance) is the load. For example, if a CD player is connected to an amplifier,
the CD player is the source and the amplifier is the load.
If the load impedance is not very much higher than the power supply impedance,
the voltages will drop. In a domestic environment, switching on a heating appliance may
cause incandescent lights to dim noticeably.
DEPARTMENT OF PHYSICS 11
Arduino based Home Automation System using Bluetooth through an Android Mobile
ANDROID OS
Android has an active community of developers and enthusiasts who use the
Android Open Source Project (AOSP) source code to develop and distribute their own
modified versions of the operating system These community-developed releases often
bring new features and updates to devices faster than through the official
manufacturer/carrier channels, with a comparable level of quality; provide continued
support for older devices that no longer receive official updates; or bring Android to
devices that were officially released running other operating systems, such as the HP
Touchpad.
DEPARTMENT OF PHYSICS 12
Arduino based Home Automation System using Bluetooth through an Android Mobile
ARDUINO IDE
Arduino is common term for a software company, project, and user community
that designs and manufactures computer open-source hardware, open-source software,
and microcontroller-based kits for building digital devices and interactive objects that can
sense and control physical devices.
DEPARTMENT OF PHYSICS 13
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-3
HARDWARE REQUIREMENTS
TRANSFORMER
Transformers convert AC electricity from one voltage to another with a little loss
of power. Step-up transformers increase voltage, step-down transformers reduce voltage.
Most power supplies use a step-down transformer to reduce the dangerously high voltage
to a safer low voltage.
The input coil is called the primary and the output coil is called the secondary.
There is no electrical connection between the two coils; instead they are linked by an
alternating magnetic field created in the soft-iron core of the transformer. The two lines
in the middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the
power in. Note that as voltage is stepped down and current is stepped up.
The ratio of the number of turns on each coil, called the turn’s ratio, determines
the ratio of the voltages. A step-down transformer has a large number of turns on its
primary (input) coil which is connected to the high voltage mains supply, and a small
number of turns on its secondary (output) coil to give a low output voltage.
Turns Ratio = (Vp / Vs) = (Np / Ns) ----------------------- Eq.3.1
DEPARTMENT OF PHYSICS 14
Arduino based Home Automation System using Bluetooth through an Android Mobile
Where,
Vp = primary (input) voltage.
Vs = secondary (output) voltage.
Np = number of turns on primary coil.
Ns = number of turns on secondary coil.
Ip = primary (input) current.
Is = secondary (output) current.
If the secondary coil is attached to a load that allows current to flow, electrical
power is transmitted from the primary circuit to the secondary circuit. Ideally, the
transformer is perfectly efficient; all the incoming energy is transformed from the
primary circuit to the magnetic field and into the secondary circuit. If this condition is
met, the incoming electric power must equal the outgoing power.
------------Eq.3.2
DEPARTMENT OF PHYSICS 15
Arduino based Home Automation System using Bluetooth through an Android Mobile
---------------------------Eq.3.3
If the voltage is increased, then the current is decreased by the same factor. The
impedance in one circuit is transformed by the square of the turns ratio. For example, if
an impedance Zs is attached across the terminals of the secondary coil, it appears to the
primary circuit to have an impedance of (Np/Ns)2Zs. This relationship is reciprocal, so that
the impedance Zp of the primary circuit appears to the secondary to be (Ns/Np)2Zp.
Features
DEPARTMENT OF PHYSICS 16
Arduino based Home Automation System using Bluetooth through an Android Mobile
Description
The LM78XX/LM78XXA series of three-terminal positive regulators are
available in the TO-220/D-PAK package and with several fixed output voltages, making
them useful in a Wide range of applications.
Each type employs internal current limiting, thermal shutdown and safe operating
area protection, making it essentially indestructible.
If adequate heat sinking is provided, they can deliver over 1A output Current.
Although designed primarily as fixed voltage.
DEPARTMENT OF PHYSICS 17
Arduino based Home Automation System using Bluetooth through an Android Mobile
LED
LED’s are semiconductor devices. Like transistors, and other diodes, LEDs are
made out of silicon. What makes an LED give off light are the small amounts of chemical
impurities that are added to the silicon, such as gallium, arsenide, indium, and nitride.
When current passes through the LED, it emits photons as a byproduct. Normal
light bulbs produce light by heating a metal filament until it is white hot. LEDs produce
photons directly and not via heat, they are far more efficient than incandescent bulbs.
Not long ago LEDs were only bright enough to be used as indicators on
dashboards or electronic equipment. But recent advances have made LEDs bright enough
to rival traditional lighting technologies. Modern LEDs can replace incandescent bulbs in
almost any application.
DEPARTMENT OF PHYSICS 18
Arduino based Home Automation System using Bluetooth through an Android Mobile
Types of LED’s
LEDs are produced in an array of shapes and sizes. The 5 mm cylindrical package
is the most common, estimated at 80% of world production. The color of the plastic lens
is often the same as the actual color of light emitted, but not always. For instance, purple
plastic is often used for infrared LEDs, and most blue devices have clear housings.
There are also LEDs in extremely tiny packages, such as those found on blinkers
and on cell phone keypads. The main types of LEDs are miniature, high power devices
and custom designs such as alphanumeric or multi-color.
RESISTORS
V = IR ---Eq.3.4
Resistors are used as part of electrical networks and electronic circuits. They
are extremely commonplace in most electronic equipment. Practical resistors can be
made of various compounds and films, as well as resistance wire (wire made of a high-
resistivity alloy, such as nickel/chrome).
DEPARTMENT OF PHYSICS 19
Arduino based Home Automation System using Bluetooth through an Android Mobile
------Eq.3.5
Resistors are common elements of electrical networks and electronic circuits and
are ubiquitous in most electronic equipment. Practical resistors can be made of various
compounds and films, as well as resistance wire (wire made of a high-resistivity alloy,
DEPARTMENT OF PHYSICS 20
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 21
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 22
Arduino based Home Automation System using Bluetooth through an Android Mobile
Capacitors are widely used in electronic circuits for blocking direct current while
allowing alternating current to pass, in filter networks, for smoothing the output of power
supplies, in the resonant circuits that tune radios to particular frequencies and for many
other purposes.
A capacitor is a passive electronic component consisting of a pair of conductors
separated by a dielectric (insulator). When there is a potential difference (voltage) across
the conductors, a static electric field develops in the dielectric that stores energy and
produces a mechanical force between the conductors. An ideal capacitor is characterized
by a single constant value, capacitance, measured in farads. This is the ratio of the
electric charge on each conductor to the potential difference between them.
The capacitance is greatest when there is a narrow separation between large areas
of conductor, hence capacitor conductors are often called "plates", referring to an early
means of construction. In practice the dielectric between the plates passes a small amount
of leakage current and also has an electric field strength limit, resulting in a breakdown
voltage, while the conductors and leads introduce an undesired inductance and resistance.
DEPARTMENT OF PHYSICS 23
Arduino based Home Automation System using Bluetooth through an Android Mobile
Theory of Operation
DEPARTMENT OF PHYSICS 24
Arduino based Home Automation System using Bluetooth through an Android Mobile
------- -Eq.3.6
Sometimes charge build-up affects the capacitor mechanically, causing its
capacitance to vary. In this case, capacitance is defined in terms of incremental changes:
--------Eq.3.7
Energy storage
Work must be done by an external influence to "move" charge between the
conductors in a capacitor. When the external influence is removed the charge separation
persists in the electric field and energy is stored to be released when the charge is allowed
to return to its equilibrium position. The work done in establishing the electric field, and
hence the amount of energy stored, is given by
----Eq.3.8
Current-Voltage relation
The current i(t) through any component in an electric circuit is defined as the rate
of flow of a charge q(t) passing through it, but actual charges, electrons, cannot pass
through the dielectric layer of a capacitor, rather an electron accumulates on the negative
plate for each one that leaves the positive plate, resulting in an electron depletion and
consequent positive charge on one electrode that is equal and opposite to the accumulated
DEPARTMENT OF PHYSICS 25
Arduino based Home Automation System using Bluetooth through an Android Mobile
negative charge on the other. Thus the charge on the electrodes is equal to the integral of
the current as well as proportional to the voltage as discussed above. As with any
antiderivative, a constant of integration is added to represent the initial voltage v (t0). This
is the integral form of the capacitor equation.
-----Eq.3.9
Taking the derivative of this, and multiplying by C, yields the derivative form.
------------ -Eq.3.10
The dual of the capacitor is the inductor, which stores energy in the magnetic field
rather than the electric field. Its current-voltage relation is obtained by exchanging
current and voltage in the capacitor equations and replacing C with the inductance L.
PUSH BUTTONS
Uses
In industrial and commercial applications push buttons can be linked together by a
mechanical linkage so that the act of pushing one button causes the other button to be
released. In this way, a stop button can "force" a start button to be released. This method
of linkage is used in simple manual operations in which the machine or process have no
electrical circuits for control.
Pushbuttons are often color-coded to associate them with their function so that the
operator will not push the wrong button in error. Commonly used colors are red for
stopping the machine or process and green for starting the machine or process.
Red pushbuttons can also have large heads (mushroom shaped) for easy operation
and to facilitate the stopping of a machine. These pushbuttons are called emergency stop
buttons and are mandated by the electrical code in many jurisdictions for increased
safety. This large mushroom shape can also be found in buttons for use with operators
who need to wear gloves for their work and could not actuate a regular flush-mounted
push button. As an aid for operators and users in industrial or commercial applications, a
pilot light is commonly added to draw the attention of the user and to provide feedback if
the button is pushed. Typically this light is included into the center of the pushbutton and
a lens replaces the pushbutton hard center disk.
The source of the energy to illuminate the light is not directly tied to the contacts
on the back of the pushbutton but to the action the pushbutton controls. In this way a start
button when pushed will cause the process or machine operation to be started and a
secondary contact designed into the operation or process will close to turn on the pilot
light and signify the action of pushing the button caused the resultant process or action to
start.
In popular culture, the phrase "the button" refers to a (usually fictional) button
that a military or government leader could press to launch nuclear weapons.
DEPARTMENT OF PHYSICS 27
Arduino based Home Automation System using Bluetooth through an Android Mobile
Push To On Button
Initially the two contacts of the button are open. When the button is pressed they
become connected. This makes the switching operation using the push button
3.7 1N4007
Diodes are used to convert AC into DC these are used as half wave rectifier or full
wave rectifier. Three points must he kept in mind while using any type of diode.
1. Maximum forward current capacity
2.Maximum reverse voltage capacity
3.Maximum forward voltage capacity
The number and voltage capacity of some of the important diodes available in the
market are as follows:
DEPARTMENT OF PHYSICS 28
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 29
Arduino based Home Automation System using Bluetooth through an Android Mobile
Now that you are familiar with P and N type materials, how these materials are
joined together to form a diode, and the function of the diode, let us continue our
discussion with the operation of the P-N junction. But before we can understand how the
P-N junction works, we must first consider current flow in the materials that make up the
junction and what happens initially within the junction when these two materials are
joined together.
Current flow through the P-type material is illustrated. Conduction in the P material
is by positive holes, instead of negative electrons. A hole moves from the positive
terminal of the P material to the negative terminal. Electrons from the external circuit
enter the negative terminal of the material and fill holes in the vicinity of this terminal. At
the positive terminal, electrons are removed from the covalent bonds, thus creating new
holes. This process continues as the steady stream of holes (hole current) moves toward
the negative terminal.
DEPARTMENT OF PHYSICS 30
Arduino based Home Automation System using Bluetooth through an Android Mobile
Maximum Ratings
1N400 1N400
Rating Symbol 1N4001 1N4002 3 1N4004 5 1N4006 1N4007 Unit
DC Blocking Voltage VR
V
*RMS Reverse Voltage R(RMS) 35 70 140 280 420 560 700 Volts
± 65 to
Operating and Storage Junction TJ +175 °C
T
Temperature Range stg
RELAYS
DEPARTMENT OF PHYSICS 31
Arduino based Home Automation System using Bluetooth through an Android Mobile
(with complete electrical isolation between control and controlled circuits), or where
several circuits must be controlled by one signal.
A relay is an electrically operated switch. Current flowing through the coil of the
relay creates a magnetic field which attracts a lever and changes the switch contacts. The
coil current can be on or off so relays have two switch positions and most have double
throw (changeover) switch contacts as shown in the diagram.
Relays allow one circuit to switch a second circuit which can be completely
separate from the first. For example a low voltage battery circuit can use a relay to switch
a 230V AC mains circuit. There is no electrical connection inside the relay between the
two circuits; the link is magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V
relay, but it can be as much as 100mA for relays designed to operate from lower voltages.
Most ICs (chips) cannot provide this current and a transistor is usually used to amplify
the small IC current to the larger value required for the relay coil. The maximum
DEPARTMENT OF PHYSICS 32
Arduino based Home Automation System using Bluetooth through an Android Mobile
output current for the popular 555 timer IC is 200mA so these devices can supply relay
coils directly without amplification.
Relays are usually SPDT or DPDT but they can have many more sets of switch
contacts, for example relays with 4 sets of changeover contacts are readily available. For
further information about switch contacts and the terms used to describe them please see
the page on switches. Most relays are designed for PCB mounting but you can solder
wires directly to the pins providing you take care to avoid melting the plastic case of the
relay.
The supplier's catalogue should show you the relay's connections. The coil will be
obvious and it may be connected either way round. Relay coils produce brief high voltage
'spikes' when they are switched off and this can destroy transistors and ICs in the circuit.
To prevent damage you must connect a protection diode across the relay coil.
The figure shows a relay with its coil and switch contacts. You can see a lever on
the left being attracted by magnetism when the coil is switched on. This lever moves the
switch contacts.
There is one set of contacts (SPDT) in the foreground and another behind them,
making the relay DPDT.
DEPARTMENT OF PHYSICS 33
Arduino based Home Automation System using Bluetooth through an Android Mobile
Applications Of Relays
DEPARTMENT OF PHYSICS 34
Arduino based Home Automation System using Bluetooth through an Android Mobile
Remember the models HC-04 or HC-06 are SLAVE only modules .HC-05 is the
module of interest in this post. To identify the model we can see the pin count. If the
module has 5 or 6 pins it is HC-05.If the module has only 4 pins then it is HC-04 or HC-
06. The firmware for HC04 is LINVOR & for the HC05 it is HC05 itself. If we scan for
Bluetooth devices from our Android phone we can see this name. The extra pins in HC-
05 are the KEY & STATE pins. The KEY pin is used to enter the Command mode.
DEPARTMENT OF PHYSICS 35
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 36
Arduino based Home Automation System using Bluetooth through an Android Mobile
ARDUINO UNO
"Uno" means one in Italian and was chosen to mark the release of Arduino
Software (IDE) 1.0. The Uno board and version 1.0 of Arduino Software (IDE) were the
reference versions of Arduino, now evolved to newer releases. The Uno board is the first
in a series of USB Arduino boards, and the reference model for the Arduino platform; for
an extensive list of current, past or outdated boards see the Arduino index of boards.
DEPARTMENT OF PHYSICS 37
Arduino based Home Automation System using Bluetooth through an Android Mobile
Technical Specifications
Microcontroller ATmega328P
Operating Voltage 5V
SRAM 2 KB (ATmega328P)
EEPROM 1 KB (ATmega328P)
Length 68.6 mm
Width 53.4 mm
Weight 25 gm
DEPARTMENT OF PHYSICS 38
Arduino based Home Automation System using Bluetooth through an Android Mobile
Circuit Diagram
DEPARTMENT OF PHYSICS 39
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-4
Nowadays, people have smart phones with them all the time. So it makes sense to use these to
control home appliances. Presented here is a home automation system using a simple Android app,
which you can use to control electrical appliances with clicks or voice commands. Commands are
sent via Bluetooth to Arduino Uno. So you need not get up to switch on or switch off the device
while watching a movie or doing some work.
The home automation circuit is built around an Arduino Uno board, Bluetooth module HC-05 and
a 3-channel relay board. The number of channels depends on the number of appliances you wish to
control. Arduino Uno is powered with a 12V DC adaptor/power source. The relay module and
Bluetooth module can be, in turn, powered using a board power supply of Arduino Uno.
Bluetooth Module
Bluetooth module used in this project is HC-05 (Fig. 4), which supports master and slave mode
serial communication (9600-115200 bps) SPP and UART interface. Using these features it can
communicate with other Bluetooth-enabled devices like mobile phones, tablets and laptops. The
module runs on 3.3V to 5V power supply.
DEPARTMENT OF PHYSICS 40
Arduino based Home Automation System using Bluetooth through an Android Mobile
Relay Module
A relay allows you to turn on or turn off a circuit using voltage and/or current much higher than
what Arduino could handle. Relay provides complete isolation between the low-voltage circuit on
Arduino side and the high-voltage side controlling the load. It gets activated using 5V from
Arduino, which, in turn, controls electrical appliances like fans, lights and air-conditioners. An 8-
channel relay module is shown in Fig. 5.
DEPARTMENT OF PHYSICS 41
Arduino based Home Automation System using Bluetooth through an Android Mobile
In this home automation project circuit, Pins 10 and 11 of Arduino are connected to pins TXD and
RXD of the Bluetooth module, respectively, as shown in Fig. 6.
Pins Gnd and Vcc of the Bluetooth module are connected to Gnd and +3.3V of Arduino board
respectively. Pins 2, 3 and 4 are connected to the three relays (RL1, RL2 and RL3) of the relay
board. Pins Vin and Gnd of the relay board are connected to pins Vin and Gnd of Arduino board,
respectively.
Note. Vin is usually used to give input power, but since we are supplying 12V to Arduino using an
adaptor, we can use Vin pin on Arduino to power the 12V relay module.
Software
The software program for the home automation project(homeautomation.ino) is written in Arduino
programming language called Processing. Arduino Uno is programmed using Arduino IDE
software that you can download from arduino.cc. MIT App Inventor software was used to create
the Android app (.apk) for this project.
The app on your smartphone sends data when you click on buttons or feed voice commands via
Bluetooth in the mobile to Bluetooth module HC-05 connected with Arduino board. Received data
pin TXD of the HC-05 is connected to Arduino. Arduino Uno processes the received data and
controls the relay board accordingly.
Assemble the circuit as shown in the circuit diagram. Open Arduino IDE and compile the program
(sketch). Upload the sketch (homeautomation.ino) to Arduino board. Switch on the power supply
to Arduino by connecting it to 12V power source. Pair Bluetooth module with your Android
phone. Type password ‘1234’ (default password) of Bluetooth module.
Click Bluetooth Image on the app to connect it with the Bluetooth module. It automatically
connects and displays as Connected in the app.
You are now ready to control the appliances using the app. You can either use on/off buttons or
voice commands to control the appliances. You can control more electrical appliances by
DEPARTMENT OF PHYSICS 43
Arduino based Home Automation System using Bluetooth through an Android Mobile
increasing the number of channels in the relay. For instance, using an 8-channel relay, you can
control up to eight devices. For this, you need to alter the source code by adding input commands
and voice commands to control the devices.
DEPARTMENT OF PHYSICS 44
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-5
SOFTWARE REQUIREMENTS
ARDUINO SOFTWARE
The board can be programmed from the Arduino software, which is available for
different platforms such as Windows, Mac OSX and Linux. It is open source software,
which is designed using a Java environment and is also based on processing and avr-gcc.
The software allows users to write their code in C and upload to the board. The
boot loader allows the uploading without the need of external hardware programmer.
Thus the software is very easy to use and efficient. (Arduino Software 2012 ) Arduino
DEPARTMENT OF PHYSICS 45
Arduino based Home Automation System using Bluetooth through an Android Mobile
programs may be written in any programming language with a compiler that produces
binary machine code. Atmel provides a development environment for their
microcontrollers, AVR Studio and the newer Atmel Studio.
The Arduino IDE supports the languages C and C++ using special rules to organize
code. The Arduino IDE supplies a software library called Wiring from the Wiring
project, which provides many common input and output procedures. A typical Arduino
C/C++ sketch consist of two functions that are compiled and linked with a program stub
main () into an executable cyclic executive program.
setup (): a function that runs once at the start of a program and that can initialize
settings.
loop (): a function called repeatedly until the board powers off.
After compiling and linking with the GNU toolchain, also included with the IDE
distribution, the Arduino IDE employs the program avrdude to convert the executable
code into a text file in hexadecimal coding that is loaded into the Arduino board by a
loader program in the board's firmware.
ARDUINO DEVELOPMENT
DEPARTMENT OF PHYSICS 46
Arduino based Home Automation System using Bluetooth through an Android Mobile
Arduino website. Layout and production files for some versions of the hardware are also
available. The source code for the IDE is released under the GNU General Public
License, version 2.
Although the hardware and software designs are freely available under copy left lice-
nses, the developers have requested that the name "Arduino" be exclusive to the official
product and not be used for derived works without permission. The official policy docu-
ment on use of the Arduino name emphasizes that the project is open to incorporating by
others into the official product.Several Arduino-compatible products commercially relea-
sed have avoided the Arduino name by using -duino name variants.
#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11); //TX, RX pins of arduino respetively
String command;
void setup()
{
BT.begin(9600);
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
while (BT.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = BT.read(); //Conduct a serial read
command += c; //build the string.
}
if (command.length() > 0) {
DEPARTMENT OF PHYSICS 47
Arduino based Home Automation System using Bluetooth through an Android Mobile
Serial.println(command);
if(command == "light on") //this command will be given as an input to switch on light1
{
digitalWrite(2, HIGH);
}
else if(command == "light off") //this command will be given as an input to switch off light1
simillarly other commands work
{
digitalWrite(2, LOW);
}
else if (command == "lamp on")
{
digitalWrite (3, HIGH);
}
else if ( command == "lamp off")
{
digitalWrite (3, LOW);
}
else if (command == "fan on")
{
digitalWrite (4, HIGH);
}
else if (command == "fan of")
{
digitalWrite (4, LOW);
}
else if (command == "all on") //using this command you can switch on all devices
{
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
DEPARTMENT OF PHYSICS 48
Arduino based Home Automation System using Bluetooth through an Android Mobile
}
else if (command == "off")//using this command you can switch off all devices
{
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
}
command="";}} //Reset the variable
//you can add other command to control addition devices by adding an elseif
//and the additions commands you add in sketch can be given through voice regonisation as i
have created the app buttons only to control three devices
//
DEPARTMENT OF PHYSICS 49
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 50
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 51
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 52
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-6
ADVANTAGES
Saves Time
Saves Money And Increases Convenience
Contributes To Economy
Increases Peace Of Mind
APPLICATIONS
Industrial Automation
DEPARTMENT OF PHYSICS 53
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-7
RESULTS
DEPARTMENT OF PHYSICS 54
Arduino based Home Automation System using Bluetooth through an Android Mobile
EXPLANATION OF RESULT
DEPARTMENT OF PHYSICS 55
Arduino based Home Automation System using Bluetooth through an Android Mobile
CHAPTER-8
CONCLUSION
II. Design and implementation of a Home Automation System using Android for
mobile phone has been discussed.
III. The purpose of the system is to use mobile phone’s inbuilt Bluetooth facility for
automation.
IV. Different hardware and software unit of the system are described.
V. The complete application software has been designed using Android, Bluetooth
API and Embedded C Language.
VI. The AS application program is tested on various Android mobile phones which
are quite satisfactory and response received from the community in general is
encouraging.
VII. The AS furnishes a good paradigm for any Automation System based on Android
Mobile Phone and Bluetooth.
FUTURE SCOPE
DEPARTMENT OF PHYSICS 56
Arduino based Home Automation System using Bluetooth through an Android Mobile
DEPARTMENT OF PHYSICS 57
Arduino based Home Automation System using Bluetooth through an Android Mobile
REFERENCES
DEPARTMENT OF PHYSICS 58
Arduino based Home Automation System using Bluetooth through an Android Mobile
APPENDIX A
Electrical Characteristics Of LM7805, VI = 10 V, IO = 500 mA
µ
A7805C
J
MIN TYP MAX
VI = 7 V to 25 V 3 100
Input voltage regulation 25° C mV
VI = 8 V to 12 V 1 50
IO = 5 mA to 1.5 A 15 100
Output voltage regulation 25° C mV
IO = 250 mA to 750
Ma 5 50
f = 10 Hz to 100
Output noise voltage kHz 25° C 40 µV
VI = 7 V to 25 V 1.3
IO = 5 mA to 1 A 0.5
DEPARTMENT OF PHYSICS 59
Arduino based Home Automation System using Bluetooth through an Android Mobile
APPENDIX B
Electrical Characteristics of 1N4007
DEPARTMENT OF PHYSICS 60
Arduino based Home Automation System using Bluetooth through an Android Mobile
APPENDIX C
Pin Characteristics of HC-05
DEPARTMENT OF PHYSICS 61