Download - Final Thesis Cc2430
i
ii
DEDICATION
We dedicate this humble effort to all our loved ones who have taken us through the
enlightening moments of life paving the way towards knowledge and discernment.
Yearning for theology ,we will continue our journey under the beacon of their support
and guidance.
iii
ACKNOWLEDGMENTS
First of all, we express our deep gratitude to Almighty Allah as no endeavour can be
accomplished even to its slightest without His will. He is indeed The most Gracious, The
most Merciful.
We hereby take this opportunity to thank our project advisor Dr. Zubair A.Khan and co-
advisor Saad Ahmed Khan for their guidance, advice, encouragement and inspiration.
They supported us in every way, professionally as well as morally especially during
difficult phases of our work and made us succeed.
It goes without saying that the credit of our work is ultimately our parents` reward whose
prayers, sacrifices and support have made us realize our dreams and achieve soaring
goals.
We also extend our whole hearted thanks to the University of Engineering and
Technology Lahore and faculty members of Electrical Engineering Department for
providing necessary help and cooperation required during the project.
iv
TABLE OF CONTENTS
Chapter Page
1. INTRODUCTION .....................................................................................................1
1.1 Introduction .................................................................................................1
1.2 Approach .....................................................................................................2
1.3 Contribution .................................................................................................3
2. REVIEW OF LITERATURE ....................................................................................4
2.1 Literature survey .........................................................................................4
2.2 The IEEE standard 802.15.4 ........................................................................5
2.2.1 Merits of Zigbee technology ...................................................7
2.2.2 Zigbee and Competing technologies ......................................8
2.2.3 Zigbee Stack architecture .....................................................12
2.2.4 Transmission mechanisms ....................................................16
2.2.5 Device types ..........................................................................16
2.2.6 Beacon versus Non beacon mode .........................................17
2.2.7 Zigbee Network topologies ...................................................18
2.3 Zigbee and Home automation ....................................................................20
2.3.1 Ideas for Home Automation……………………………20
2.3.2 A Case Study…………………………………………….22
2.3.3 Zigbee home example……………………………………24
2.3.4 Zigbee Application Profiles………………………………26
2.3.5 Attributes and clusters…………………………………….28
v
2.3.6 Binding……………………………………………………….29
2.3.7 Descriptors……………………………………………………30
3. METHODOLOGY ..................................................................................................31
3.1 Specifications of the project ......................................................................31
3.1.1 Software flow .....................................................................33
3.2 Hardware Implementation ........................................................................36
3.2.1 Z-stack.................................................................................37
vi
3.2.2 Working of light switch…………………………………...38
3.2.3 Binding Details ................................................................38
3.2.4 Serial Interfacing ..............................................................40
3.2.5 A Temperature sensing application .................................40
3.2.6 Some API Functions .........................................................41
3.2.7 ZDO Interface ..................................................................48
3.2.8 Important OSAL Functions..............................................49
3.3 NS2 Simulation ........................................................................................51
3.3.1 LEACH Protocol .................................................................51
3.3.2 The Energy model ...............................................................53
4. FINDINGS AND INNOVATIONS .........................................................................55
4.1 Clustering…………………………………………………………………55
4.1.1Proposed clustering algorithm…………………………..55
4.2 Performance Analysis of a Zigbee HAN .................................................57
4.2.1 RFD configuration and analysis .........................................58
4.2.2 FFD configuration and analysis .........................................60
4.2.3 Inferences ...........................................................................62
5. CONCLUSION .......................................................................................................65
Section5.1 Conclusion ....................................................................................65
Section5.2 Future work ...................................................................................66
REFERENCES ............................................................................................................67
APPENDICES .............................................................................................................70
vii
LIST OF TABLES
Table Page
2.1 Comparison of Wireless technologies ....................................................6
3.1 Flexible power modes in CC2430 ........................................................36
4.1 Transient times of Chipcon CC2430 ....................................................57
4.2 Measured power consumption@ 2.7V..................................................58
4.3 Network parameters ..............................................................................63
4.4 Assumptions ..........................................................................................64
viii
LIST OF FIGURES
Figure Page
2.1 The Wireless market .............................................................................5
2.2 Zigbee Stack architecture…………………………………………….13
2.3 ISM Frequency bands………………………………………………..14
2.4 Types of frames………………………………………………………14
2.5 The superframe structure…………………………………………….16
2.6 Zigbee network model……………………………………………….18
2.7 A case study………………………………………………………….24
2.8 Zigbee home example………………………………………………...25
2.9 HCL profile…………………………………………………………...27
2.10 Switch remote control………………………………………………...29
3.1 Basic block diagram…………………………………………………..32
3.2 The Zigbee smart home……………………………………………….33
3.3 Software Flow diagram for Coordinator……………………………..34
3.4 Software Flow diagram for end device………………………………35
3.5 The binding mechanism……………………………………………….39
3.6 Temperature sensing application……………………………………..41
3.7 An 802.15.4 network on NS2 simulator……………………………..54
4.1 Cluster based Zigbee home area network model…………………….56
4.2 Coordinator power consumption as a function of Beacon interval…..61
4.3 End Device power consumption as a function of Beacon interval……62
ix
Abstract
Driven by emerging standards, increasing energy costs, and advances in Wireless Sensor
Networking, the “smart home” is becoming a reality for the mass market. Over a decade,
professional installers have been using proprietary systems.With emergence of standards
such as Zigbee, cost effective low-data rate, home solutions are now realizable. This
project presents a cluster based home area network in which Zigbee has been used as the
underlying technology. Zigbee is an efficient wireless protocol built around IEEE
standard 802.15.4. Zigbee wireless approach is the most suitable for low data rate
applications like HANs.Here each room is deployed with sensor nodes in a star
topology.Afterwards the cluster heads of all the rooms report to the PAN
coordinator.From analysis of power consumption of Zigbee based home networks ,this
architecture gives least power consumption.In the proposed solution use of hierarchical
mechanism is suggested. Using beacon mode, power consumption calculation and
performance analysis have been done.Hardware implementation of temperature and
lighting control has been done using CC2430.
1
CHAPTER 1
INTRODUCTION
1.1 Introduction
Besides technical perspectives, technology is trying hard to provide ease at the hand of
customers. Telecommunications has become a basic human need. The aspect of social
responsibility on technology brings comfort to laymen and areas such as bio-med and
home networking arise. WSN`s have spread consternation in the field of home area
networking. Home automation is one of the application fields where wireless sensor
networks and consumer electronics blend together. One major objective is to develop an
integrated and user-friendly environment with least power consumption and long battery
life.
Technologies for implementing wireless home networking include IEEE
802.11,wireless LAN, Bluetooth, IEEE1394, UWB (ultrawide-band) based wireless and
last but not least Zigbee IEEE 802.15.4. Zigbee is based on IEEE standard 802.15.4. In a
Zigbee HAN, a single remote can give command to many devices and with ease to
interface with outdoor mobile and remote devices. It is a more reliable, robust and cost
effective solution. Zigbee is paving the way for intelligent sensors to provide greater
control of lighting, heating, cooling, water and filtration, appliance-use and security
systems from anywhere in and around the home. These controls dramatically improve
energy efficiency with increasing power demands that exceed supply, as well as concerns
around greenhouse gas emissions.
Home automation is the use of one or more computers to control basic home
functions and features automatically and sometimes remotely. An automated home is
sometimes called a smart home. The term “smart home” comprises a number of different
applications in a single home whether it is audio/video control,location estimation
2
schemes,image registration methods,distributed architectures and human-friendly
environments.
Home automation can include the scheduling and automatic operation of water
sprinkling, heating and air conditioning, window coverings, security systems, lighting,
and food preparation appliances. Home automation may also allow vital home functions
to be controlled remotely from anywhere in the world using a computer connected to the
Internet. Besides the functions already mentioned, remote control can be extended to
telephones and answering machines, fax machines, amateur radios and other
communications equipment, and home robots such as automatic vacuum cleaners.
Management of routing paths in home area networking requires complex
computations. Use of clustered topology eliminates redundancy in such a way that only
accumulated data is sent to the sink. While using Zigbee, the unique active, sleep and
wake-up modes of deployed nodes ultimately result in power saving. Possible network
topologies for Zigbee sensor networks include star, cluster-tree and mesh topology
respectively.
Zigbee networks are usually data centric based on the concept of attributes and
clusters. Hierarchical routing and clustering has due advantages of scalability, self
organization, security, better data aggregation and fault tolerance. Although hierarchical
clustering is well known for large sized and full-load networks yet we are now using it
for HAN`s. In hierarchical architecture, there is less computation burden, dynamic
organization, localization and redundancy exploitation.
1.2 Approach
A zigbee automated smart home has been developed.Various types of sensor and
actuator nodes have been deployed in a unique architecture. We have configured a
beacon enabled clustered topology for IEEE802.15.4.We have shown through results that
using Zigbee based clustered architecture gives a better home area network in terms of
3
power consumption.We also present a mathematical performance analysis of IEEE
802.15.4 device that is used for our home area network.
1.3 Contribution
Work on network and application layer while using existing IEEE
802.15.4 and zigbee alliance protocols and modules.
Performance analysis of Home area networking in terms of power
consumption.
Hardware implementation of home lighting and temperature
control using embedded systems.
Modelling of the implemented system.
Simulation using NS2 simulator
4
CHAPTER 2
REVIEW OF LITERATURE
2.1 Literature Survey
A Java based home automation system was presented by A. R. Al-Ali and M. AL-Rousan
[1], that can monitor home appliances via world wide web using Java server pages, Java
beans & interactive C . An NMS architecture was proposed for Bluetooth [2] using
Ethernet connectivity (LAN). The overall system architecture consists of a base station,
home server, wireless sensor nodes and smart user terminals such as PC & PDA`s. A
virtual home robot server [3] was introduced in which sensing system is implemented
using Zigbee. In [4], a green house monitoring control has been developed using Zigbee
& for deployment Jennic`s chip JN5121 was used. Another paper combines GPRS and
Zigbee to establish a multi-mode network structure which employs GPRS as the data
transmission device in the wide-area while Zigbee in the local area [5]. It also introduces
a Zigbee-GPRS “meter reading program” and “oil pipelining program” which are
basically ideas for commercial, industrial & environmental applications but can be
incorporated in home area networking after necessary modifications. For intra oral human
to computer system [6] a Zigbee based system has been discussed which uses star
topology. The prototype is specific to bio-med applications but the steps of construction
can be followed to develop any kind of home are network. [7] is an 'aware home' capable
of knowing information about itself and the whereabouts and activities of its inhabitants.
Applications include support for elderly, finding lost objects, smart floor knowing the
footsteps ` data etc. Zigbee is being watched with keen interest as “the technology for
ubiquitous computing” for future [8]. [9] is an elaboration of ambient intelligence which
can pave the way for development of future homes 'Intelligence in 2010' with wider smart
infrastructures and integrated services avoiding ubiquitous clutter.
5
A base station centric data gathering protocol BCDGP [10] was proposed. WEN is
the basic entity of this proposed algorithm and authors have shown the flooding process
and minimized the energy consumption of WEN.
[11] deeply performs probabilistic analysis and modeling of IEEE 802.15.4 for
medical area networking. Basic formulae and calculations for average back off, frame
size, node lifetime and reception and transmission times are really useful. In [12],a
detailed performance analysis of IEEE 802.15.4 has been done for a cluster-tree based
topology(pure mesh networking). Device power consumption, node operations,
calculation of back off time, coordinator`s energy efficiency & good put have been
modeled & simulated using WISENES.
2.2 The IEEE standard 802.15.4
Figure 2.1 The Wireless Market
The above figure shows some IEEE standardized competing technologies.Their range of
operation and types of application areas vary.Zigbee is suitable for low data rate
applications.Both zigbee and Bluetooth are short ranged as compared to WiFi and
6
Wimedia.Standards like 802.11b and WiMedia are known for internet access,video
applications,image processing etc.
Table 2.1 presents a detailed comparison regarding merits and demerits of various
wireless technologies .A significant and relevant observation about zigbee can be made
from here that it the best technology for monitoring and control applications.Utilization
of system resources is least ie only 4Kb.Also it has a long battery life,least cost and is the
most reliable.
Table 2.1 Comparison of wireless technologies
Market Name
Standard
GPRS/GSM
1xRTT/CDMA
Wi-Fi™
802.11b
Bluetooth™
802.15.1
ZigBee™
802.15.4
Application
Focus
Wide Area
Voice & Data
Web, Email,
Video
Cable
Replacement
Monitoring
& Control
System
Resources 16MB+ 1MB+ 250KB+ 4KB - 32KB
Battery Life
(days) 1-7 .5 – 5 1 – 7 100 - 1,000+
Network Size 1 32 7 255 / 65,000
Bandwidth(KB/s) 64 - 128+ 11,000+ 720 20 - 250
Transmission
Range (meters) 1,000+ 1 – 100 1 - 10+ 1 - 100+
Success Metrics Reach,
Quality
Speed,
Flexibility
Cost,
Convenience
Reliability,
Power, Cost
7
2.2.1 Merits of Zigbee technology
ZigBee is a home-area networking technology which ensures integrated environments.
ZigBee was created to satisfy the market's need for a cost-effective, standards-based
wireless network that supports low data rates, low power consumption, security, and
reliability. To address this need, the ZigBee Alliance, an industry working group is
developing standardized application software on top of the IEEE 802.15.4 wireless
standard. The alliance is working closely with the IEEE to ensure an integrated,
complete, and interoperable network for the market. For example, the working group will
provide interoperability certification testing of 802.15.4 systems that include the ZigBee
software layer. Zigbee is the only standards based technology that addresses the needs of
most remote monitoring and control and sensory network applications. IEEE 802.15.4
acts as the physical radio and Zigbee as the logical network and application software.
ZigBee is poised to become the global control/sensor network standard. It has been
designed to provide the following features:[13]
– Low power consumption
– Long battery life
– has active (transmit/receive) and sleep mode. Application software needs to focus
on the application, not on which power mode is optimum for each aspect of
operation.
– Even mains powered equipment needs to be conscious of energy. Consider a future
home with 100 wireless control/sensor devices,
– Case 1: 802.11 Rx power is 667 mW (always on)@ 100 devices/home &
50,000 homes/city = 3.33 megawatts
– Case 2: 802.15.4 Rx power is 30 mW (always on)@ 100 devices/home &
50,000 homes/city = 150 kilowatts
8
– Case 3: 802.15.4 power cycled at .1% (typical duty cycle) = 150 watts.
ZigBee devices will be more ecological than its predecessors saving megawatts at it
full deployment.
– Low cost (device, installation, maintenance)
Low cost to the users means low device cost, low installation cost and low
maintenance. ZigBee devices allow batteries to last up to years using primary
cells (low cost) without any chargers (low cost and easy installation). ZigBee’s
simplicity allows for inherent configuration and redundancy of network devices
provides low maintenance.
– High density of nodes per network
ZigBee’s use of the IEEE 802.15.4 PHY and MAC allows networks to handle any
number of devices. This attribute is critical for massive sensor arrays and control
networks.
– Simple protocol, global implementation
ZigBee’s protocol code stack is estimated to be about 1/4th of Bluetooth’s or
802.11’s. Simplicity is essential to cost, interoperability, and maintenance.
2.2.2 Zigbee and competing technologies
Zigbee vs X10
Of the few attempts to establish a standard for home networking that would control
various home appliances, the X-10 protocol is one of the oldest. It was introduced in
1978 for the Sears Home Control System and the Radio Shack Plug ‘n Power System. It
uses power-line wiring to send and receive commands. X-10 transmissions are
synchronized to the zero-crossing point of the AC power line. A binary 1 is represented
by a 1ms burst of 120kHz at the zerocross point, and binary 0, by the absence of 120kHz.
The network consists of transmitter, receiver and bidirectional units that can receive and
transmit X-10 commands. Receiving units work as remote-control power switches for
9
home appliances or as remote-control dimmers for lamps. The transmitter unit is a
normally-open switch that sends a predefined X-10 command if the switch is closed. The
X-10 commands enable you to change the status of the appliance unit (turn it on/off) or to
control the status of a lamp unit (on, off, dim, bright). Bidirectional units may send their
current status (on /off) upon request. A special code is used to accommodate the data
transfer from analog sensors. The downside of its simplicity is slow speed, low reliability
and lack of security. The effective data transfer rate is 60bps— too slow for any
meaningful data communication between nodes. High redundancy in transition is dictated
by heavy signal degradation in the power line. For any power appliances, the X-10
transmission looks like noise and is subject to removal by the power-line filters.
Reliability and security issues rule out the use of the X-10 network for critical household
applications.[14]
Zigbee vs Bluetooth
TimingConsiderations
ZigBee
• New slave enumeration = 30ms typically
• Sleeping slave changing to active = 15ms typically
• Active slave channel access time = 15ms typically Bluetooth
• New slave enumeration = >3s, typically 20s
• Sleeping slave changing to active = 3s typically
• Active slave channel access time = 2ms typically
Conclusion:
ZigBee devices can quickly attach, exchange information, detach, and then go to deep
sleep to achieve a very long battery life. Bluetooth devices require about ~100X the
energy for this operation.
10
PowerConsiderations:
ZigBee
– 2+ years from ‘normal’ batteries
– Designed to optimize slave power requirements
Bluetooth
– Power model as a mobile phone (regular daily charging)
– Designed to maximize ad-hoc functionality
Scenario 1: ZigBee Battery Drain, network connection[13]
Goal: Two year battery life
Assumptions:
– AAA cell = 1.15 Ahr (Duracell alkaline)
– 2 yrs = 17,532 hrs
Partial result: Average current drain < 65 µA (capacity/time)
– Tx/Rx current drain ~ 15 mA and sleep current = 1 µA
Partial result: Maximum duty cycle < .43% (Avg. current drain-sleep
current)/current drain
– Beacon duration of 3 mS (longer beacons containing more information would drain
more current)
– Beacon rate of 1/s (beacon rates can be as slow as .03/s)
Partial result: beacon use in this case requires a .3% duty cycle
Final result: 22.8 hours (0.13%) of transmission time would be allowed for data
transmission or reception.
Scenario 2: Battery Drain when the unit is not connected to the network
Assumptions:
– Device will connect only when necessary to send data
– Acquisition time
11
– Bluetooth requires about 20 – 30 seconds (~98% confidence) for an Inquiry (first
time) and about 3 seconds for a Page (subsequent times)
– IEEE 802.15.4 acquisition time is about 30 mS
– Using maximum duty cycle of .43% and 40 byte packet
Result:
– ~ 45,140 data transmissions for Bluetooth
– ~ 4,269,670 data transmissions for ZigBee
ZigBee has an inherent advantage for these modes of operation due to its short
attach time and/or its ability to remain in the sleep mode for long periods.
Disadvantages in others
INFRARED:
A proprietary solution
Use of multiple remotes
Needs line of sight communication
X10: Signals passing through one live conductor may not propagate through the high
impedance of the distribution winding to the other live conductor.
Subject to strong attenuation by resistor coils and delay lines
Gets filtered with noise
absorption of passing X10 signals by computers, television sets, and satellite
receivers
Slow transmission
UPB: A digital evolution of X10. that improves reliability but it is expensive.
12
INSTEON: Insteon devices in home act like a two-way repeater – sending and receiving commands,
confirming commands, and retransmitting corrupted messages –so these devices are
complex as compared to zigbee. ZWAVE: ZWave is similar to zigbee in many ways but it lacks a global standard and does not
have the publicity that ZigBee currently holds.
WIBREE : Range of wibree is less than zigbee and its networking capability is also less than zigbee.
2.2.3 The stack architecture The zigbee architecture is made up of a set of blocks called layers.Each layer performs a
specific set of services for the layer above; a data entity provides a data transmission
service and a management entity provides all other services.
Each service entity exposes an interface to the upper layer through a service access point
(SAP), and each SAP supports a number of service primitives to achieve the required
functionality. The ZigBee stack architecture is based on the standard Open Systems
Interconnection (OSI) seven-layer model but defines only those layers relevant to
achieving functionality in the intended market space.
13
Figure 2.2 Zigbee Stack Architecture
The IEEE 802.15.4-2003 standard defines the two lower layers: the physical PHY)
layer and the medium access control (MAC) sub-layer. The ZigBee Alliance builds on
this foundation by providing the network (NWK) layer and the framework for the
application layer. The application layer framework is comprised of the application
support sub-layer (APS), the ZigBee device objects (ZDO) and the manufacturer-defined
application objects.
ZigBee-compliant products operate in unlicensed bands worldwide, including
2.4GHz (global), 902 to 928MHz (Americas), and 868MHz (Europe). Raw data
throughput rates of 250Kbps can be achieved at 2.4GHz (16 channels), 40Kbps at
915MHz (10 channels), and 20Kbps at 868MHz (1 channel).
14
Figure 2.3 ISM Frequency Bands
Basic features of IEEE 802.15.4 are :
• Use of CSMA(carrier sense multiple accesss)
• Optional beacon structure(GTS)
• Message acknowledgement
• Dynamic device addressing
• DS/FA(direct sequence frequency agility)
Figure 2.4 Types of frames
15
There are four types of frames in IEEE802.15.4:
The data frame provides a payload of up to 104 bytes. The frame is numbered so that all
packets are tracked. A frame-check sequence ensures that packets are received without
error. This frame structure improves reliability.
The acknowledgment (ACK) frame provides feedback from the receiver to the sender
confirming that the packet was received without error. The device takes advantage of
specified "quiet time" between frames to send a short packet immediately after the data-
packet transmission.
A MAC command frame provides the mechanism for remote control and configuration of
client nodes. A centralized network manager uses MAC to configure individual clients'
command frames no matter how large the network.
The beacon frame wakes up client devices, which listen for their address and go back to
sleep if they don't receive it. Beacons are important for mesh and cluster-tree networks to
keep all the nodes synchronized without requiring those nodes to consume precious
battery energy by listening for long periods of time.[14]
In the beacon-enabled mode, all communications are performed in a super-frame
structure presented in Figure 2.5. A super-frame is bounded by periodically transmitted
beacon frames, which allow nodes to synchronize to the network. An active part of a
super-frame is divided into 16 contiguous time slots that form three parts: the beacon,
Contention Access Period (CAP) and Contention-Free Period (CFP). At the end of the
super-frame is an inactive period, when nodes may enter to a power saving mode. The
Beacon Interval (BI) and the active Super-frame Duration (SD) are adjustable by Beacon
Order (BO) and Super-frame Order (SO) parameters as
BI = aBaseSuperframeDuration x 2BO (1)
SD = aBaseSuperframeDuration x 2SO (2)
16
BI
BEACON
SD
CAP CFP INACTIVE
Figure 2.5 The superframe structure
2.2.4 Transmission mechanisms
Data transfer can happen in three different ways:
- Direct data transmission. This applies to all data transfers, either from a device to a
coordinator, from a coordinator to a device, or between two peers, un-slotted CSMA-CA
or slotted CSMA-CA is used for data transmission, depending whether non-beacon
enabled mode or beacon enabled mode is used.
- Indirect data transmission. This only applies to data transfer from a coordinator to its
devices. In this mode, a data frame is kept in a transaction list by the coordinator, waiting
for extraction by the corresponding device.
- GTS data transmission. This only applies to data transfer between a device and its
coordinator, either from the device to the coordinator or from the coordinator to the
device. No CSMA-CA is needed in GTS data transmission [15].
2.2.5 Device types
ZigBee networks use three device types:
• The network coordinator maintains overall network knowledge. It's the most
sophisticated of the three types and requires the most memory and computing
power.
• The full function device (FFD) supports all 802.15.4 functions and features
specified by the standard. It can function as a network coordinator. Additional
17
memory and computing power make it ideal for network router functions or it
could be used in network-edge devices.
• The reduced function device (RFD) carries limited (as specified by the standard)
functionality to lower cost and complexity. End devices are generally RFD`s.
2.2.6 Beacon vs non beacon mode
Ultra-low power consumption is how ZigBee technology promotes a long lifetime for
devices with nonrechargeable batteries. ZigBee networks are designed to conserve the
power of the slave nodes. For most of the time, a slave device is in deep-sleep mode and
wakes up only for a fraction of a second to confirm its presence in the network.
Zigbee networks can either use beacon or non-beacon mode depending upon the type of
application.Non beacon mode works on unslotted CSMA mechanism and beacon enabled
uses slotted CSMA.In non beacon mode,end devices can initiate communication anytime
at random,The non-beacon mode is used in simple peer and near-peer networks whereas
beacon mode is suitable for cluster tree or mesh topologies.
Beacons are used to synchronize the network devices and identify the HAN .The
major advantage in beacon mode is that it reduces the system’s power consumption. In
the beacon-enabled mode, all communications are performed in a super-frame
structure.An active part of a super-frame is divided into 16 contiguous time slots that
form three parts: the beacon, Contention Access Period (CAP) and Contention-Free
Period (CFP). At the end of the super-frame is an inactive period when nodes enter in a
power saving mode.The beacon mode is more suitable when the network coordinator is
battery operated. Non-beacon mode is typically used for security systems where client
units such as intrusion sensors, motion detectors and glass-break detectors sleep 99.999
percent of the time.Beacon enabled mode is usually preferred for in automated
homes,industrial applications and large,dense networks.
18
2.2.7 Zigbee network topologies
The NWK layer associates or dissociates devices using the network coordinator,
implements security, and routes frames to their intended destination. In addition, the
NWK layer of the network coordinator is responsible for starting a new network and
assigning an address to newly associated devices.
The NWK layer supports multiple network topologies including star, cluster tree, and
mesh, all of which are shown in Figure 2.6.
Figure 2.6 ZigBee network model
In a star topology, one of the FFD-type devices assumes the role of network
coordinator and is responsible for initiating and maintaining the devices on the network.
All other devices, known as end devices, directly communicate with the coordinator.
In a mesh topology, the ZigBee coordinator is responsible for starting the network
and for choosing key network parameters, but the network may be extended through the
use of ZigBee routers.Cluster-tree networks utilize a hybrid star/mesh topology that
combines the benefits of both for high levels of reliability and support for battery-
powered nodes.
19
Selection of topology
The architecture of network is probably the most significant attribute.While deciding
about the network topology,number of devices,their configuration and kind of
relationship with the network coordinator need to be considered.If a single room is to be
automated ;for instance it is being provided with lighting and temperature control then
star topology can be chosen.Star topology utilizes master slave configuration in which
slave nodes sleep most of the time and can directly communicate with the coordinator at
their own will.Cluster tree or mesh topology will be the best for a clustered network
scenario in which there is a parent child relationship b/w nodes.Mesh networks extend
through the use of routers in the network;coordinator is mainly responsible for
initialization of network only.Home automation can be effectively realized if we chose
cluster tree topology whose basic unit under each cluster head is star topology. Star or
simplified cluster tree topology best suits to low data rate and long battery life operations.
Ultimate network size can reach 264 nodes (more than we'll probably need). Using
local addressing, you can configure simple networks of more than 65,000 (216) nodes,
thereby reducing address overhead.The endpoint address 255 can also be used to
broadcast a message to all the user endpoints on a node. The endpoint address 0 on each
node is reserved for the ZDO (ZigBee Device Objects).
Actual application profiles are defined in the individual profiles of the IEEE's
working groups. Each ZigBee device can support up to 30 different profiles. Currently,
only one profile, Commercial and Residential Lighting, is defined. It includes switching
and dimming load controllers, corresponding remote-control devices, and occupancy and
light sensors.
The General Operation Framework (GOF) is a glue layer between applications
and rest of the protocol stack. The GOF currently covers various elements that are
common for all devices. It includes subaddressing and addressing modes and device
descriptions, such as type of device, power source, sleep modes, and coordinators. Using
20
an object model, the GOF specifies methods, events, and data formats that are used by
application profiles to construct set/get commands and their responses.
2.3 Zigbee and Home automation
A ZigBee-enabled home network can use a single device, like a cell phone, PDA or
remote control to turn off a light switch without getting out of bed. For example, by using
a cell phone to signal arrival at home the network would automatically recognize the
device, and a number of actions would take place:
• The lights turn on
• Security system disarms
• Automatic garage door opens
• The heating or cooling system switches from energy saving mode to a preferred comfort
level
2.3.1 Ideas for home automation
Lighting:
• Automization of switching lights
• Regulation of illumination according to level of ambient luminosity
Lighting control may also include control of exhausts,ceiling fans and electric wind-
ow shades.
Electronics Control:
The category of audio control include s audio switching and distribution.Switching
determines selection of the audio source and distribution allos it to be heard in more than
one rooms.Video control comprises ‘multi zone’ video systems allowing the video
source to be viewed on multiple TVs.
21
Security:
Security systems include control and distribution of security cameras and detection of
possible intrusion.
• Sensors for movement of detection
• Sensors for magnetic contact of door/window
• Sensors for crystal breakage
Temperature control:
Temperature can be monitored with low voltage temperature control systems from
several locations in home.HVAC is a part of temperature control because heating,
ventilation and air conditioning solutions include temperature and humidity control.
Lawn watering:
Using zigbee we can achieve a high technology lawn irrigation system.Each
day,the system monitors the amount of rain and sends data to a central device.The device
cross references the data to the local weather report and then proceeds to create and
analyse a virtual amount of soil sample.This sample determines the amount of watering
your lawn requires.
An automated home may comprise a unique architecture of occupancy sensors that
would include entry/exit sensors for detecting movement through doorways, room motion
sensors for detecting room occupancy, spot sensors to detect occupany of specific
locations with rooms, house status sensors to detect the status the of certain parameters of
home. A central controller would communicate with the whole network.
The system can be added with more sensors and controlled objects in a 'plug'n play'
manner. The central controller controls the controlled objects in response to the entry/exit
sensors, room motion sensors, spot sensors, and house status sensors. In prefered
22
embodiment, the central controller is a personal computer or dedicated control device
running a program,using standard communications over the network. Users might also
communicate and control through smart switches, IR recievers, keypads , voice
recognition tranceivers etc.
For a house- there are 6 main modes.
1- Home- The family is home and is actively doing things in the house.
2- Night- The family is in for the night. Any doors or room opening maybe
cause for an alarm
3- Away- No one is home. Motion is some room maybe cause for an alarm.
4- House tour- Someone is giving a tour of the house. Special modes might
be enabled like to give verbal tour of each room
5- Party- A party is going on. Special modes maybe enabled.
6- Special- A user-defined mode that enables special things to turn on and off as
defined by the home owner. These house mdoes are either manually set by pushing
a switch (by people entering or exiting the home or retiring for the evening), or are
automatically set by timers, ambient light sensors, spot sensors, etc
2.3.2 A case study
Goal behind the efforts in this case is to:
• Easily create networks
• Add devices to networks
• Merge applications
• Extend range
Son installs a retail two-pack ZigBee lamp controller and lamp module.Mom likes it,this
allows her to stay warm in bed without having to get up to turn out lamp.When son is
23
away he remains worried about her health, so adds wearable panic button and phone line
connection.
• New PAN coordinator assumes coordination master function from lamp module;
network auto-reconfigures for star topology. Mom likes it, son is also worried about her
neighborhood, so adds door and window security sensor
• PAN Coordinator locates these new devices and adds them
• PAN Coordinator offers to alert police via phone line if window sensor is tripped, turns
on lamp by bed. Mom now worries about mail being stolen from roadside box,so wants
to know when mailman delivers mail.
• Son buys ZigBee Mailbox Alert
– finds that range is exceeded, purchases ZigBee Range Extender,finds it also allows her
Panic Button to work outside in the garden. For Christmas, Mom gets new computer with
ZigBee
Human Interface Devices (HID)
• Comes with software to allow her to automate her house via ZigBee
24
Figure 2.7 A Case study
2.3.3 Zigbee home example
The practical example shown in figure is a home with a ZigBee network that controls the
lights, security system, fire system, and the heating and air conditioning. The diagram
shows a number of devices, where a red link is a Router-to-Router link, and a blue link is
an End node to Router link.
25
Figure 2.8 A Zigbee Home Network
Here, lighting fixture B (which might also be the Coordinator) has identified and
established routes via Routers embedded in lighting fixtures A and F, mains-powered
(with battery backup) smoke detector C, and table lamp D.
All the Routers are mains-powered devices (lamps, heat pump, lighting fixtures, smoke
alarms) and the End devices are battery-powered (switches, thermostats, motion
detectors). Sensors are bound to actuators through sometimes either the choice of the
user, or because of specific binding specified by the manufacturer.
Home network topology
Light switch b is bound to and controls hanging lighting fixture B, and communicates
with it directly (single hop). Some of the control is multi-hop: for instance, peel-and-stick
thermostat/HVAC controller c communicates with the HVAC heat pump K located
outside the home through a complex route, potentially due to RF obstructions or
interference that might preclude a direct path. So when the home occupant wants to cool
the house a bit, that command is sent from c to K through intermediaries B and A, both
26
lamp fixtures behaving as network Routers. Note also that there is an alternate path, via
B-G-J-H, which has more hops and is probably less efficient.
The network determines the cost of a route using various metrics and assigns the
best route as the primary, and other less favorable routes as secondary. Why the
secondary routes? Remember the ZigBee slogan: Wireless control that simply works. The
message that the thermostat/controller sends out will generally take far less than 100ms to
get to the HVAC heat pump, and the heat pump is expected to acknowledge that message
in the same time. If the thermostat does not get the response, it will try again. If there is a
network problem (for example, the link between B and A is disrupted due to
interference), node B can go to the alternate route, where it sends the message via the
longer path.
Another important aspect is that the network is a multi-use system, where lighting,
HVAC, and security all can take advantage of the others’ existing infrastructure. This is
not mandatory, and can be defined by the manufacturer of individual devices, but allows
a far more powerful and robust network to form quickly.[16]
2.3.4 Zigbee application profiles
The ZigBee stack in a particular network uses the relevant 'Stack Profile' from the ZigBee
Alliance. The stack profile determines the type, shape and features of the network, and
depends on the field of application, e.g. the Home Controls profile.
An application profile is associated with a particular stack profile and addresses
the needs of a specific application or market - for example, the ZigBee Alliance has
defined the Home Controls-Lighting (HCL) application profile for use in controlling
lighting in the home.It defines a number of devices and functions which are needed or are
useful for controlling domestic lighting, such as switches, dimmers, occupancy sensors
and load controllers.
27
. Figure 2.9 HCL Profile
Device description
In each Application Profile a number of Device Descriptions are defined, describing the
types of devices the profile supports. For the HCL profile, devices such as a Switch
Remote Control (a switch), Light Sensor Monochromatic, Dimmer Remote Control,
Occupancy Sensor, Switching Load Controller and Dimming Load Controller are
available. Each device in an Application Profile has a Device Identifier associated with it.
Input and Output Data
The Application Profile also specifies the information that a device can generate as
output and can use as input, together with the format this information takes. The
individual pieces of information are called attributes, and their possible values and
format or type (e.g. 8- or 16-bit integer, time value, etc) are defined as part of the Device
Descriptions in the profile. Attributes are grouped together into clusters for the device,
which can be either inputs or outputs.
Public and Private Profiles
Application Profiles can be public or private:
• Public profiles are those introduced by the ZigBee Alliance for use by
manufacturers implementing devices that need to work with devices from other
manufacturers - for example, to allow a switch from one vendor to work with the
light fitting from another vendor. Products implemented to a public profile are
tested and certified for conformance to that profile.
28
• Private profiles are also known as "non-public" profiles - they are proprietry
profiles introduced by manufacturers to allow them to market products for which
public profiles do not exist. This also allows manufacturers to differentiate their
products from others in the same market segment.
2.3.5 Attributes and clusters
Clusters and attributes determine which network devices can communicate with each
other.
Attributes
Each data item that passes between devices of a ZigBee network is called an attribute.
Each attribute has its own unique identifier. For example, a switch device can have an
attribute with identifier OnOff whose value represents the action to be performed: On
(0xFF), Off (0x00), Toggle (0xF0).
Clusters
A number of attributes are grouped into a cluster, where each cluster has its own unique
identifier. For example, for an HCL Switch Remote Control (SRC) device, there is a
cluster with identifier OnOffSRC containing the attribute OnOff. Clusters may be
mandatory or optional for a device to support.
A cluster may contain several attributes. For example, for an HCL Switching Load
Controller (SLC) device, the cluster Output:StatusSLC contains 17 attributes. These
describe the state of the controller, such as whether the SLC is On or Off, the total length
of time that the load has been in the On state, the total power consumed, the voltage
applied to the load.
29
Figure 2.10 Switch remote control
2.3.6 Binding
At a high level, binding is the process of establishing a relationship between nodes that
can communicate in a meaningful way - for example, which switches control which
lights. It therefore determines the overall functionality of the network.
Binding Mechanism
At a more detailed level, the binding mechanism associates applications which generate
information with applications which can use that information.
The information is exchanged as clusters - in order for two applications to be bound, they
must have compatible clusters. For example, for two applications on different nodes to be
bound for the purpose of temperature control, one must be able to generate an output
cluster related to temperature, and the other must be able consume it as an input cluster.
Bindings are stored in a binding table.
The binding between two applications is specified by:
• The source network address and endpoint of the application where the cluster is
generated
• The destination network address and endpoint of the receiving application
• The cluster ID of the cluster being sent between them
30
Binding Types
• One-to-one: A binding in which an endpoint is bound to one (and only one) other
endpoint
• One-to-many: A binding in which a source endpoint is bound to more than one
destination endpoint
• Many-to-one: A binding in which more than one source endpoint is bound to a
single destination endpoint
Consider a switch and load controller from the HCL profile.
• In the one-to-one case, a single switch controls a single light
• In the one-to-many case, a single switch controls several lights, perhaps in the
same room
• In the many-to-one case, several switches control a single light, such as a light on
a staircase, where there are switches at the top and bottom of the stairs, either of which
can be used to turn on the light .
2.3.7 Descriptors
Information about a ZigBee node and its applications are stored on the node in "descriptors".
"Node" Descriptors
Node descriptor: Contains basic information about the device
Power descriptor: Contains information on how the device is powered
"Application" Descriptors
Simple descriptor: A mandatory descriptor that contains information about application
endpoint
Complex descriptor: An optional descriptor
User descriptor: An optional descriptor [17]
31
CHAPTER 3
METHODOLOGY
3.1 Specifications of the project
We will be working over the frequency band 2.4 GHz which is used worldover. In zigbee
we can use either star, cluster or mesh topology but according to the dimensions of
project, we will be using simplified cluster tree topology.This topology is low cost,has
long battery life.Most of the devices in our network are RFD(reduced function device) so
it is simple in implementation and requires minimum RAM and ROM. We have presented a cluster tree structure whose basic unit under each cluster
head is star topology. It has been proved that star or simplified cluster tree topology best
suits to low data rate and long battery life operations. In our cluster based architecture, all
nodes do not take part in the routing process. Data of ordinary nodes is gathered by the
respective cluster heads. Cluster head has the exact knowledge of routes and
communicates with the coordinator.
Our work is a dedicated effort on the network and application layer. As figure
shows, our smart home is deployed with a coordinator and different occupancy sensors
e.g. temperature and light sensors in bedroom and lounge, pressure, motion and smoke
sensors in library, humidity sensors for lawn watering mechanism and water level sensors
for the pool. Respective cluster heads accomplish messaging with the PAN coordinator
which in turn is connected to the base station. Internet/GPRS facility is there for remote
monitoring of home while you are away.
32
Figure 3.1 Basic block diagram
33
Figure 3.2 The Zigbee Smart Home
3.1.1 Software flow
The software flow diagram of pan-coordinator is shown in Figure 13. After the
initialization of network, the channel is
34
INITIALIZATION
CHANNEL SELECTION
PAN CREATION & STARTING OF NETWORK
SENDING BEACONS
NEW NODE JOINING REQUEST
CONTROL OR DATA REQUEST
ASSIGNMENT OF NEW PAN ADDRESS
AND BINDING
CALLING THE RESPECTIVE FUNCTION
DECISION MAKING BASED ON REQUEST
INTERRUPTPROCESS
Figure 3.3 Software flow diagram for coordinator
selected by the PAN-coordinator on which the network has to be established. After that
PAN creates the network and coordinator moves in a state of sending beacon packets. If it
receives any response (request), interrupt occurs and that request is granted. If the
coordinator allows a particular node to join the network, then it allocates the node a node
ID for the network commutation and binding is completed. Afterwards, node can access
to different functionalities provided by the network. If nodes have already joined the
35
PAN and send query for some data, then the respective functions are called and the query
is entertained.
The software flow for a node is shown is Figure 4. When a node is turned on, it
scans the network in its vicinity and joins the network. Then binding occurs and node
adds to the PAN. Usually node would be in sleeping mode so that less power
consumption occurs, but in its active mode, it might be in one of the two states i.e. it
might be sending some query to the coordinator and making a request for it, or it might
be in a state of processing upon a request sent by the coordinator.
INITIALIZATION
NETWORK SCAN
BINDING
WAITING FOR BEACONS
SENDING A REQUESTDATA REQUEST
ACQUIRE SENSOR DATA
COMMAND/ DATA TRANSMISSION
BEACON RECEPTION
Figure 3.4 Software flow diagram for end device
36
3.2 Hardware implementation
We have used Chipcon product CC2430 for the accomplishment of hardware.The
CC2430 is the first single-chip, IEEE 802.15.4 compliant and ZigBee SOC (System
OnChip) RF transceiver with integrated microcontroller. It provides a highly integrated,
flexible low-cost solution for applications using the world wide unlicensed 2.4 GHz
frequency band.The CC2430ZDK is the most powerful tool in the market today for
developing complete ZigBee applications in the minimum timeframe. The kit includes all
required hardware and software to evaluate, demonstrate,prototype and develop various
ZigBee applications.
The hardware is representative of an actual application, and is well suited as a
prototyping,evaluation and demonstration platform targeting various ZigBee applications.
With this kit a ZigBee Logical device type mapped to the IEEE 802.15.4 Full Function
and Reduced Function Devices (FFD and RFD) using the CC2430 can be demonstrated.
An FFD can take the role of a ZigBee Coordinator, Router, or End Device depending on
the ZigBee logical device type configuration. An RFD can act as ZigBee End Device and
cannot serve as a ZigBee Coordinator or ZigBee Router.
Table 3.1 Flexible power modes in CC2430
Power mode 1 190µA Digital regulator on, 16 MHz RCOSC and 32 MHz crystal oscillator off. 32.768 kHz XOSC, POR and ST active.RAM retention
Power mode 2 0.5µA Digital regulator off, 16 MHz RCOSC and 32 MHz crystal oscillator off. 32.768 kHz XOSC, POR and ST active.RAM retention
Power mode 3 0.3µA No clocks. RAM retention. POR active.
37
.
The CC2430 has the capability to demonstrate ZigBee low power capabilities. The
CC2430ZDK is bundled with the Wireless ZigBee stack for evaluation,demonstration,
prototyping and developing purposes of the stack. It can be used to well demonstrate the
current ZigBee Home Lightning Profile.
On the CC2430EB,we have a joystick, LED`s and LCDwhich are used to give user
input and for indication purposes respectively.The LED blinks to indicate match requests
and binding.It can also be used to demonstrate working of a light switch.The LCD
displays the respective IEEE addresses and identifies it as a coordinator or end
device.Request and response messages also get displayed on the LCD.
3.2.1 Z Stack
For implementation purposes,our source software was “Z-Stack”.Z-Stack is Texas
Instrument’s implementation of the ZigBee specification. It is certified as a ZigBee
Compliant Platform ( ZCP ) by the ZigBee Alliance. It consists of the following
components.
• HAL ( Hardware abstraction layer )
• OSAL ( Operating system abstraction layer )
• ZigBee Stack + IEEE 802.15.4 MAC
• User Application
• MT ( Monitor Test ) – Used to communicate with a PC-based test tool via the
UART.
38
The following services are provided by the simplified ZigBee API :
• Initialization(zb_SystemReset,zb_StartRequest)
• Configuration(zb_ReadConfiguration,zb_WriteConfiguration,zb_GetDeviceInfo)
• Discovery(zb_FindDeviceRequest,zb_BindDeviceRequest,zb_AllowBindRequest
,zb_PermitJoinRequest)
• Data transfer(zb_SendDataRequest,zb_ReceiveDataIndication)
The Home Automation Profile
The HA Profile, Profile Id 0x0104, is a Stack Profile.The HA Profile relies upon the ZCL
in general and specifically on the Foundation and General function domain.
3.2.2 Working of light switch
After the devices have joined the network,place one of them in the Allow Bind mode by
pressing S1 on that device.The bind request is issued by the other device which is acting
as the “light switch” by pressing its S1. This will cause it to bind to the prior device that
was in the Allow Bind mode. When the switch has successfully created the binding,
LED1 is turned ON for that device.After that, S2 can be pressed on the switch device to
send the TOGGLE command. This will cause LED1 on the corresponding device to be
toggled.
3.2.3 Binding Details
Binding is a logical link between two devices at the application layer. Multiple bindings
can be created on a device, one for each type of data packet. In addition, a binding may
have more than one destination device ( one-to-many bindings ).For example, in a
lighting network with multiple switches and lights, each switch will control one or more
39
light. In that case, a binding should be created in each switch. This allows the application
to send the data packets without knowing the actual destination address.
Figure 3.5 The Binding Mechanism
Once a binding is created on the source device, the application can send data without
specifying a destination address (in the call to zb_SendDataRequest(), the invalid address
- 0xFFFE should be used as the destination ). This will cause the stack to look up the
destination in its internal binding table based on the command identifier of the packet.
There can be more than one destination in the binding entry. In that case, the stack will
automatically send a copy of the packet to each destination specified in the binding entry.
Note:
Bindings can only be created between “complementary” devices. That is, the
binding will only succeed if both devices have registered the same command_id in their
simple descriptor structures and one device has the command as an “output” while the
other device has it as an “input”.
40
3.2.4 Serial interfacing
By doing serial interfacing,our ultimate goal is to achieve “wireless chat” which is
useful in providing remote access to the user.Each of the two modules are separately
interfaced with their respective PC`s by using serial cable.Sensor reports can be
periodically viewed on PC through hyper terminal.Serial application is running on both
the devices.one of them transmits the data stream from the serial port over the air to
another zigbee device.Thus messages can be exchanged wirelessly between them and
appear on PC too via serial interfacing.In this way application of wireless chat is
accomplished.
3.2.5 A temperature sensing application
This scenario includes a temperature sensing device as a sensor node and an acyuator
device such as a heating/cooling unit.After identifying the devices as “produce” ( output
) and “consume” ( input ) ,we alott them command id`s.The temperature reading is
“output” from the temp sensor and “input” to the thermostat.The report of sensor
reading can be achieved in two ways either by “Auto Binding” or by “Key presses”by
pressing S1.Sensing device periodically sends temperature reading,when it crosses the
threshold level,coordinator orders the actuator device to lower or higher the temperature
accordingly.In hardware we have implemented this by changing the speed of motor. As
motor is present in almost all temperature controlling units.
41
Figure 3.6 Temperature sensing application
3.2.6 Some API Functions
zb_SystemReset
The zb_SystemReset function resets the device. The device reads the configuration
properties at this time.
Prototype
void zb_SystemReset ( void )
Parameters
None
Return Value
None
zb_StartRequest
The zb_StartRequest function starts the ZigBee stack. The device will either start a new
network or attempt to join an existing network depending on whether it is configured to
42
be a coordinator or router/end-device. After completion of this process, the device is
ready to send, receive and route packets in the ZigBee network.
Prototype
void zb_StartRequest ( void )
Parameters
None
Return Value
None
zb_PermitJoiningRequest
The zb_PermitJoiningRequest function is used to control the joining permissions and thus
allow or disallow new devices from joining the network.
Prototype
void zb_PermitJoiningRequest ( uint16 destination, uint8 timeout )
Parameters
destination
The destination parameter indicates the address of the device for which the joining
permissions
should be set. This is usually the local device address or the special broadcast address.
Return Value
ZB_SUCCESS or an error parameter
zb_BindDevice
The zb_BindDevice function establishes or removes a ‘binding’ between two devices.
Once bound, an application on the source device can send messages to the destination
device by referencing the commandId for the binding. The bindings are stored in the non-
volatile memory and restored upon a reset.
Prototype
43
uint8 zb_BindDevice ( uint8 create, uint16 commandId, uint8 *pDestination )
Parameters
create
The create parameter is TRUE to create a new binding, or FALSE to delete an existing
binding.
commandId
The commandId identifies message for which this binding should apply. Once a binding
is setup,the commandId can be used in calls to zb_SendDataRequest to send data.
pDestination
When adding a binding, the pDestination parameter indicates the 64-bit IEEE address of
the device to establish the binding with. If the pDestination is NULL, then the device will
bind with any other device that is in the Allow Binding
Return Value
None
zb_AllowBind
The zb_AllowBind function puts the device into the Allow Binding mode for a given
period of time. A peer device can establish a binding to a device in the Allow Binding
mode by calling zb_BindDevice with a destination address of NULL.
Prototype
void zb_AllowBind ( uint16 commandId, uint8 timeout )
Parameters
commandId
The commandId identifies the binding. The commandId value must match the
commandId passed into zb_BindDevice on the peer device.timeout
The timeout parameter indicates the amount of time in seconds to remain in the Allow
Binding Mode.If timeout is set to 0xFF, the device will be in the Allow Bind mode for
this commandId without any timeout.If timeout is set to 0x00, the device will cancel the
44
Allow Bind mode for this commandId.Otherwise, the device will be in the Allow Bind
mode for this commandId for the specified time.The maximum timeout value is 64.
Return Value
None
zb_SendDataRequest
The zb_SendDataRequest function initiates transmission of a data packet to a peer device.
The destination of the transmission may be the 16-bit short address of the peer device or
an invalid address.The zb_SendDataRequest function returns immediately. The status of
the send data operation is returnedto the Application Task via the zb_SendDataCnf
callback function.
Prototype
void zb_SendDataRequest ( uint16 destination, uint16 commandId, uint8 len, uint8
*pData, uint8 handle, uint8 ack, uint8 radius )
Parameters
destination
The destination parameter indicates the device in the ZigBee network to transmit the data
to.
commandId
The commandId parameter specifies the type of command being issued to the peer
device.
dataLength
The dataLength parameter contains the number of bytes in the pData buffer.
pData
The pData parameter is a pointer to the data to be transmitted.
handle
The handle parameter contains an identifier for the data transmission. This handle is used
in the
45
zb_SendDataConfirm callback by the stack to identify the transmission.
txOptions
This is a bit mask of the transmission options.
ZB_ACK_REQUEST ( 0x10 )- End-to-end acknowledgement and retransmission should
be
employed in the transmission of this packet. When using acknowledged transmission, the
zb_SendDataConfirm callback is delayed until the acknowledgement is received. If the
ack
parameter is FALSE, the zb_SendDataConfirm callback is called after the radio transmits
the
data. The ack parameter is ignored if the destination is a broadcast address.
radius
The radius parameter indicates the maximum number of hops the data can be relayed in
the
ZigBee network. Setting the radius parameter to 0 indicates a default radius of 15 hops.
This can
be used to limit the propagation of the data packet in a mesh network.
Return Value
None
zb_ReadConfiguration
The zb_ReadConfiguration function is used to get a Configuration Property from
Nonvolatile memory.
Prototype
void zb_ReadConfiguration( uint8 configId, uint8 len, void *pValue )
Parameters
configId
The configId parameter indicates the configuration property to read.
46
len
The len parameter indicates the size of the pValue buffer in bytes.
pValue
The pValue parameter is a pointer to a buffer that will contain the configuration property.
Return Value
None
zb_WriteConfiguration
The zb_WriteConfiguration function is used to write a Configuration Property to
nonvolatile memory.
Prototype
void zb_WriteConfiguration( uint8 configId, uint8 len, void *pValue )
Parameters
configId
The configId parameter indicates the configuration property to write. A list of
configuration
properties and their identifiers can be found in section 5.3
len
The len parameter indicates the size of the pValue buffer in bytes.
pValue
The pValue parameter is a pointer to a buffer that contains value to write to the
configuration
property.
Return Value
None
zb_GetDeviceInfo
The zb_GetDeviceInfo function retrieves a Device Information Property.
47
Prototype
void zb_GetDeviceInfo ( uint8 parameter, uint8 len, void *pValue )
Parameters
parameter
The parameter indicates the device information property to read.
Return Value
None
zb_FindDeviceRequest
The zb_FindDeviceRequest function is used to determine the short address for a device in
the network.
The device initiating a call to zb_FindDeviceRequest and the device being discovered
must both be a member of the same network. When the search is complete, the
zv_FindDeviceConfirm callback function is called.
Prototype
void zb_FindDeviceRequest( uint8 searchType, uint8 *searchKey )
Parameters
searchType
The searchType parameter indicates the method of search. The following search types
can be used:
ZB_IEEE_SEARCH
searchKey
The searchKey parameter contains information unique to the device being discovered.
The
searchKey parameter is dependant on the searchType. The content of the searchKey for
each
searchType follows:
ZB_IEEE_SEARCH – The searchKey is the 64-bit IEEE address of the device being
48
discovered.
Return Value
None
Callback Functions
When any request operation completes,a confirm response is issued for that operation in
the form of callback function respectively.Callback functions are there corresponding to
all the API functions mentioned above.
3.2.7 ZDO Interface
ZDO_Networkaddress_Request
This message will request the device to send a “Network Address Request”. This
message sends a broadcast message looking for a 16 bit address with a known 64 bit
IEEE address. You must subscribe to “ZDO Network Address Response” to receive the
response to this message. The response message listed below only indicates whether or
not the message was received properly.
ZDO_Networkaddress_Response
Status is a 1 byte field that indicates SUCCESS or FAILURE
ZDO_IEEEaddress_Request
This command will request a device’s IEEE 64-bit address. You must subscribe to “ZDO
IEEE Address Response” to receive the data response to this message. The response
message listed below only indicates whether or not the message was received properly.
49
ZDO_IEEEAddress_Response
Status is a 1 byte field that indicates SUCCESS or FAILURE.
ZDO_Simpledescriptor_Request
This command is generated to inquire as to the Simple Descriptor of the destination
device’s Endpoint.
The Endpoint byte represents the application endpoint the data is from.
ZDO_Simpledescriptor_Response
Status is a 1 byte field that indicates SUCCESS or FAILURE.
ZDO_Activeendpoint_Request
This command is generated to request a list of active endpoint from the destination device
ZDO_Activeendpoint_Response
Status is a 1 byte field that indicates SUCCESS or FAILURE.
ZDO_Bind_Request
This command is generated to request a Bind.
ZDO_Bind_Response
Status is a 1 byte field that indicates SUCCESS or FAILURE.
3.2.8 Important OSAL functions
osal_set_event( )
This function is called to set the event flags for a task.
Prototype
byte osal_set_event( byte task_id, UINT16 event_flag )
Parameter Details
task_id is the identifier of the task for which the event is to be set.
50
event_flag is a 2 byte bitmap with each bit specifying an event. There is only 1 system
event(SYS_EVENT_MSG), the rest of the events/bits are defined by the receiving task.
Return
Return value indicates the result of the operation.
RETURN VALUE DESCRIPTION
ZSUCCESS Success
INVALID_TASK Invalid Task
osal_start_timer( )
This function is called to start a timer. When the timer expires, the given event bit will be
set. The event will be set in the task from which the osal_start_timer function is called.
To explicitly specify the task id, use the osal_start_timerEx() function instead of
osal_start_timer().
Prototype
byte osal_start_timer(UINT16 event_id, UINT16 timeout_value);
Parameter Details
event_id is a user defined event bit. When the timer expires, the calling task will be
notified (event).
timeout_value is the amount of time (in milliseconds) before the timer event is set.
Return
Return value indicates the result of the operation.
RETURN VALUE DESCRIPTION
ZSUCCESS Timer Start Successful
NO_TIMER_AVAILABLE Unable to start the timer
51
3.3 NS2 Simulation
The NS2 simulator version 2.31 has been used for simulation.The work initially started
by taking into account the WPAN patch and IEEE 802.15.4 header files and
CCfiles.Various trace files and classes were studied.Physical and MAC layer have been
included and called upon as default.Algorithm used in the network is LEACH(Low
energy adaptive clustering hierarchy) with necessary modifications.Default coverage area
is set to be 10m.
First of all,PAN coordinator has been defined as the supreme head of the network.
Afterwards,nodes start getting formed,initialized and owned by sub heads.Every head
searches its vicinity and synchronizes with its neighbouring nodes.After that,data
exchange can take place using protocols such as CBR(constant bit rate)or FTP(file
transfer protocol).
3.3.1 LEACH: Low-Energy Adaptive Clustering Hierarchy
LEACH is a self-organizing,adaptive clustering protocol that uses randomizati- on to
distribute the energy load evenly among the sensors in the network.In LEACH, the nodes
organize themselves into local clusters, with one node acting as the local base station or
cluster-head. LEACH includes randomized rotation of the high-energy cluster-head
position such that it rotates among the various sensors in order to not drain the battery of
a single sensor.
Sensors elect themselves to be local cluster-heads at any given time with a certain
probability. Each node makes its decision about whether to be a cluster-head
independently of the other nodes in the network and thus no extra negotiation is required
to determine the cluster-heads. These clusterhead nodes broadcast their status to the other
sensors in the network. Each sensor node determines to which cluster it wants to belong
52
by choosing the cluster-head that requires the minimum communication energy. Once all
the nodes are organized into clusters, each cluster-head creates a schedule for the nodes
in its cluster
Algorithm Details:[19]
The operation of LEACH is broken up into rounds, where each round begins with a set-
up phase, when the clusters are organized, followed by a steady-state phase, when data
transfers to the base station occur. In order to minimize overhead, the steady-state phase
is long compared to the set-up phase.
Advertisement Phase
Initially, when clusters are being created, each node decides whether or not to become a
cluster-head for the current round. This decision is based on the suggested percentage of
cluster heads for the network (determined a priori) and the number of times the node has
been a cluster-head so far. This decision is made by the node n choosing a random
number between 0 and 1.
If the number is less than a threshold T(n), the node becomes a cluster-head
for the current round. The threshold is set as:
where
P = the desired percentage of cluster heads,
r = the current round,
and G is the set of nodes that have not been cluster-heads in the last 1
Prounds.
53
Each node that has elected itself a cluster-head for the current round broadcasts an
advertisement message to the rest of the nodes.After this phase is complete, each
non-cluster-head node decides the cluster which it will belong for this round.
Cluster SetUp Phase
After each node has decided to which cluster it belongs, it must inform the cluster-head
node that it will be a member of the cluster. Each node transmits this information back to
the cluster-head. During this phase, all cluster-head nodes must keep their receivers on.
Schedule Creation
The cluster-head node receives all the messages for nodes that would like to be included
in the cluster. Based on the number of nodes in the cluster, the cluster-head node creates a
TDMA schedule telling each node when it can transmit. This schedule is broadcast back
to the nodes in the cluster.
Hierarchical Clustering
A version of LEACH is extended to form hierarchical clusters. In this scenario, the
cluster-head nodes would communicate with ”super-clusterhead” nodes and so on until
the top layer of the hierarchy,at which point the data would be sent to the base
station.This modification of hierarchical clustering to LEACH has been employed in our
case too.
3.3.2 The Energy model
“Energy Model” is an important node attribute in NS2. The energy model represents level
of energy in a node.The energy model has an initial value which is the level of energy the
node has at the beginning of the simulation.
54
The initial-energy is to be passed along as a parameter and txPower_ and rxPower_
denote the energy usage for receiving and transmitting packets. The class methods (
DecrTxEnergy(txtime, P_tx)) and every packet received ( DecrRcvEnergy (rcvtime,
P_rcv)) are used to decrease the energy level of the node for every packet transmitted by
the node.If the energy level at the node goes down to zero, no more packets can be
received or transmitted by the node and it dies down.
An 802.15.4 network on NS2 simulator
55
CHAPTER 4
FINDINGS AND INNOVATIONS
4.1 Clustering
The main features of Zigbee based cluster based architecture for home area networking
are:
- Less complex routing data paths to the PAN-coordinator. It is due to the fact that
in clustered based algorithm only the cluster head need the information to route that data
to the sink.
- The energy consumption in case of a clustered based architecture is reduced. As
the number of nodes in a clustered based activity is done through the heads so the nodes
don't need to wake up at irregular intervals for routing the data-paths, as in the case of
flat-routing schemes.
- The life time of the network is increased. A home area network can be deployed
having a longer lifetime.
4.1.1 Proposed Clustering Algorithm
Startup Phase
When the network is initialized, each node on the network participates in the election for
the cluster head. A node 'n' would only be elected as a cluster-head if its energy density
would be maximum in a neighborhood of defined radius 'r'. [18]
(1)
56
Figure 4.1 A clustered based Zigbee Home Area Network Model
Cluster Formation Phase-
After the formation of cluster heads, the left-over nodes join that cluster head which is at
the least weighted distance as compared to other cluster heads. This phase of cluster
formation is repeated until all the node is the network have established connection with
the nearest cluster head.
Due to the probabilistic approach of deciding the cluster head, the formation of
cluster might be uneven. To overcome such a situation, a minimum and maximum
threshold is defined. If in a cluster the number of nodes is less than defined threshold then
it would first split, and then the nodes would merge to a nearest cluster head. Similarly, if
the number of nodes exceed from a particular threshold then it should split into smaller
halves. Also a sensor is able to join another cluster head if it can get the shortest path to
sink through the other cluster head.
Balancing Cluster-head formation
For a balanced clustered approach the nodes should rotate the cluster head formation
between themselves. If a cluster-head has exhausted and can't further participate in
network as a cluster-head then the cluster-head election within that cluster should again
be held and new cluster head should be formed.
57
4.2 Performance analysis of a Zigbee HAN
The performance of an end device and coordinator used in the home area network has
been analyzed. The hardware that had been used is the Zigbee SoC by Texas Instruments
i.e. Chipcon CC2430. The hardware contains an integrated PCB antenna; the IEEE
802.15.4 compliant RF transceiver CC2430 with necessary support components, sensors,
joystick, buttons and LED’s that can be used to demonstrate the Zigbee Home profiles.
Table 4.1, shows the transient times of CC2430 during its various activities.
Table 4.1 Transient times of Chipcon CC2430
Sleep to idle 975us
Idle to transmit 192us
Idle to recieve 192us
Receive to transmit 320us
Transmit to recieve 250us
The two essential network parameters that are required for the determination of
duty cycle are the beacon order BO and the super frame order SO. In a beacon-enabled
network, device receives beacons and exchanges data with a coordinator. The rest of
time, device is in the sleep mode. Table II gives the measured power consumption of
CC2430.
58
Table 4.2 Measured power consumptions @ 2.7V
PTX 26mA 70mW
PRX 29mA 78.3mW
PCCA 30.7mA 83mW
PI 1.4mA 3.79mW
PMCU 0.8mA 2.25mW
PS 0.06uA 1.62uW
4.2.1 Reduced Function Device (End Device) Configuration and analysis
The end device in home area network is either an actuator or a sensor device. The end
nodes can be configured to send data either periodically or on query based logic. For
example, an end device like a temperature sensor can send data every 75 seconds or can
also send data when needed. It has to be taken care of, that the end device shouldn’t wake
every beacon interval, else battery drainage problem would reduce the network life-time.
Duty cycle signifies that the device wakes up to receive beacon from coordinator.
It should be long enough to ensure that the beacon is not missed. The duty cycle of device
[13] is calculated in terms of various beacon receptions. Direct and indirect data
transmissions and receptions have also been catered in calculations.
(1) where, tBR is Beacon reception time and is given by
(2)
tST is the transmission time for short frames. Usual applications in home network invoke
short data frame length packets.
(3)
The acknowledge ACK reception time and indirect data transmission time are:
59
(4)
(5)
ACK transmission time is obtained by adding up receive to transmit time, wait duration
and ACK frame length.
(6)
Network scanning time either accounts for a new node which has to join the network
or the node which has lost its contact.
(7)
The value of duty cycle of end device is significant because it is ultimately proportional
to network longevity.The network lifetime is maximized when duty cycle is
minimum.Our clustering technique ensures that the on duty cycle is minimized.
The power consumption of device that is used for IEEE 802.15.4 is
(8)
where, Beacon reception energy
(9)
Transmission energy for short frames is
(10)
The energy required that is required for indirect communication of short frames is
(11)
Energies for ACK reception and transmission are
(12)
(13)
respectively and network scanning energy is formulated as
60
(14)
4.2.2 Fully Functional Device (Coordinator) Configuration and analysis
Function of coordinator is to maintain synchronization with the cluster heads by regularly
receiving beacons from them. Duty cycle of coordinator is:
(15)
where,
tBT is the beacon transmission time and tLT is the time for transmission of long data frames
if any
(16)
Power consumption of coordinator can be ultimately expressed as
(17)
where, Beacon transmission energy is
(18)
The sink node needs more power as it has to transmit the received data and this power
cannot be compromised.Thus it is same both for the clustered or nonclustered networks
respectively. The calculated values for power consumption of an end device versus the beacon interval
have been plotted. When the beacon interval goes long, power consumption of device
decreases as can be observed from the graph.
61
Figure 4.2 RFD power consumption as a function of beacon interval
Referring to Figure 4.2, less energy is required in searching the network as the beacon
interval increases. Beacon order BO which basically determines beacon interval BI has
atypical range of 6-10.We have calculated power consumption for BO=6 and SO=0. For
home area networking applications, this value suffices as we have short frame lengths in
such applications. It was observed during calculations that power consumption increases
in case of higher BO.
In Figure 4.3, power consumption of coordinator is plotted as a function of BI. Same
trend is observed as was for the end device but as coordinator performs most of the
activities for the network and governs the network being an FFD, its power goes upto
13mW.
62
Figure 4.3 Coordinator power consumption as a function of beacon interval
4.2.3 Inferences:
A beacon-enabled and hierarchically clustered topology has been proved to be the most
optimum in terms of power consumption and energy efficiency. We have done
performance analysis by using different network parameters. Various relationships have
been deduced for beacon receptions and transmissions in terms of time and energy.
Graphical analysis has been done between the beacon interval and power consumption of
end device and coordinator. Analysis show that with increase in beacon interval, power
consumption reduces. Longevity is essentially required in HAN which is effectively
accomplished by our low power consumption network. If we do not use clustering,power
consumption would have been twice or thrice the present calculated value.Thus a
clustered based Zigbee network, with low order beacons is suitable as frame lengths are
usually short and need of indirect communication is seldom.
63
Table 4.3 Network parameters
PARAMETER SYMBOL VALUE
Beacon order BO 6-10
Superframe order SO 0-2
Average no. of
retransmissions
y 3
Hidden node probability h 30%
Uplink data transmission
interval
UI 1-100
Downlink data transmission
interval
DI 100
Network scanning interval INS 1h
Beacon interval BI 0.96s
ACK frame length LA 11octets
Beacon frame length LB 26octets
Data frame length LD 50octets
Data frame overhead LO 25octets
No. of devices NA 4
No. of nodes NB 500
CCA analysis time tCCA 128us
ACK wait duration tAW 864us
Back off period tBOT 320us
Interframe spacing tIFS 192-640us
Response time for data
request
tRES 19.52ms
64
Table 4.4 Assumptions
Items in a long frame A 8
Radio data rate R 250kbps
Synchronization in accuracy t1 100us
Contention access period tCAP 15.36-61.44ms
aBasesuperframeDuration SD 960
Crystal tolerances Єtx,rx 20ppm
65
CHAPTER 5
CONCLUSION AND FUTURE WORK
5.1 Conclusion
We have successfully implemented lighting and temperature control for a home
environment while working on network and application layer.The experiments range
from testing of a single light switch to light and temperature control of multiple
rooms.Zigbee communication has been shown between PAN coordinator,sensor nodes
and actuator nodes.Remote access to home has also been provided.You can receive
updates and monitor changes in the network via your PC while you are away.
The architecture we have proposed is hierarchical and clustered which ideally suits for
automation of multiple rooms in home.Basically we have used attributes of star
topology,mesh links have been added where needed.
A zigbee enabled home is human friendly and less complex,it will never interfere with
the wired infrastructure nor create noises or attenuation of electromagnetic
waves.Moreover zigbee wireless technology can be easily interfaced with remote devices
compared to some wired technology.
Combination of two or more technologies can also prove to be effective like combining
Zigbee and Bluetooth,zigbee with GPRS or WiFi.This will gather advantages of both
standards and results in manifold benefits.Zigbee is the technology for bridging the gap
between bluetooth and WiFi.
When we talk about automation all around the home,we discover that some operations
may be performed better under non beacon mode eg.smoke detectors,fire alarms,intrusion
66
detectors.So a mix of beacon and non beacon mode may also be used and the network
can be integrated afterwards.
Another suggestion for more effective realization of zigbee automated home is to zigbee
enable all the remote devices such as street mailbox,telephone lines,energy meters.
Hence no question remains about the fact that zigbee is the best technology for home
automation.It provides low data rate,least power consumption and long battery life.
5.2 Future work
• Due to limitations of time constraint,we have only implemented light and
temperature applications,other ideas can be worked upon in future.
• NS2 simulation can be extended to show further details and calculations of power
consumption and battery life estimation.
• Theoretically we have explained detailed significance and applications of LEACH
protocol and have presented our own clustering algorithm too.If time would have
allowed,simulation algorithm could be worked upon by doing extensive
modification in header files and getting even better results.
• Use of a similar but enhanced-featured module CC2431 can be made so that
location estimation and security ensurance is easily achieved.
• Separate power measurements could be performed for all applications and
concerns about real battery life time can be further investigated.
• In future,the present project can be merged with a home robot server which itself
is another project integrating WSN`s and Robotics.
REFERENCES
[1] A. R. Al-Ali and M. AL-Rousan,“Java-Based Home Automation System” , IEEE
Transactions on Consumer Electronics, Vol. 50, No. 2,pp. 498-594, May 2004.
[2] Guangming Song; Zhigang Wei; Weijuan Zhang; Aiguo Song, "Design of a
Networked Monitoring System for Home Automation," Consumer Electronics, IEEE
Transactions on , vol.53, no.3, pp.933-937, Aug. 2007
[3] Jae-Min Choi; Byeong-Kyu Ahn; You-Sung Cha; Tae-Yong Kuc, "Remote-controlled
Home Robot Server with Zigbee Sensor Network," SICE-ICASE, 2006. International
Joint Conference , vol., no., pp.3739-3743, Oct. 2006
[4] Zhou, Yiming; Yang, Xianglong; Guo, Xishan; Zhou, Mingang; Wang, Liren, "A
Design of Greenhouse Monitoring & Control System Based on Zigbee Wireless Sensor
Network," Wireless Communications, Networking and Mobile Computing, 2007. WiCom
2007. International Conference on , vol., no., pp.2563-2567, 21-25 Sept. 2007
[5] Shen Lin; Shi xiangquan; Ling Ming, "A wireless network based on the combination
of Zigbee and GPRS," Networking, Sensing and Control, 2008. ICNSC 2008. IEEE
International Conference on , vol., no., pp.267-270, 6-8 April 2008
[6] Qiyu Peng; Budinger, T.F., "Zigbee-based Wireless Intra-oral Control System for
Quadriplegic Patients," Engineering in Medicine and Biology Society, 2007. EMBS 2007.
29th Annual International Conference of the IEEE, vol., no., pp.1647-1650, 22-26 Aug.
2007
[7] Kidd, C. D., Orr, R., Abowd, G. D., Atkeson, C. G., Essa, I. A., MacIntyre, B.,
Mynatt, E. D., Starner, T., and Newstetter, W. 1999. The Aware Home: A Living
Laboratory for Ubiquitous Computing Research. In Proceedings of the Second
international Workshop on Cooperative Buildings, integrating information,
Organization, and Architecture (October 01 - 02, 1999).
[8] Jianliang Zheng and Myung 1. Lee, “Will IEEE 802.1 5.4 Make Ubiquitous
Networking a Reality?:A Discussion on a Potential LOW Power,Low Bit Rate Standard,”
IEEE Communications Magazine June 2004
[9] Ambient Intelligence,Nigel Shadbolt,University of Southampton
[10] Sung-Hwa Hong; Byongguk Kim; Doo-Seop Eom, "A Base-station Centric Data
Gathering Routing Protocol in Sensor Networks Useful in Home Automation
Applications," Consumer Electronics, IEEE Transactions on , vol.53, no.3, pp.945-951,
Aug. 2007
[11] Timmons, N.F.; Scanlon, W.G., "Analysis of the performance of IEEE 802.15.4 for
medical sensor body area networking," Sensor and Ad Hoc Communications and
Networks, 2004. IEEE SECON 2004. 2004 First Annual IEEE Communications Society
Conference on , vol., no., pp. 16-24, 4-7 Oct. 2004
[12] Kohvakka, M., Kuorilehto, M., Hännikäinen, M., and Hämäläinen, T. D. 2006.
Performance analysis of IEEE 802.15.4 and Zigbee for large-scale wireless sensor
network applications. In Proceedings of the 3rd ACM international Workshop on
Performance Evaluation of Wireless Ad Hoc, Sensor and Ubiquitous Networks
(Terromolinos, Spain, October 06 - 06, 2006). PE-WASUN '06. ACM, New York, NY,
48-57
[13]www.zigbee.org/imwp/idms/popups/pop_download.asp?contentID=5162
[14] Home networking with Zigbee by Mikhail Galeev
www.embedded.com/columns/technicalinsights
[15] J. Zheng and M. J. Lee, “A Comprehensive performance study of IEEE 802.15.4,”
IEEE Press Book, 2004.
[16] www.embedded-computing.com/.../zigbee/win_04
[17] http://www.jennic.com/elearning/zigbee/files/html/module4/module4-1.htm
[18] Lee, SangHak; Ham, KyungSun; Park, ChangWon, "Distributed Clustering for
Wireless Sensor Networks," Communications and Information Technologies, 2006.
ISCIT '06. International Symposium on , vol., no., pp.1113-1117, Oct. 18 2006-Sept. 20
2006
[19] tcs.hut.fi/studiesT-79.194/papers/yrjola_050316.pdf