SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project...

63
i SMART HOME AUTOMATION WITH ZIGBEE A PROJECT REPORT Submitted by SHAWN.G.VIJAYAN Reg.No.: 12BEC139 SINDHUJA.D Reg.No.: 12BEC148 TAMILARASU.M.S Reg.No.: 12BEC168 VINAYASHREE.S.D Reg.No.: 12BEC174 In partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING IN ELECTRONICS AND COMMUNICATION ENGINEERING KUMARAGURU COLLEGEOF TECHNOLOGY (An Autonomous Institution Affiliated to Anna University, Chennai) COIMBATORE-641049 ANNA UNIVERSITY: CHENNAI 600 025 APRIL 2016

Transcript of SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project...

Page 1: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

i

SMART HOME AUTOMATION WITH ZIGBEE

A PROJECT REPORT Submitted by

SHAWN.G.VIJAYAN Reg.No.: 12BEC139

SINDHUJA.D Reg.No.: 12BEC148

TAMILARASU.M.S Reg.No.: 12BEC168

VINAYASHREE.S.D Reg.No.: 12BEC174

In partial fulfillment for the award of the degree

of

BACHELOR OF ENGINEERING

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

KUMARAGURU COLLEGEOF TECHNOLOGY

(An Autonomous Institution Affiliated to Anna University, Chennai)

COIMBATORE-641049

ANNA UNIVERSITY: CHENNAI 600 025

APRIL 2016

Page 2: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

ii

BONAFIDE CERTIFICATE

Certified that this project report titled “SMART HOME AUTOMATION WITH ZIGBEE”

is the bonafide work of Mr. SHAWN.G.VIJAYAN [Reg. No.:12BEC139], Ms.

SINDHUJA.D [Reg. No.:12BEC148], Mr. TAMILARASU.M.S [Reg. No.:12BEC168],

Ms. VINAYASHREE.S.D [Reg. No.:12BEC174], who carried out the project work under

my supervision. Certified further that to the best of my knowledge the work reported herein

does not form part of any other project or dissertation on the basis of which a degree or award

was conferred on an earlier occasion on this or any other candidate.

SIGNATURE SIGNATURE

Mr. S.GOVINDARAJU Dr. A.VASUKI

PROJECT SUPERVISOR HEAD OF THE DEPARTMENT

Department of ECE Department of ECE

Kumaraguru College of Technology Kumaraguru College of Technology

Coimbatore-641 049 Coimbatore-641 049

The candidates with Register No: 12BEC139, 12BEC148, 12BEC168, 12BEC174

are examined by us in the Project viva-voce held on............................

INTERNAL EXAMINER EXTERNAL EXAMINER

Page 3: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

iii

ACKNOWLEDGEMENT

We express our sincere thanks to the Management of Kumaraguru College of

Technology and Joint Correspondent Shri. Shankar Vanavarayar for the kind support and

for providing necessary facilities to carry out the project work.

We would like to express our sincere thanks to our beloved Principal Dr. R.S.Kumar,

Ph.D., Kumaraguru College of Technology, who encouraged us in each and every step of the

project.

We would like to thank Dr. A.Vasuki, Ph.D., Head of the Department, Electronics and

Communication Engineering, for her kind support and for providing necessary facilities to

carry out the project work.

We wish to thank with everlasting gratitude to our Project Coordinator Mr.

R.Karthikeyan, M.E., AP-II, Department of Electronics and Communication Engineering for

his consistent support throughout the course of this project work.

We are greatly privileged to express our deep sense of gratitude and heartfelt thanks to

our Project Guide Mr. SS..GGoovviinnddaarraajjuu (Prof/ECE), Department of Electronics and

Communication Engineering for his/her expert counseling and guidance to make this project

to a great deal of success and also we wish to convey our regards to all teaching and non-

teaching staff of ECE Department for their help and cooperation.

Finally, we thank our parents and our family members for giving us the moral support

and abundant blessings in all of our activities and our dear friends who helped us to endure

our difficult times with their unfailing support and warm wishes.

Page 4: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

iv

ABSTRACT:

The aim of this project “HOME AUTOMATION BASED on ZIGBEE” is to

develop that can be controlled remotely using a landline connection. The home

automation is one of the most emerging trends in modernization of home

appliance control. Presently, conventional wall switches are located in different

parts of the house and one has to physically go near them and press them to turn

the loads on/off. It becomes very difficult for the elderly or physically

handicapped people to do so. Homes of the 21st century will become more and

more self-controlled and automated due to the comfort it provides, especially

when employed in a private home. A home automation system is a means that

allow users to control electric appliances of varying kind. The project ”HOME

AUTOMATION SYSTEM” is using PIC Microcontroller that employs the

integration of wireless sensor networking to provide the user with remote control

of various lights, fans, and appliances with in their home. The system will

automatically change on the basis of sensors’ data. This system is designed to be

low cost and expandable allowing a variety of devices to be controlled. It

becomes very difficult for the elderly or physically handicapped people to do so.

Homes of the 21st century will become more and more self-controlled and

automated due to the comfort it provides, especially when employed in a private

home. A home automation system is a means that allow users to control electric

appliances of varying kind.

TABLE OF CONTENTS

Page 5: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

v

CHAPTER TITLE PAGE NO

1 INTRODUCTION 1

2

3

BLOCK DIAGRAM AND EXPLONATION

CIRCUIT DISCRIPTION

2

2

3.1 WORKING

3.2 WORKING MODULE

4

5

4 HARDWARE DISCRIPTION

4.1 COMPONENTS

7

8

4.1.1 PIN DIAGRAM 9

4.1.2 PIC16F877A FEATURES 10

4.1.2.1 HIGH-PERFORMANCE RISC 11

4.1.2.2 SPECIAL FEATURES 12

4.1.2.3 PERIPHERAL FEATURES 12

4.1.2.4 ANALOG FEATURES 13

4.1.3 MEMORY OF THE PIC16F877 14

4.1.3.1 PROGRAM MEMORY 14

4.1.3.2 DATA MEMORY 15

4.1.3.3 DATA EEPROM 16

4.1.4 PIC16F87XA PROGRAM MEMORY 17

4.1.4.1 PIC16F87XA DATA MEMORY 18

Page 6: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

vi

4.1.4.2 PIC16F87XA DATA EEPROM 19

4.1.5 PIC Timer1 20

4.2 ZIGBEE 23

4.2.1 ZIGBEE RF4CE 24

4.2.2 COMMUNICATION MODELS

4.2.3 USES

25

26

4.3 LCD DISPLAY 28

4.3.1 PIN DESCRIPTION 28

4.3.2 ADVANTAGES 30

4.3.3 APPLICATIONS 31

4.4 POWER SUPPLY UNIT 32

4.4.1 WORKING PRINCIPLE 33

4.4.2 BRIDGE RECTIFIER 35

4.4.3 IC VOLTAGE REGULATORS 35

4.4.4 FILTERS 36

4.5 LED 37

4.5.1 ADVANTAGE 39

5 SOFTWARE DESCRIPTION 40

5.1 MPLAB IDE

40

6 ALGORITHM FOR CODING 41

7 CODING 42

Page 7: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

vii

8 CONCLUSION AND FUTURE SCOPE 52

9 REFERENCE 61

LIST OF FIGURES

FIGURE NO TITLE PAGE NO

3.1 BLOCK DIAGRAM OF TRANSMITTER 2

3.2 BLOCK DIAGRAM OF RECEIVER 3

4.1 PIN DIAGRAM FOR PIC 5

4.2 PIN CONFIGURATION OF PIC 8

4.3 PIC16F876A/877A PROGRAM MEMORY

MAP AND STACK

12

4.4 DIRECT AND INDIRECT ADDRESSING 16

4.5 ZIGBEE COMMUNICATION MODEL 19

4.6 BLOCK DIAGRAM OF POWER SUPPLY 24

4.7 CIRCUIT DIAGRAM OF POWER SUPPLY 26

5.1 PICKIT 1 31

5.2 PICKIT 2 32

5.3 PICKIT 3 33

Page 8: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

viii

7.1 CIRCUIT DIAGRAM 45

7.2 WORKING MODULE OF THE

TRANSMITTING SIDE

46

7.3 WORKING MODULE OF THE RECEIVER

SIDE

46

LIST OF TABLES

TABLE NO. TITLE PAGE NO

3.1 FEATURES OF PIC 6

3.2 DIFFERENCE BETWEEN 16F877A AND

16F887

7

3.3 LCD PINOUT DESCRIPTION 23

ABBREVIATIONS:

PIC – PERIPHERAL INTERFACE CONTROLLER

LCD – LIQUID CRYSTAL DISPLAY

LED – LIGHT EMITTING DIODE

Page 9: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

1

CHAPTER 1

INTRODUCTION

The aim of this project “HOME AUTOMATION BASED Zigbee ”is to develop

that can be controlled remotely using a landline connection. The home

automation is one of the most emerging trends in modernization of home

appliance control. Presently, conventional wall switches are located in different

parts of the house and one has to physically go near them and press them to turn

the loads on/off. It becomes very difficult for the elderly or physically

handicapped people to do so. Homes of the 21st century will become more and

more self-controlled and automated due to the comfort it provides, especially

when employed in a private home. A home automation system is a means that

allow users to control electric appliances of varying kind.

This system is designed to provide control of home appliances through

landline by dialing the designated number for the particular load. Dialing

can be done from the home phone or a call made to the home number

from outside. This system is designed without engaging a programmable

microcontroller but is based on digital logic using DTMF technology

(Dual Tone multiple frequency) which receives the command from the

landline phone to develop digital output.

The concept of this system can be extended in future by giving an

acknowledgement message to the user by system on the status of loads by

using GSM modem.

Page 10: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

2

CHAPTER 2

BLOCK DIAGRAM

2.1 TRANSMITTER SECTION:

Fig 2.1: Block diagram of transmitter

EXPLONATION:

In the transmitter section, the data is being transmitted to the Zigbee

transmitter through input given through software, by which this circuit is

simulated. By adding input through this software, the controller acts

according to the input and data is sent over transmitted Zigbee module to

receiver module since microcontroller is programmed according to the

application. ZigBee is a specification for a suite of high level

PC

SECTION

ZIGBEE

Page 11: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

3

communication protocols using small, low-power digital radios based on

the IEEE 802.15.4-2003 standard for Low-Rate Wireless Personal Area

Networks (LR-WPANs), such as wireless light switches with lamps,

electrical meters with in-home-displays, consumer electronics equipment

via short-range radio.

The technology defined by the ZigBee specification is intended to be simpler

and less expensive than other WPANs, such as Bluetooth. ZigBee is targeted at

radio-frequency (RF) applications that require a low data rate, long battery life,

and secure networking.

The most capable device, the coordinator forms the root of the network tree and

might bridge to other networks. There is exactly one ZigBee coordinator in each

network since it is the device that started the network originally. It is able to

store information about the network, including acting as the Trust Centre &

repository for security keys.

In the transmitting type cell, both glass sheets are transparent, so that light from

a rear source is scattered in the forward direction when the cell is activated. In

reflective type cell has a reflecting surface on one side of glass sheets. The

incident light on the front surface of the cell is dynamically scattered by an

activated cell.

ZigBee protocols are intended for use in embedded applications requiring low

data rates and low power consumption. ZigBee current focus is to define a

general-purpose, inexpensive, self-organizing mesh network that can be used for

industrial control, embedded sensing, medical data collection, smoke and

intruder warning, building automation, home automation, etc. The resulting

network will use very small amounts of power — individual devices must have a

battery life of at least two years to pass ZigBee certification.

Page 12: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

4

2.2 RECEIVER SECTION:

Fig 2.2: Block diagram of receiver

EXPLONATION:

In receiver section, data that is transmitted as a buffer is being received and sent

to the output ports of controller. The controller sends corresponding signals to

the devices connected to it. Here, the output devices are fan, LED, LCD Display.

PIC16F

877A

Micro

Controller

Power Supply

LCD

Zigbee

Fan

Light

Page 13: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

5

The fan is connected to the controller through relay. Relay can be used to

convert power level to the fan. 5V of power is magnified to 12V.

ZigBee is a specification for a suite of high level communication protocols using

small, low-power digital radios based on the IEEE 802.15.4-2003 standard for

Low-Rate Wireless Personal Area Networks (LR-WPANs), such as wireless

light switches with lamps, electrical meters with in-home-displays, consumer

electronics equipment via short-range radio. In the transmitting type cell, both

glass sheets are transparent, so that light from a rear source is scattered in the

forward direction when the cell is activated.

In reflective type cell has a reflecting surface on one side of glass sheets. The

incident light on the front surface of the cell is dynamically scattered by an

activated cell.

The technology defined by the ZigBee specification is intended to be simpler

and less expensive than other WPANs, such as Bluetooth. ZigBee is targeted at

radio-frequency (RF) applications that require a low data rate, long battery life,

and secure networking.

Page 14: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

6

CHAPTER 3

CIRCUIT DIAGRAM

Fig 3.1: Circuit diagram

3.1 WORKING:

The main objectives of this research is to design and implement a home

automation system using ZIGBEE that is capable of controlling and automating

most of the house appliances through an easy manageable web interface. The

proposed system has a great flexibility by using ZIGBEE technology to

interconnect its distributed sensors to home automation. This will decrease the

deployment cost and will increase the ability of upgrading, and system

Page 15: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

7

reconfiguration. We design a PROTEUS design for a control and monitor.

Initially the signal from the transmitting Zigbee moves to the PIC in the form of

a buffer. The buffer is converted as data and is send to the receiving Zigbee.

Then the data is displayed in the LED. If the given command is to ON the light

then the light is ON and the same applies for the OFF command. Here we use

only the light and fan.

3.2 WORKING MODULE:

3.2.1 TRANSMITTER:

Fig 3.2: Transmitter

In the transmitter section, the data is being transmitted to the Zigbee transmitter

through input given through software, by which this circuit is simulated. The

proposed system has a great flexibility by using ZIGBEE technology to

interconnect its distributed sensors to home automation. This will decrease the

deployment cost and will increase the ability of upgrading, and system

reconfiguration. We design a PROTEUS design for a control and monitor. By

adding input through this software, the controller acts according to the input and

Page 16: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

8

data is sent over transmitted Zigbee module to receiver module since

microcontroller is programmed according to the application.

3.2.2 RECIEVER:

Fig 3.3: Receiver

In receiver section, data that is transmitted as a buffer is being received and sent

to the output ports of controller. The proposed system has a great flexibility by

using ZIGBEE technology to interconnect its distributed sensors to home

automation. This will decrease the deployment cost and will increase the ability

of upgrading, and system reconfiguration. We design a PROTEUS design for a

control and monitor. The controller sends corresponding signals to the devices

connected to it. Here, the output devices are fan, LED, LCD Display. The fan is

connected to the controller through relay. Relay can be used to convert power

level to the fan. 5V of power is magnified to 12V.

Page 17: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

9

CHAPTER 4

HARDWARE DESCRIPTION

COMPONENTS:

PIC16F877A

LCD

LED

RELAY

COOLING FAN

ZIGBEE

4.1 PIC MICROCONTROLLER:

The PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward

compatible with the PIC16C5x, PIC12Cxxx and PIC16C7x devices. It features

200 ns instruction execution, 256 bytes of EEPROM data memory, self

programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital

(A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port

that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a

Parallel Slave Port.

Page 18: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

10

Fig 4.1: Pin diagram for PIC

Early models of PIC had read-only memory (ROM) or field

programmable EPROM for program storage, some with provision for erasing

memory. All current models use Flash memory for program storage, and newer

models allow the PIC to reprogram itself. Program memory and data memory

are separated. Data memory is 8-bit, 16-bit and in latest models, 32-bit wide.

Program instructions vary in bit-count by family of PIC, and maybe 12, 14, 16,

or 24 bits long. The instruction set also varies by model, with more powerful

chips adding instructions for digital signal processing functions. The hardware

capabilities of PIC devices range from 8-pin DIP chips up to 100-pin SMD

chips, with discrete I/O pins, ADC and DAC modules, and communications

ports such as UART, I2C, CAN, and even USB. Low power and high-speed

variations exist for many types.

Page 19: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

11

Table 4.1: Features of PIC

The hardware capabilities of PIC devices range from 8-pin DIP chips up to 100-

pin SMD chips, with discrete I/O pins, ADC and DAC modules, and

communications ports such as UART, I2C, CAN, and even USB. Low power

and high-speed variations exist for many types

Page 20: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

12

Table 4.2: Differences between 16F877A and16F887

The four features that you might cause you to use a 16F887 instead of a

16F877(A) are

External gate

Volt Reference

Nano WattTM

Internal Clock

Page 21: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

13

4.1.1 PIN DIAGRAM:

Fig 4.2: PIN Configuration of PIC 16F877A

Page 22: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

14

4.1.2 Microchip PIC16F877A Microcontroller Features:

4.1.2.1 High-Performance RISC CPU

Operating speed: 20 MHz, 200 ns instruction cycle

Operating voltage: 4.0-5.5V

Industrial temperature range (-40° to +85°C)

15 Interrupt Sources

35 single-word instructions

All single-cycle instructions except for program branches (two-cycle)

4.1.2.2 Special Microcontroller Features

Flash Memory: 14.3 Kbytes (8192 words

Data SRAM: 368 bytes

Data EEPROM: 256 bytes

Self-reprogrammable under software control

In-Circuit Serial Programming via two pins (5V)

Watchdog Timer with on-chip RC oscillator

Programmable code protection

Power-saving Sleep mode

Selectable oscillator options

In-Circuit Debug via two pins

4.1.2.3 Peripheral Features

33 I/O pins; 5 I/O ports

Page 23: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

15

Timer0: 8-bit timer/counter with 8-bit pre scalar

Timer1: 16-bit timer/counter with pre scalar

o Can be incremented during Sleep via external crystal/clock

Timer2: 8-bit timer/counter with 8-bit period register, pre scalar and post

scalar

Two Capture, Compare, PWM modules

o 16-bit Capture input; max resolution 12.5 ns

o 16-bit Compare; max resolution 200 ns

o 10-bit PWM

Synchronous Serial Port with two modes:

SPI Master

I2C Master and Slave

USART/SCI with 9-bit address detection

Parallel Slave Port (PSP)

8 bits wide with external RD, WR and CS controls

4.1.2.4 Analog Features

10-bit, 8-channel A/D Converter

Brown-Out Reset

Analog Comparator module

Programmable on-chip voltage reference module

Programmable input multiplexing from device inputs and internal VREF.

Page 24: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

16

4.1.3 Memory of the PIC16F877 divided into 3 types of memories:

4.1.3.1 Program Memory

A memory that contains the program(which we had written), after we’ve

burned it. As a reminder, Program Counter executes commands stored in the

program memory, one after the other.

4.1.3.2 Data Memory

This is RAM memory type, which contains a special registers like SFR

(Special Faction Register) and GPR (General Purpose Register). The variables

that we store in the Data Memory during the program are deleted after we turn of

the micro. These two memories have separated data buses, which makes the

access to each one of them very easy.

4.1.3.3 Data EEPROM (Electrically Erasable Programmable Read-

Only Memory)

A memory that allows storing the variables as a result of burning the

written program. Each one of them has a different role. Program Memory and

Data Memory two memories that are needed to build a program, and Data

EEPROM is used to save data after the microcontroller is turn off. Program

Memory and Data EEPROM they are non-volatile memories, which store the

information even after the power is turn off. These memories called Flash Or

EEPROM. In contrast, Data Memory does not save the information because it

needs power in order to maintain the information

Page 25: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

17

4.1.4 PIC16F87XA Program Memory

The PIC16F87XA devices have a 13-bit program counter capable of

addressing an 8K word x 14 bit program memory space. This memory is used to

store the program after we burn it to the microcontroller. The

PIC16F876A/877A devices have 8K words x 14 bits of Flash program memory

that can be electrically erased and reprogrammed.

Each time we burn program into the micro, we erase an old program and

write a new one. Each time the main program execution starts at address 0000 –

Reset Vector. The address 0004 is “reserved” for the “interrupt service routine”

(ISR). If we plan to use an interrupt, our program will begin after the Interrupt

Vector; and if not we can start to write from the beginning of the Reset Vector.

The PIC16F87XA family has an 8-level deep x 13-bit wide hardware stack. The

stack space is not part of either program or data space and the stack pointer is not

readable or writable.

In the PIC microcontrollers, this is a special block of RAM memory used

only for this purpose. Program Counter (PC) keeps track of the program

execution by holding the address of the current instruction. Program Memory

and Data EEPROM they are non-volatile memories, which store the information

even after the power is turn off.

It is automatically incremented to the next instruction during the current

instruction execution. Each one of them has a different role. Program Memory

and Data Memory two memories that are needed to build a program, and Data

EEPROM is used to save data after the microcontroller is turn off.

Page 26: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

18

Fig 4.3:PIC16F876A/877A program memory map and stack

Program Counter (PC) keeps track of the program execution by holding the

address of the current instruction. It is automatically incremented to the next

instruction during the current instruction execution.

The PIC16F87XA family has an 8-level deep x 13-bit wide hardware stack. The

stack space is not part of either program or data space and the stack pointer is not

readable or writable. In the PIC microcontrollers, this is a special block of RAM

memory used only for this purpose.

Page 27: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

19

The CALL instruction is used to jump to a subroutine, which must be

terminated with the RETURN instruction. CALL has the address of the first

instruction in the subroutine as its operand. When the CALL instruction is

executed, the destination address is copied to the PC. The PC is pushed onto the

stack when a CALL instruction is executed, or an interrupt causes a branch. The

stack is popped in the event of a RETURN, RETLW or a RETFIE instruction

execution.

The stack operates as a circular buffer. This means that after the stack has

been pushed eight times, the ninth push overwrites the value that was stored

from the first push. The tenth push overwrites the second push (and so on). Each

time the main program execution starts at address 0000 – Reset Vector. The

address 0004 is “reserved” for the “interrupt service routine” (ISR). If we plan to

use an interrupt, our program will begin after the Interrupt Vector; and if not we

can start to write from the beginning of the Reset Vector. Some of the memory is

divided into the pages that are designed for write/burn the program into them;

the remaining memory (Stack, Interrupt Vector, and Reset Vector) is hardware

registers.

4.1.4.1 PIC16F87XA Data Memory Organization

The data memory is partitioned into multiple banks which contain the

General Purpose Registers and the Special Function Registers. Number of banks

may vary depending on the microcontroller; for example, micro PIC16F84 has

only two banks.

Page 28: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

20

Each bank extends up to 7Fh (128 bytes). The lower locations of each

bank are reserved for the Special Function Registers. Above the Special

Function Registers are General Purpose Registers, implemented as static RAM.

While program is being executed, it is working with the particular bank. To

access a register that is located in another bank, one should access it inside the

program. There are special registers which can be accessed from any bank, such

as STATUS register.

4.1.4.2 PIC16F87XA Data EEPROM

The data EEPROM and Flash program memory is readable and writable

during normal operation (over the full VDD range). This memory is not directly

mapped in the register file space. Instead, it is indirectly addressed through the

Special Function Registers.

There are six SFRs used to read and write to this memory:

EECON1

EECON2

EEDATA

EEDATH

EEADR

EEADRH

When interfacing to the data memory block, EEDATA holds the 8-bit data

for read/write and EEADR holds the address of the EEPROM location being

accessed. These devices have 128 or 256 bytes of data EEPROM (depending on

the device), with an address range from 00h to FFh. On devices with 128 bytes,

addresses from 80h to FFh are unimplemented.

A few important points about Data EEPROM memory:

Page 29: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

21

It lets you save data DURING programming

The data is saved during the “burning” process

You can read the data memory during the programming and use it

The use is made possible with the help of SFR

At this point there is no need to learn how to use this memory with special

registers, because there are functions (writing and reading) that are ready.

Direct Addressing: Using this method we are accessing the registers

directly by detecting location inside Data Memory from Opcode and by selecting

the bank using bits RP1 and RP0 of the STATUS register.

Indirect Addressing: To implement indirect addressing, a File Select

Register (FSR) and indirect register (INDF) are used. In addition, when using

this method we choose bank using bit IRP of the STATUS register. Indirect

addressing treated like a stack pointer, allowing much more efficient work with a

number of variables. INDF register is not an actual register (it is a virtual register

that is not found in any bank).

There is SFR (Special Function Register) – special registers of RAM, and

there is FSR (File Select Register).

The following figure shows the two addressing methods:

Example of direct addressing:

TEMP Equ 0x030

Movlw 5

Movwf TEMP

It’s easy to understand, that direct addressing method means working

directly with the variables. In the second line we put the number 5 into the

working register W, and in the line 3, the content of the W passes to the TEMP

variable.

Page 30: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

22

Example of indirect addressing:

TEMP Equ 0x030

Movlw 0x030

Movwf FSR

Movlw 5

Movwf INDF

In the second line, we put a value into the W register. In the third line, the

value passes to the FSR register, and from this moment FSR points to the

address of the TEMP variable. In the fourth line, the number 5 passes to the W

register, and in the fifth line, we move the contents of W register (which is 5) to

the INDF. In fact INDF performs the following: it takes the number 5 and puts it

in the address indicated by FSR register.

Fig 4.4: Direct and Indirect addressing

Page 31: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

23

4.1.5 PIC Timer1:

The Timer1 module, timer/counter, has the following features:

16-bit timer/counter consisting of two 8-bit registers (TMR1H and

TMR1L).

readable and writable.

8-bit software programmable pre scalar.

Internal (4 MHz) or external clock select.

Interrupt on overflow from FFFFh to 0000h.

4.2 ZIGBEE:

ZigBee is a specification for a suite of high level communication protocols

using small, low-power digital radios based on the IEEE 802.15.4-2003 standard

for Low-Rate Wireless Personal Area Networks (LR-WPANs), such as wireless

light switches with lamps, electrical meters with in-home-displays, consumer

electronics equipment via short-range radio. The technology defined by the

ZigBee specification is intended to be simpler and less expensive than other

WPANs, such as Bluetooth. ZigBee is targeted at radio-frequency (RF)

applications that require a low data rate, long battery life, and secure networking.

Technical overview

ZigBee is a low-cost, low-power, wireless mesh networking standard.

First, the low cost allows the technology to be widely deployed in wireless

control and monitoring applications. Second, the low power-usage allows longer

life with smaller batteries. Third, the mesh networking provides high reliability

and more extensive range.

Released Specifications:

ZigBee Home Automation

Page 32: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

24

ZigBee Smart Energy 1.0

ZigBee Telecommunication Services

ZigBee Health Care

ZigBee Remote Control

Specifications under development:

ZigBee Smart Energy 2.0

ZigBee Building Automation

ZigBee Retail Services.

There are three different types of ZigBee devices:

ZigBee coordinator (ZC): The most capable device, the coordinator forms

the root of the network tree and might bridge to other networks. There is

exactly one ZigBee coordinator in each network since it is the device that

started the network originally. It is able to store information about the

network, including acting as the Trust Centre & repository for security

keys.

ZigBee Router (ZR): As well as running an application function, a router

can act as an intermediate router, passing on data from other devices.

ZigBee End Device (ZED): Contains just enough functionality to talk to

the parent node (either the coordinator or a router); it cannot relay data

from other devices. This relationship allows the node to be asleep a

significant amount of the time thereby giving long battery life. A ZED

requires the least amount of memory, and therefore can be less expensive

to manufacture than a ZR or ZC.

Page 33: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

25

4.2.1 ZigBee RF4CE:

The software is designed to be easy to develop on small, inexpensive

microprocessors. The radio design used by ZigBee has been carefully optimized

for low cost in large scale production. It has few analog stages and uses digital

circuits wherever possible.

Even though the radios themselves are inexpensive, the ZigBee

Qualification Process involves a full validation of the requirements of the

physical layer. This amount of concern about the Physical Layer has multiple

benefits, since all radios derived from that semiconductor mask set would enjoy

the same RF characteristics.

On the other hand, an uncertified physical layer that malfunctions could cripple

the battery lifespan of other devices on a ZigBee network. Where other protocols

can mask poor sensitivity or other esoteric problems in a fade compensation

response, ZigBee radios have very tight engineering constraints: they are both

power and bandwidth constrained.

Thus, radios are tested to the ISO 17025 standard with guidance given by Clause

6 of the 802.15.4-2006 Standard. Most vendors plan to integrate the radio and

microcontroller onto a single chip getting smaller devices.

4.2.2 Communication models:

ZigBee high-level communication model. An application may consist of

communicating objects which cooperate to carry out the desired tasks. The focus

of ZigBee is to distribute work among many different devices which reside

within individual ZigBee nodes which in turn form a network (said work will

typically be largely local to each device, for instance the control of each

individual household appliance).

Page 34: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

26

Fig 4.5: ZIGBEE Communication model

4.2.3 Uses of Zigbee protocol:

ZigBee protocols are intended for use in embedded applications requiring

low data rates and low power consumption. ZigBee current focus is to define a

general-purpose, inexpensive, self-organizing mesh network that can be used for

industrial control, embedded sensing, medical data collection, smoke and

intruder warning, building automation, home automation, etc. The resulting

network will use very small amounts of power — individual devices must have a

battery life of at least two years to pass ZigBee certification.

XBee is used to create personal area networks built from a small low-

power digital radios. ZigBee is based on an IEEE 802.15.4 standard. Though its

low power consumption limits transmission distances to 10–100 meters line-of-

sight, depending on power output and environmental characteristics, ZigBee

Page 35: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

27

devices can transmit data over long distances by passing data through a mesh

network of intermediate devices to reach more distant ones.

ZigBee is typically used in low data rate applications that require long

battery life and secure networking (ZigBee networks are secured by 128

bit symmetric encryption keys.) ZigBee has a defined rate of 250 kbit/s, best

suited for intermittent data transmissions from a sensor or input device.

Applications include wireless light switches, electrical meters with in-home-

displays, traffic management systems, and other consumer and industrial

equipment that requires short-range low-rate wireless data transfer. The

technology defined by the ZigBee specification is intended to be simpler and less

expensive than other wireless personal area networks (WPANs), such

as Bluetooth or Wi-Fi.

Typical application areas include

Home Entertainment and Control — Smart lighting, advanced

temperature control, safety and security, movies and music

Wireless Sensor Networks’ — starting with individual sensors like

Telosb/Tmote and Iris from Memsic.

Zigbee technology has many useful features and characteristics and

these features of Zigbee technology are the reason of its increase demand

in the commercial zone particularly in commercial and residential at time

lesser but prospects are better.

Zigbee technology allows wireless networking to connect several units to

control through one button like in business industry. This wireless

networking avoids the threat of short circuiting. Centralization control

system reduces the man power.

Page 36: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

28

As a wireless communication system Zigbee technology helps to monitor

the activities and manipulates in a better way.

Zigbee technology used in the remote control devices helps to control the

function at a specific range. This feature of Zigbee Technology is very

attractive and effortless as all the home appliances are mostly coming with

remote control system which is the essence of this Zigbee wireless

technology. In industry all the units are centralized in one place with the

help of remote control or switch-based system.

As Zigbee technology based devices are designed on low-power

frequency therefore are reliable. Low-power consumption feature of

Zigbee technology helps to run a device for a long duration or sometimes

this duration is of years.

Bluetooth application gives a unique feature of transferring information or

data from one place to another in a far better way than Bluetooth itself.

Zigbee technology is used in three different types of devices which are

used in networking according to its functionality. As prominently Zigbee

is a wireless technology for making a network system, coordinators are

the primary devices to help in activation of the system by collecting the

data in form of memory. Then router comes as a secondary device to

perform the function by sending information to the destination. Third

types of Zigbee based devices are the end-user devices. These are

basically receiver so are not able to send information itself. It remains in

sleep mode while not in use so less amount of battery uses and resultantly

longer life.

Page 37: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

29

Comparison of Zigbee with other wireless technologies:

4.3 LCD DISPLAY:

Liquid crystal cell displays (LCDs) are used in similar applications where

LEDs are used. These applications are display of display of numeric and

alphanumeric characters in dot matrix and segmental displays.

LCDs are of two types:

1. Dynamic scattering type

2.Field effect type

The construction of a dynamic scattering liquid crystal cell. The liquid

crystal material may be one of the several components, which exhibit optical

properties of a crystal though they remain in liquid form. Liquid crystal is

Page 38: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

30

layered between glass sheets with transparent electrodes deposited on the inside

faces.

When a potential is applied across the cell, charge carriers flowing through the

liquid disrupt the molecular alignment and produce turbulence. When the liquid

is not activated, it is transparent. When the liquid is activated the molecular

turbulence causes light to be scattered in all directions and the cell appease to be

bright.This phenomenon is called dynamic scattering.

The construction of a field effect liquid crystal display is similar to that of

the dynamic scattering type, with the exception that two thin polarizing optical

filters are placed at the inside of each glass sheet. The liquid crystal material in

the field effect cell is also of different type from employed in the dynamic

scattering cell. The material used is twisted nomadic type and actually twists the

light passing through the cell when the latter is not energised.

Liquid crystal cells are of two types:

1.Transmittive type

2. Reflective type

In the transmittive type cell, both glass sheets are transparent, so that light

from a rear source is scattered in the forward direction when the cell is activated.

In reflective type cell has a reflecting surface on one side of glass sheets. The

incident light on the front surface of the cell is dynamically scattered by an

activated cell.

The liquid crystals are light reflectors are transmitters and therefore they

consume small amounts of energy (unlike light generators).

The seven segment display, the current is about 25micro Amps for

dynamic scattering cells and 300micro amps for field effect cells. Unlike LEDs

which can work on d.c. the LCDs require a.c. voltage supply. A typical voltage

supply to dynamic scattering LCD is 30v peak to peak with 50 Hz

Page 39: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

31

4.3.1 PIN DESCRIPTION:

PIN NO SYMBOL FUNCTION

1 Vss Ground terminal of

Module

2 Vdd Supply terminal of

Module, +

5v

3 Vo Power supply for liquid

crystal drive

4 RS Register select

RS=0…Instruction

register

RS=1…Data register

5 R/W Read/Write

R/W=1…Read

R/W=0…Write

6 E(EI) Enable

7-14 DB0-DB7 Bi-directional Data Bus.

Data Transfer is

performed once ,thru

DB0-DB7,incase of

interface data length is

8-bits;and twice, thru

DB4-DB7 in the case of

Page 40: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

32

interface data length is

4-bits.Upper four bits

first then lower four bits.

15 LAMP-(L-) LED or EL lamp power

supply terminals

16 LAMP+(L+)

(E2)

Enable

Table 4.3: LCD pin out description

4.3.2 ADVANTAGES:

Consume much lesser energy (i.e. low power) when compared to LEDs.

Utilizes the light available outside and no generation of light.

Since very thin layer of liquid crystal is used, more suitable to act as

display elements (in digital watches, pocket calculators, ect.)

Since reflectivity is highly sensitive to temperature, used as temperature

measuring sensor.

Very cheap.

4.3.3 APPLICATIONS:

Watches

Fax & Copy machines & Calculators.

4.4 POWER SUPPLY UNIT:

The ac voltage, typically 220V rms, is connected to a transformer, which

steps that ac voltage down to the level of the desired dc output. A diode rectifier

then provides a full-wave rectified voltage that is initially filtered by a simple

Page 41: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

33

capacitor filter to produce a dc voltage. This resulting dc voltage usually has

some ripple or ac voltage variation.

A regulator circuit removes the ripples and also remains the same dc value

even if the input dc voltage varies, or the load connected to the output dc voltage

changes. This voltage regulation is usually obtained using one of the popular

voltage regulator IC units.

Fig 4.6: Block diagram (Power supply)

4.4.1 Working principle:

Transformer:

The potential transformer will step down the power supply voltage (0-

230V) to (0-6V) level. Then the secondary of the potential transformer will be

connected to the precision rectifier, which is constructed with the help of op–

amp. The advantages of using precision rectifier are it will give peak voltage

output as DC, rest of the circuits will give only RMS output.

4.4.2 Bridge rectifier:

When four diodes are connected as shown in figure, the circuit is called as

bridge rectifier. The input to the circuit is applied to the diagonally opposite

corners of the network, and the output is taken from the remaining two corners.

Let us assume that the transformer is working properly and there is a

positive potential, at point A and a negative potential at point B. the positive

potential at point A will forward bias D3 and reverse bias D4.

TRANSFORMER

RECTIFIER

FILTER

IC

REGULATOR

LOAD

Page 42: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

34

The negative potential at point B will forward bias D1 and reverse D2. At

this time D3 and D1 are forward biased and will allow current flow to pass

through them; D4 and D2 are reverse biased and will block current flow. The

path for current flow is from point B through D1, up through RL, through D3,

through the secondary of the transformer back to point B. this path is indicated

by the solid arrows. Waveforms (1) and (2) can be observed across D1 and D3.

One-half cycle later the polarity across the secondary of the transformer

reverse, forward biasing D2 and D4 and reverse biasing D1 and D3. Current

flow will now be from point A through D4, up through RL, through D2, through

the secondary of T1, and back to point A.

This path is indicated by the broken arrows. Waveforms (3) and (4) can be

observed across D2 and D4. The current flow through RL is always in the same

direction. In flowing through RL this current develops a voltage corresponding

to that shown waveform (5). Since current flows through the load (RL) during

both half cycles of the applied voltage, this bridge rectifier is a full-wave

rectifier.

4.4.3 IC voltage regulators:

Voltage regulators comprise a class of widely used Ics. Regulator IC units

contain the circuitry for reference source, comparator amplifier, control device,

and overload protection all in a single IC. IC units provide regulation of either a

fixed positive voltage, a fixed negative voltage, or an adjustably set voltage. The

regulators can be selected for operation with load currents from hundreds of

milli amperes to tens of amperes, corresponding to power ratings from milli

watts to tens of watts.

A fixed three-terminal voltage regulator has an unregulated dc input

voltage, Vi, applied to one input terminal, a regulated dc output voltage, Vo,

Page 43: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

35

from a second terminal, with the third terminal connected to ground. The series

78 regulators provide fixed positive regulated voltages from 5 to24 volts.

Similarly, the series 79 regulators provide fixed negative regulated voltages from

5 to 24 volts.

For Ics, microcontroller, LCD --- 5 volts

For alarm circuit, op-amp, relay circuits ---12 volts

Fig 4.7: Circuit diagram (Power supply)

4.4.4 Filters:

Capacitors are used as filters in the power supply unit. Shunting the load

with the capacitor, effects filtering. The action of the system depends upon the

fact the capacitor stores energy during the conduction period and delivers this

energy to the load during the inverse or non-conducting period. In this way, time

Page 44: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

36

during which the current passes through the load is prolonged and ripple is

considerably reduced.

4.5 LED:

A light-emitting diode (LED) is a two-lead semiconductor light source. It

is a p–n junction diode, which emits light when activated.[4]When a

suitable voltage is applied to the leads, electrons are able to recombine

with electron holes within the device, releasing energy in the form of photons.

This effect is called electroluminescence, and the color of the light

(corresponding to the energy of the photon) is determined by the energy band

gap of the semiconductor.

4.5.1 ADVANTAGE:

Lifetime

As solid-state light sources, LEDs have very long lifetimes and are

generally very robust. While incandescent bulbs may have an expected

lifetime (to failure) of 1000 hours, LEDs are often quoted of having a

lifetime of up to 100,000 hours – more than 11 years. However, this figure

is extremely misleading; like all other light sources, the performance of

LEDs degrades over time, and this degradation is strongly affected by

factors such as operating current and temperature.

At present, there is no standard definition of lifetime for LEDs, although

various parties have suggested that lifetime should be the time taken for

the LED’s output to fall to some percentage (such as 70% or 50%) of its

original value.

Standardization

The general lack of standardization in the LED field is an ongoing issue.

Page 45: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

37

Various standards relating to LEDs exist in areas such as automotive

lighting and traffic signals. Other efforts are being conducted by bodies

such as CIE, NEMA and IES.

Lowmaintanace

The long lifetime of LEDs reduces the need to replace failed lamps, and

this can lead to significant savings, particularly in the cost of sending out

maintenance crews. This also makes LED fixtures useful for installation

in relatively inaccessible locations. However, if tasks like cleaning the

light fixture or performing electrical checks need to be carried out

regularly, then the light sources could be replaced at the same time,

negating the “low maintenance” advantage.

Efficiency

LEDs are high-efficiency light sources. White LEDs with efficacies of 25

lm/W and up are commercially available, exceeding the performance of

incandescent and some fluorescent sources. The directional nature of light

produced by LEDs allows the design of luminaries with higher overall

efficiency.

Lowpowerconsumption

The low power consumption of LEDs leads to significant energy

savings that can often drive the installation of LED-based systems, for

example traffic signals. National programs to develop effective solid-state

lighting industries in the US and Japan have been driven by the potential

energy savings associated with using LEDs.

Brightness

Although LEDs have high efficiency and consume a small amount of

power, the devices produce a small total number of lumens. For example,

a 60 W incandescent bulb with an efficiency of 20 lm/W produces 1200

Page 46: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

38

lumens. A one-watt LED with an efficiency of 30 lm/W produces only 30

lumens i.e. 40 such LEDs are required to produce the same amount of light as

the incandescent bulb.

Heat

LEDs don’t produce heat in the form of infrared radiation, which makes

incandescent bulbs hot to the touch. The absence of IR radiation allows

LED fixtures to be positioned in locations where heating from

conventional sources would cause a particular problem e.g. illuminating

food or textiles.

However, LEDs do produce heat at the semiconductor junction within the

device. The wall-plug efficiency (optical power out divided by electrical

power in) of LED packages is typically in the region of 5-40%, meaning

that somewhere between 60 and 95% of the input power is lost as heat.

Without very efficient thermal management and heat sinking this causes

the junction temperature of the LED to rise, which causes the LED

characteristics to change. Driving LEDs above their rated current causes

the junction temperature to rise to levels where permanent damage may

occur.

Cost

In many applications, LEDs are expensive compared with other light

sources, when measured by metrics such as “dollars-per-lumen”. LED

manufacturers continue to work towards reducing their production costs

while at the same time increasing the light output of their devices.

However, the high initial cost of LED-based systems is offset by lower

energy consumption, lower maintenance costs and other factors.

Page 47: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

39

Smallform-factors

LEDs are very small – typical high-brightness LED chips measure 0.3 mm

by 0.3 mm, while high-power devices can be 1 mm x 1 mm or larger.

There are many examples where the availability of small, high-brightness

devices have enabled significant market advancement. The obvious

example is in mobile phone handsets, where blue, green and white LEDs

are now used in most models to backlight keypads and liquid-crystal

display (LCD) screens.

Instantaneousswitch-on

LEDs switch on rapidly, even when cold, and this is a particular

advantage for certain applications such as vehicle brake lights.

Colour

LEDs are available in a broad range of brilliant, saturated colors (although

performance varies across the spectrum), and white devices are also

available. Modules containing different-colored LEDs (typically red,

green and blue, or RGB) can be tuned to a huge range of colors, and easily

dimmed. RGB modules provide a much wider gamut of colors than white

LEDs or other traditional white light sources, which is a particular

advantage in applications such as backlighting liquid-crystal displays

(LCDs).

RGBLEDsandcolormixing

LED characteristics change with time, temperature and current, and from

device to device. For RGB LEDs, the performance of different-colored

devices changes at different rates. This can result in variation of lamp

color and intensity, and poor reproducibility.

WhiteLED

The color of white LEDs can be very inconsistent, although manufacturers

Page 48: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

40

have narrowed their binning ranges. White LEDs with the same correlated

color temperature can have different color tints perceptible to the human

eye.

Colored LEDs (typically red, green and blue, or RGB) can be tuned to a

huge range of colors, and easily dimmed. RGB modules provide a much

wider gamut of colors than white LEDs or other traditional white light

sources, which is a particular advantage in applications such as

backlighting liquid-crystal displays (LCDs).

Without very efficient thermal management and heat sinking this causes

the junction temperature of the LED to rise, which causes the LED

characteristics to change. Driving LEDs above their rated current causes

the junction temperature to rise to levels where permanent damage may

occur.

Page 49: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

41

CHAPTER 5

ALGORITHM FOR CODING

Download MPLAB IDE and use the tutorial in the MPLAB IDE User’s

Guide at the bottom of this page to explore how easy it is to create an

application. Write assembly code, build and assemble your project with

MPLAB’s wizards, then test your code with the built-in simulator and debugger.

When you are ready to test your own application, select one of our low-cost

debugger/programmers to program a device and analyze your hardware.

Choose MPLAB C Compilers, the highly optimized compilers for the

PIC18 series microcontrollers, high performance PIC24 MCUs, dsPIC digital

signal controllers and PIC32MX MCUs. Or, use one of the many products from

third party language tools vendors. Most integrate into MPLAB IDE to function

transparently from the MPLAB project manager, editor and debugger.

Page 50: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

42

CHAPTER 6

PROGRAM CODING

RECEIVER

#include<htc.h>

#include<pic.h>

#include "delay.c"

#define XTAL_FREQ 20MHZ

__CONFIG(HS & PWRTEN & BOREN & WDTDIS & UNPROTECT &

LVPDIS);

char a;

void enable()

{

RD7=1;

DelayMs(1);

RD7=0;

}

void lcdcmd(unsigned char cmd )

{

Page 51: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

43

PORTB=cmd;

enable();

}

void lcddata(unsigned char data)

{

RD5=1;

PORTB=data;

enable();

RD5=0;

}

void lcdstring(const unsigned char *st)

{

while(*st)

lcddata(*st++);

}

unsigned char receive()

{

if(OERR){RCIE=0;RCIE=1;}

while(!RCIF);

return(RCREG);

Page 52: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

44

}

void transmit(unsigned char data)

{

while(!TXIF);

TXREG =data;

TXIF = 1;

}

void usartstring(const unsigned char *st)

{

while(*st)

transmit(*st++);

}

void init()

{

TXSTA = 0X24; //configure the TX for 8-bit width

RCSTA = 0X90; //configure the RX for 8-bit width

SPBRG = 25; //9600 baud rate for 20MHZ

INTCON = 0XC0; //configure the Global & peripheral

interrupts

Page 53: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

45

RCREG = 0;

}

void interrupt isr()

{

if(RCIF){

a=receive();

RCIF=0;

PEIE=0;

GIE=0;

RCIE=0;

}

}

void main()

{

PORTB=0x00;

TRISB=0x00;

PORTD=0x00;

TRISD=0x00;

TRISC = 0x80;//configure the pin directions for UART comm

PORTC = 0x00;

Page 54: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

46

ADCON1=0x06;

lcdcmd(0x38);

lcdcmd(0x06);

lcdcmd(0x0C);

init();

while(1)

{

PEIE=1;

GIE=1;

RCIE=1;

lcdcmd(0x80);

lcdstring("FAN :");

lcdcmd(0xC0);

lcdstring("LIGHT:");

if(a=='0'){lcdcmd(0x86);

lcdstring(" ON ");

RC0=1;}

if(a=='1'){lcdcmd(0x86);

lcdstring(" OFF ");

RC0=0;

Page 55: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

47

}

if(a=='2'){lcdcmd(0xC6);

lcdstring(" ON ");

RC1=1;}

if(a=='3'){lcdcmd(0xC6);

lcdstring(" OFF ");

RC1=0;}

}

}

TRANSMITTER

#include<htc.h>

#include<pic.h>

#include "delay.c"

#define XTAL_FREQ 20MHZ

__CONFIG(HS & PWRTEN & BOREN & WDTDIS & UNPROTECT &

LVPDIS);

void enable()

{

RD7=1;

Page 56: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

48

DelayMs(1);

RD7=0;

}

void lcdcmd(unsigned char cmd )

{

PORTB=cmd;

enable();

}

void lcddata(unsigned char data)

{

RD5=1;

PORTB=data;

enable();

RD5=0;

}

void lcdstring(const unsigned char *st)

{

while(*st)

lcddata(*st++);

Page 57: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

49

}

unsigned char receive()

{

while(!RCIF);

return(RCREG);

}

void transmit(unsigned char data)

{

while(!TXIF);

TXREG =data; //transmitting the data through TX buffer

}

void init()

{

TXSTA = 0X24; //configure the TX for 8-bit width

RCSTA = 0X90; //configure the RX for 8-bit width

SPBRG = 25; //9600 baud rate for 20MHZ

INTCON = 0XC0; //configure the Global & peripheral

interrupts

RCREG = 0;

Page 58: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

50

}

void usartstring(const unsigned char *st)

{

while(*st)

transmit(*st++);

}

void main()

{

PORTB=0x00;

TRISB=0x00;

PORTD=0x00;

TRISD=0x00;

TRISC = 0x8F; //configure the pin directions for UART

comm

PORTC = 0x00;

ADCON1=0x06;

lcdcmd(0x38);

lcdcmd(0x06);

lcdcmd(0x0C);

Page 59: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

51

init();

while(1)

{

lcdcmd(0x80);

lcdstring("FAN :");

lcdcmd(0xC0);

lcdstring("LIGHT:");

if(!RC0){

lcdcmd(0x86);

lcdstring(" ON ");

transmit('0');

while(!RC0);

}

if(!RC1){

lcdcmd(0x86);

lcdstring(" OFF ");

transmit('1');

while(!RC1);

}

if(!RC2){

Page 60: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

52

lcdcmd(0xC6);

lcdstring(" ON ");

transmit('2');

while(!RC2);

}

if(!RC3){

lcdcmd(0xC6);

lcdstring(" OFF ");

transmit('3');

while(!RC3);

}

}

Page 61: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

53

CHAPTER 7

CONCLUSION AND FUTURE SCOPE:

The home automation using Zigbee has been experimentally proven to

work satisfactorily by connecting simple appliances to it and the appliances were

successfully controlled remotely through internet. The designed system not only

monitors the sensor data, like temperature, gas, light, motion sensors, but also

actuates a process according to the requirement, for example switching on the

light when its gets dark. This will help the user to analyze the condition of

various parameters in the home anytime anywhere.

There is a scope for the further development in our project is using this

system as frame work, the system can be expanded to include various other

options which could include home security feature like capturing the photo of a

person moving around the house and storing it onto the cloud. The will reduce

the data storage than using the CCTV camera which will record all the time and

stores it.

The system can be expanded for energy monitoring, or weather stations.

This kind of a system with respective changes can be implemented in the

hospitals for disable people or in industries where human invasion is impossible

or dangerous, and it can also be implemented for environmental monitoring.

Page 62: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

54

REFERENCE:

ZigBee Alliance, "ZigBee Specification 2005", http://www.ZigBee.com.

Ondrej.S and Zdenek. B, "ZigBee Technology and Device Design,"

Networking, International Conference on System and International

Conference on Mobile Communications and Learning Technologies,

2006, pp. 129-139, April 2006.

Fabio L.Zucatto, and Clecio A.Biscassi, "ZigBee for Building Control

Wireless Sensor Networks," 2007 SBMO / IEEE MTT - S International

Microwave & Optoelectronics Conference, pp. 511-515, 2007.

Dechuan Chen, Meifang Wang, "A Home Security ZigBee Network for

remote Monitoring Application," 2006 The IET International Conference

on Wireless Mobile & Multimedia Networks , pp. 304-307, 2006

Amit Sahai and Brent Waters, "Fuzzy Identity Based Encryption. In

Advances in Cryptology - Eurocrypt", volume 3493 of LNCS, pp 457-

473, Springer, 2005.

John Bethencourt, Amit Sahai and Brent Waters, "Ciphertext-policy

attribute-based encryption," In IEEE Symposium on Security and Privacy,

pp 321-334, 2007.

Son Thanh Nguyen and Chunming Rong, "ZigBee Security Using

Identity-Based Cryptography," Lecture Notes in Computer Science, Vol.

4610, pp. 3-12, Aug. 2007.

Page 63: SMART HOME AUTOMATION WITH ZIGBEE · PDF filei smart home automation with zigbee a project report submitted by shawn.g.vijayan reg.no.: 12bec139

55

Boneh, D., Franklin, M. "Identity-based Encryption from the Weil

Pairing," CRYPTO 2003. LNCS, vol.2729, pp. 382-398 Springer,

Heidelberg, 2003.