Professional Documents
Culture Documents
INTRODUCTION
This article explains you 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 user’s 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.
Android is the customizable, easy-to-use operating system that powers more than a billion
devices across the globe – from phones and tablets to watches, TV, cars and more to come.
Android is built on the open Linux Kernel. Furthermore, it utilizes a custom virtual machine
that was designed to optimize memory and hardware resources in a mobile environment.
Android is open source; it can be liberally extended to incorporate new cutting edge
technologies as they emerge. The platform will continue to evolve as the developer
community works together to build innovative mobile applications.
Android breaks down the barriers to building new and innovative applications. Android
provides access to a wide range of useful libraries and tools that can be used to build rich
applications. Google's argument is that Android is open because the code is opened to all,
because Google doesn't charge for the platform, and because developers have access to it all.
The only restriction is on Google services, for which the company demands that phone
makers conform to certain specifications. Google's take on Android is that they make it as
open as possible.
1
Bluetooth control home appliances
at89c51 controller
8051 programming board
Programming cable
DC battery or 12V,1A adaptor
16×2 LCD
Bluetooth module
5V Relays – 2
Lamp
DC Motor
BC 547 Transistors – 2
330 ohm resistors (1/4 watt) – 2
Reset circuit
Crystal circuit
5V DC power supply circuit
Connecting wires
Keil compiler
Flash magic
Proteus
Android application file
2
Bluetooth control home appliances
Features
3
Bluetooth control home appliances
Introduction
4
Bluetooth control home appliances
HC‐05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module,designed
for transparent wireless serial connection setup.The HC-05 Bluetooth Module can be
used in a Master or Slave configuration, making it a great solution for wireless
communication.This 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 Rluetooth system with CMOS
technology and with AFH (Adaptive Frequency Hopping Feature).
Hardware Features
Software Features
Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.
Auto‐connect to the last device on power as default.
Permit pairing device to connect as default.
Auto‐pairing PINCODE:”1234” as default.
5
Bluetooth control home appliances
Pin Description
ENABLE:
When enable is pulled LOW, the module is disabled which means the module will not
turn on and it fails to communicate.When enable is left open or connected to 3.3V, the
module is enabled i.e the module remains on and communication also takes place.
Vcc:
GND:
Ground pin
STATE:
It acts as a status indicator.When the module is not connected to / paired with any other
bluetooth device,signal goes Low.At this low state,the led flashes continuously which
denotes that the module is not paired with other device.When this module is connected
to/paired with any other bluetooth device,the signal goes High.At this high state,the led
blinks with a constant delay say for example 2s delay which indicates that the module
is paired.
BUTTON SWITCH:
This is used to switch the module into AT command mode.To enable AT command
mode,press the button switch for a second.With the help of AT commands,the user can
6
Bluetooth control home appliances
change the parameters of this module but only when the module is not paired with any
other BT device.If the module is connected to any other bluetooth device, it starts to
communicate with that device and fails to work in AT command mode.
Hardware Connections
As we know that Vcc and Gnd of the module goes to Vcc and Gnd of Arduino.The TXD
pin goes to RXD pin of Arduino and RXD pin goes to TXD pin of Arduino i.e(digital pin
0 and 1).The user can use the on board Led.But here,Led is connected to digital pin 12
externally for betterment of the process.
The program given below is the HC-05 bluetooth module program.This process is quite
different from others since we are going to use android mobile to control and
communicate with arduino.Here the bluetooth module acts as an interface between our
mobile and Arduino board.Before getting into the execution process,follow the given
procedure:
First of all,the user should install an application called Bluetooth SPP PRO from
the playstore which is a free application.
After installation,pair the bluetooth module to your mobile as like connecting
one device to other using bluetooth.The default pairing code is 1234.
Upload the given program to the Arduino Uno board.After uploading the
code,unplug the USB from the arduino.
Now use external power adapter to power the Uno board.
7
Bluetooth control home appliances
The Bluetooth SPP PRO has three types of communication mode.Here Byte
stream mode is used to communicate.So select that mode and give the input
as 1,as soon as the input has given the led will turn on and for 0 led will turn off.
#include <SoftwareSerial.h>
int ledpin=12;
int Data;
void setup()
mySerial.begin(9600);
pinMode(ledpin,OUTPUT);
void loop()
if (mySerial.available())
Data=mySerial.read();
if(Data=='1')
digitalWrite(ledpin,HIGH);
8
Bluetooth control home appliances
else if (Data=='0')
digitalWrite(ledpin,LOW);
5V RELAY
A type of relay that can handle the high power required to directly control an electric
motor or other loads is called a contactor. Solid-state relays control power circuits with
no moving parts, instead using a semiconductor device to perform switching. Relays
with calibrated operating characteristics and sometimes multiple operating coils are
used to protect electrical circuits from overload or faults; in modern electric power
systems these functions are performed by digital instruments still called "protective
relays".
Magnetic latching relays require one pulse of coil power to move their contacts in one
direction, and another, redirected pulse to move them back. Repeated pulses from the
same input have no effect. Magnetic latching relays are useful in applications where
interrupted power should not be able to transition the contacts.
Magnetic latching relays can have either single or dual coils. On a single coil device, the
relay will operate in one direction when power is applied with one polarity, and will
reset when the polarity is reversed. On a dual coil device, when polarized voltage is
applied to the reset coil the contacts will transition. AC controlled magnetic latch relays
have single coils that employ steering diodes to differentiate between operate and reset
commands.
DC MOTOR
A DC motor is any of a class of rotary electrical machines that converts direct current
electrical energy into mechanical energy. The most common types rely on the forces
produced by magnetic fields. Nearly all types of DC motors have some internal
mechanism, either electromechanical or electronic, to periodically change the direction
of current flow in part of the motor.
9
Bluetooth control home appliances
DC motors were the first type widely used, since they could be powered from existing
direct-current lighting power distribution systems. A DC motor's speed can be
controlled over a wide range, using either a variable supply voltage or by changing the
strength of current in its field windings. Small DC motors are used in tools, toys, and
appliances. The universal motor can operate on direct current but is a lightweight
motor used for portable power tools and appliances. Larger DC motors are used in
propulsion of electric vehicles, elevator and hoists, or in drives for steel rolling mills.
The advent of power electronics has made replacement of DC motors with AC
motors possible in many applications.
A simple DC motor has a stationary set of magnets in the stator and an armature with
one or more windings of insulated wire wrapped around a soft iron core that
concentrates the magnetic field. The windings usually have multiple turns around the
core, and in large motors there can be several parallel current paths. The ends of the
wire winding are connected to a commutator. The commutator allows each armature
coil to be energized in turn and connects the rotating coils with the external power
supply through brushes. (Brushless DC motors have electronics that switch the DC
current to each coil on and off and have no brushes.)
The total amount of current sent to the coil, the coil's size and what it's wrapped around
dictate the strength of the electromagnetic field created.
10
Bluetooth control home appliances
The sequence of turning a particular coil on or off dictates what direction the effective
electromagnetic fields are pointed. By turning on and off coils in sequence a rotating
magnetic field can be created. These rotating magnetic fields interact with the magnetic
fields of the magnets (permanent or electromagnets) in the stationary part of the motor
(stator) to create a force on the armature which causes it to rotate. In some DC motor
designs the stator fields use electromagnets to create their magnetic fields which allow
greater control over the motor.
At high power levels, DC motors are almost always cooled using forced air.
Different number of stator and armature fields as well as how they are connected
provide different inherent speed/torque regulation characteristics. The speed of a DC
motor can be controlled by changing the voltage applied to the armature. The
introduction of variable resistance in the armature circuit or field circuit allowed speed
control. Modern DC motors are often controlled by power electronics systems which
adjust the voltage by "chopping" the DC current into on and off cycles which have an
effective lower voltage.
Since the series-wound DC motor develops its highest torque at low speed, it is often
used in traction applications such as electric locomotives, and trams. The DC motor was
the mainstay of electric traction drives on both electric and diesel-electric locomotives,
street-cars/trams and diesel electric drilling rigs for many years. The introduction of
DC motors and an electrical grid system to run machinery starting in the 1870s started
a new second Industrial Revolution. DC motors can operate directly from rechargeable
batteries, providing the motive power for the first electric vehicles and today's hybrid
cars and electric cars as well as driving a host of cordless tools. Today DC motors are
still found in applications as small as toys and disk drives, or in large sizes to operate
steel rolling mills and paper machines. Large DC motors with separately excited fields
were generally used with winder drives for mine hoists, for high torque as well as
smooth speed control using thyristor drives. These are now replaced with large AC
motors with variable frequency drives.
Brushed
11
Bluetooth control home appliances
ripple) Since this is a single phase two-pole motor, the commutator consists of a split
ring, so that the current reverses each half turn ( 180 degrees).
The brushed DC electric motor generates torque directly from DC power supplied to
the motor by using internal commutation, stationary magnets
(permanent or electromagnets), and rotating electrical magnets.
Advantages of a brushed DC motor include low initial cost, high reliability, and simple
control of motor speed. Disadvantages are high maintenance and low life-span for high
intensity uses. Maintenance involves regularly replacing the carbon brushes and springs
which carry the electric current, as well as cleaning or replacing the commutator. These
components are necessary for transferring electrical power from outside the motor to
the spinning wire windings of the rotor inside the motor. Brushes consist of conductors.
Brushless
Typical brushless DC motors use one or more permanent magnets in the rotor
and electromagnets on the motor housing for the stator. A motor controller converts DC
to AC. This design is mechanically simpler than that of brushed motors because it
eliminates the complication of transferring power from outside the motor to the
spinning rotor. The motor controller can sense the rotor's position via Hall
effect sensors or similar devices and can precisely control the timing, phase, etc., of the
current in the rotor coils to optimize torque, conserve power, regulate speed, and even
apply some braking. Advantages of brushless motors include long life span, little or no
maintenance, and high efficiency. Disadvantages include high initial cost, and more
complicated motor speed controllers. Some such brushless motors are sometimes
referred to as "synchronous motors" although they have no external power supply to be
synchronized with, as would be the case with normal AC synchronous motors.
Uncommutated
Homopolar motor – A homopolar motor has a magnetic field along the axis of rotation
and an electric current that at some point is not parallel to the magnetic field. The name
homopolar refers to the absence of polarity change. Homopolar motors necessarily have
a single-turn coil, which limits them to very low voltages. This has restricted the
practical application of this type of motor.
12
Bluetooth control home appliances
A PM motor does not have a field winding on the stator frame, instead relying on PMs
to provide the magnetic field against which the rotor field interacts to produce torque.
Compensating windings in series with the armature may be used on large motors to
improve commutation under load. Because this field is fixed, it cannot be adjusted for
speed control. PM fields (stators) are convenient in miniature motors to eliminate the
power consumption of the field winding. Most larger DC motors are of the "dynamo"
type, which have stator windings. Historically, PMs could not be made to retain high
flux if they were disassembled; field windings were more practical to obtain the needed
amount of flux. However, large PMs are costly, as well as dangerous and difficult to
assemble; this favors wound fields for large machines.
To minimize overall weight and size, miniature PM motors may use high energy
magnets made with neodymium or other strategic elements; most such are neodymium-
iron-boron alloy. With their higher flux density, electric machines with high-energy
PMs are at least competitive with all optimally designed singly fed synchronous and
induction electric machines. Miniature motors resemble the structure in the illustration,
except that they have at least three rotor poles (to ensure starting, regardless of rotor
position) and their outer housing is a steel tube that magnetically links the exteriors of
the curved field magnets.
Wound stators
A field coil may be connected in shunt, in series, or in compound with the armature of a
DC machine (motor or generator)
There are three types of electrical connections between the stator and rotor possible for
DC electric motors: series, shunt/parallel and compound (various blends of series and
shunt/parallel) and each has unique speed/torque characteristics appropriate for
different loading torque profiles/signatures.
Series connection
Shunt connection
13
Bluetooth control home appliances
A shunt DC motor connects the armature and field windings in parallel or shunt with a
common D.C. power source. This type of motor has good speed regulation even as the
load varies, but does not have the starting torque of a series DC motor. It is typically
used for industrial, adjustable speed applications, such as machine tools,
winding/unwinding machines and tensioners.
Compound connection
A compound DC motor connects the armature and fields windings in a shunt and a
series combination to give it characteristics of both a shunt and a series DC motor. This
motor is used when both a high starting torque and good speed regulation is needed.
The motor can be connected in two arrangements: cumulatively or differentially.
Cumulative compound motors connect the series field to aid the shunt field, which
provides higher starting torque but less speed regulation. Differential compound DC
motors have good speed regulation and are typically operated at constant speed.
BC 547 TRANSISTORS
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.
14
Bluetooth control home appliances
Pin Diagram:
RESISTORS
Resistors are elements of electrical circuits that resist and reduce the flow of
current through the electrical circuit. They can also be used to provide specific
voltages to active components. Resistors are available with fixed or variable
resistance values. Fixed resistors are ones in which resistance never changes.
Variable resistors, sometimes called potentiometers, allow resistance to be
adjusted. Resistor values are measured in Ohms and a resistor’s composition
and construction determines the amount of resistance offered. Typically
resistors are constructed of metal or carbon and are available in a variety of
mounting styles, but through hole and surface mount are the most common.
15
Bluetooth control home appliances
only change slightly with temperature, time or operating voltage. Variable resistors can
be used to adjust circuit elements (such as a volume control or a lamp dimmer), or as
sensing devices for heat, light, humidity, force, or chemical activity.
Resistors are common elements of electrical networks and electronic circuits and are
ubiquitous in electronic equipment. Practical resistors as discrete components can be
composed of various compounds and forms. Resistors are also implemented
within integrated circuits.
KEIL COMPILER
The Keil C51 C Compiler for the 8051 microcontroller is the most popular 8051 C
compiler in the world. It provides more features than any other 8051 C compiler
available today.
The C51 Compiler allows you to write 8051 microcontroller applications in C that, once
compiled, have the efficiency and speed of assembly language. Language extensions in
the C51 Compiler give you full access to all resources of the 8051.
The C51 Compiler translates C source files into relocatable object modules which
contain full symbolic information for debugging with the µVision Debugger or an in-
circuit emulator. In addition to the object file, the compiler generates a listing file which
may optionally include symbol table and cross reference information.
Features
Flexible variable allocation with bit, data, bdata, idata, xdata, and pdata memory
types,
Support for dual data pointers on Atmel, AMD, Cypress, Dallas Semiconductor,
Infineon, Philips, and Triscend microcontrollers,
Support for the Philips 8xC750, 8xC751, and 8xC752 limited instruction sets,
16
Bluetooth control home appliances
KLASH MAGIC
This application is very useful for those who work in the electronics field. The main
window of the program is composed of five sections where you can find the most
common functions in order to program a microcontroller device. Using the
“Communications” section you will be able to choose the way a specific device connects
to your computer. Select the COM port to be used and the baud rate. It is recommended
that you choose a low baud rate first and increase it afterwards. This way you will
determine the highest speed with which your system works.
17
Bluetooth control home appliances
Circuit Diagram
18
Bluetooth control home appliances
19
Bluetooth control home appliances
In the above circuit LCD is used to indicate the status of electrical loads and also used to
display received data from Bluetooth. Here LCD is interfaced to the PORT1 of the
microcontroller in 4 bit mode.
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 you want to change the Bluetooth name
and password then you need to use Bluetooth AT commands.
To know about all the Bluetooth AT commands refer HC-03/05 Embedded Bluetooth
Serial Communication Module AT command set.
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.
1. Write the program to the projectin keil 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 5V power supply circuit to provide regulated 5V DC to the microcontroller.
6. Switch on the both AC and DC supplies.
20
Bluetooth control home appliances
7. Now relay output pins gets 230v 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
Program Explanation:
In this program, first of all we have included header file and defines input, output pins and
variables
#include<reg51.h>
sbit Fan=P2^0;
sbit Light=P2^1;
sbit TV=P2^2;
char str;
char Charin=0;
Here we have some functions that we have used in our program. In this we have configured
9600bps baud rate at 11.0592MHz Crystal Frequency.
21
Bluetooth control home appliances
{
while(*p)
{
Serialwrite(*p);
p++;
}
Serialwrite(0x0d);
}
void Serialbegin()
{
TMOD=0x20;
SCON=0x50;
TH1=0xfd;
TR1=1;
}
After this, in main program we have initialized UART and monitored the SBUF register for
receiving the data. Then data is matched and compared with predefined values and relative
operation has been performed.
void main()
{
P2=0x00;
Serialbegin();
Serialprintln("System Ready...");
delay(50);
while(1)
{
while(!RI);
Charin=SBUF;
str=Charin;
RI=0;
if(str=='1')
22
Bluetooth control home appliances
{
Fan=1;
Serialprintln(" Fan ON");
delay(50);
}
else if(str=='2')
{
Fan=0;
Serialprintln(" Fan OFF");
delay(50);
}
So that’s how we can create a whole system for the house and can connect all the AC
appliances to the 8051 microcontroller using Relays. And this bluetooth controlled
home automation system can be operated from a Smart phone.
SOURCE CODE
#include<reg51.h>
sbit Fan=P2^0;
sbit Light=P2^1;
sbit TV=P2^2;
char str;
char Charin=0;
void delay(int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
void Serialwrite(char byte)
{
SBUF=byte;
while(!TI);
TI=0;
}
void Serialprintln(char *p)
{
while(*p)
{
Serialwrite(*p);
p++;
23
Bluetooth control home appliances
}
Serialwrite(0x0d);
}
void Serialbegin()
{
TMOD=0x20;
SCON=0x50;
TH1=0xfd;
TR1=1;
}
void main()
{
P2=0x00;
Serialbegin();
Serialprintln("System Ready...");
delay(50);
while(1)
{
while(!RI);
Charin=SBUF;
str=Charin;
RI=0;
if(str=='1')
{
Fan=1;
Serialprintln(" Fan ON");
delay(50);
}
else if(str=='2')
{
Fan=0;
Serialprintln(" Fan OFF");
delay(50);
}
else if(str=='3')
{
Light=1;
Serialprintln(" Light ON");
delay(50);
}
else if(str=='4')
{
Light=0;
Serialprintln(" Light OFF");
delay(50);
}
else if(str=='5')
{
24
Bluetooth control home appliances
TV=1;
Serialprintln(" TV ON");
delay(50);
}
else if(str=='6')
{
TV=0;
Serialprintln(" TV OFF");
delay(50);
}
str=0;
}
}
25