You are on page 1of 25

Bluetooth control home appliances

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.

Remote Password Operated Electronic Home Appliances Control Circuit


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

1
Bluetooth control home appliances

Circuit Hardware Requirements:

 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

 Circuit Software Requirements:

 Keil compiler
 Flash magic
 Proteus
 Android application file

2
Bluetooth control home appliances

Features

• Compatible with MCS-51 Products

• 4 Kbytes of In-System Reprogrammable Flash Memory Endurance: 1,000


Write/Erase Cycles

• Fully Static Operation: 0 Hz to 24 MHz

• Three-Level Program Memory Lock

• 128 x 8-Bit Internal RAM

• 32 Programmable I/O Lines • Two 16-Bit Timer/Counters

• Six Interrupt Sources

• Programmable Serial Channel

• Low Power Idle and Power Down Modes

Pin Configurations PDIP/Cerdip Description The AT89C51 is a low-power, high-


performance CMOS 8-bit microcomputer with 4 Kbytes of Flash Programmable and
Erasable Read Only Memory (PEROM). The device is manufactured using Atmel’s
high density nonvolatile memory technology and is compatible with the industry
standard MCS-51 instruction set and pinout. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional nonvolatile memory
programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the
Atmel AT89C51 is a powerful microcomputer which provides a highly flexible and cost
effective solution to many embedded control

8051 programmer board

3
Bluetooth control home appliances

Introduction

4
Bluetooth control home appliances

HC-05 Bluetooth Module

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).

Bluetooth Module HC-05

The Bluetooth module HC-05 is a MASTER/SLAVE module.By default the factory


setting is SLAVE.The Role of the module (Master or Slave) can be configured only by
AT COMMANDS.The slave modules cannot initiate a connection to another Bluetooth
device, but can accept connections.Master module can initiate a connection to other
devices.The user can use it simply for a serial port replacement to establish connection
between MCU and GPS, PC to your embedded project, etc.Just go through the
datasheet for more details File

Hardware Features

 Typical ‐80dBm sensitivity.


 Up to +4dBm RF transmit power.
 3.3 to 5 V I/O.
 PIO(Programmable Input/Output) control.
 UART interface with programmable baud rate.
 With integrated antenna.
 With edge connector.

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

The HC-05 Bluetooth Module has 6pins. They are as follows:

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:

Supply Voltage 3.3V to 5V

GND:

Ground pin

TXD & RXD:

These two pins acts as an UART interface for communication

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 and Software Required

 HC-05 Bluetooth Module


 Arduino Uno
 Arduino IDE(1.0.6V)

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.

Program for HC-05 Bluetooth Module

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>

SoftwareSerial mySerial(0, 1);

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);

mySerial.println("LED On! ");

8
Bluetooth control home appliances

else if (Data=='0')

digitalWrite(ledpin,LOW);

mySerial.println("LED Off! "); }}}

5V RELAY

A relay is an electrically operated switch. Many relays use an electromagnet to


mechanically operate a switch, but other operating principles are also used, such
as solid-state relays. Relays are used where it is necessary to control a circuit by a
separate low-power signal, or where several circuits must be controlled by one signal.
The first relays were used in long distance telegraph circuits as amplifiers: they
repeated the signal coming in from one circuit and re-transmitted it on another circuit.
Relays were used extensively in telephone exchanges and early computers to perform
logical operations.

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 coil of wire with a current running through it generates an electromagnetic field


aligned with the center of the coil. The direction and magnitude of the magnetic field
produced by the coil can be changed with the direction and magnitude of the current
flowing through it.

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.

If external power is applied to a DC motor it acts as a DC generator, a dynamo. This


feature is used to slow down and recharge batteries on hybrid car and electric cars or to
return electricity back to the electric grid used on a street car or electric powered train
line when they slow down. This process is called regenerative braking on hybrid and
electric cars. In diesel electric locomotives they also use their DC motors as generators
to slow down but dissipate the energy in resistor stacks. Newer designs are adding large
battery packs to recapture some of this energy.

Brushed

Main article: Brushed DC electric motor

A brushed DC electric motor generating torque from DC power supply by using an


internal mechanical commutation. Stationary permanent magnets form the stator field.
Torque is produced by the principle that any current-carrying conductor placed within
an external magnetic field experiences a force, known as Lorentz force. In a motor, the
magnitude of this Lorentz force (a vector represented by the green arrow), and thus the
output torque,is a function for rotor angle, leading to a phenomenon known as torque

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

Main articles: Brushless DC electric motor and Switched reluctance motor

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

Other types of DC motors require no commutation.

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.

 Ball bearing motor – A ball bearing motor is an unusual electric motor


that consists of two ball bearing-type bearings, with the inner races
mounted on a common conductive shaft, and the outer races connected to
a high current, low voltage power supply. An alternative construction fits
the outer races inside a metal tube, while the inner races are mounted on a
shaft with a non-conductive section (e.g. two sleeves on an insulating rod).
This method has the advantage that the tube will act as a flywheel. The
direction of rotation is determined by the initial spin which is usually
required to get it going.

12
Bluetooth control home appliances

Permanent magnet stators

Main article: Permanent-magnet electric motor

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)

Main article: universal motor

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 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.

14
Bluetooth control home appliances

Pin Diagram:

RESISTORS

Resistors are available at Mouser Electronics from industry leading manufacturers.


Mouser is an authorized distributor for many resistor manufacturers including
Bourns, IRC, KOA, Ohmite, Panasonic, Susumu, Vishay, Yageo, & more. We stock
many resistor types including carbon, ceramic, chassis mount, current sense, film,
metal foil, metal oxide, & wirewound resistors and offer through hole and surface
mount packaging. We also stock a variety of resistor networks, resistor kits, and
resistor hardware.

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.

A resistor is a passive two-terminal electrical component that implements electrical


resistance as a circuit element. In electronic circuits, resistors are used to reduce
current flow, adjust signal levels, to divide voltages, bias active elements, and
terminate transmission lines, among other uses. High-power resistors that can dissipate
many watts of electrical power as heat may be used as part of motor controls, in power
distribution systems, or as test loads for generators. Fixed resistors have resistances that

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

 Nine basic data types, including 32-bit IEEE floating-point,

 Flexible variable allocation with bit, data, bdata, idata, xdata, and pdata memory
types,

 Interrupt functions may be written in C,

 Full use of the 8051 register banks,

 Complete symbol and type information for source-level debugging,

 Use of AJMP and ACALL instructions,

 Bit-addressable data objects,

 Built-in interface for the RTX51 Real-Time Kernel,

 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

 Support for the Infineon 80C517 arithmetic unit.

KLASH MAGIC

Flash Magic is an application developed by Embedded Systems Academy to allow you


to easily access the features of a microcontroller device. With this program you can
erase individual blocks or the entire Flash memory of the microcontroller.

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

Android Based Home Automation System Circuit Block Diagram:

Circuit Diagram

18
Bluetooth control home appliances

Android Based Home Automation System Circuit Design:

This project consists of a microcontroller, 16 x 2 alphanumeric LCD, two 5V relays, a lamp,


DC motor and Bluetooth module. Here at89c51 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. We can use 9V DC battery or 12V, 1A adapter to
provide the supply to the circuit. For the above circuit additionally you need to connect reset
circuit and crystal circuit to the controller to work properly.

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.

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
characters.
 AT+PSWD? — Responds with the existing password.
 AT+PSWD =<password> — Sets module pairing password.

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.

Remote Password Operated Home Appliances Control Project Algorithm:

1. Initialize the LCD and UART protocol.


2. Now read the data from Bluetooth module.
3. Display the received data on LCD.
4. Compare the received string with predefined strings and accordingly switch the
electrical loads.
5. Display the status of electrical loads on LCD.

How Bluetooth Controlled Electronic Home Appliances Circuit Works?

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;

After this we have created a function for delay.

void delay(int time)


{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}

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.

void Serialwrite(char byte)


{
SBUF=byte;
while(!TI);
TI=0;
}
void Serialprintln(char *p)

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

You might also like