Generally many people get confused with two terms XBee and ZigBee, most of them use it interchangeably. But this is actually not the case; ZigBee is standard protocol for wireless networking. While XBee is a product that supports various wireless communication protocol, including ZigBee, Wi-Fi (Wi-Fly module), 802.15.4, 868 MHz module etc. Here we are mainly focused on Xbee/Xbee-PRO ZB RF module which consists of ZigBee firmware.
Just think of a calculator in computer, where complex calculations are performed with user friendly interface. The task would have been very difficult and tedious if only hardware would have been available. So, at highest level, the availability of software makes problem solving process easier. Whole process is divided into layers of the software by the actual hardware which is called by higher levels.
We even use the concept of layers in our daily life. For example, sending courier/letter to your friend’s house, sending email from one point of world to another. Similarly, most modern network protocols even employ a concept of layers to separate different software components into independent modules that can be assembled in different ways. One may have to get his hands dirty for getting the in depth understanding of Xbee architecture, but we will make the things very simple for you.
Let’s start with some basic terms like routing, collision avoidance, and acknowledgement. For understanding first term just go by its name, “route” which means to track or identify the path. In networking, routing means to provide direction to the data from source node to destination node. When two nodes in network attempt to transmit simultaneously, creates a situation called collision. So, generally Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) technique to avoid collision you can learn more about CSMA using this link. Basically in it the nodes talk in the same way that human conversation; they briefly check to see that no one is talking before they start to send data.
Whenever receiver successfully receives the transmitted data, it acknowledges the transmitter. The flow of data must not be allowed to overwhelm the receiver radio. Any receiving radio has a limited speed at which it can process incoming data and a limited amount of memory in which to store incoming data.
There are major four layers available in ZigBee stack which are physical layer, Media access layer, Network layer and application layer.
Application layer defines various addressing objects including profiles, clusters, and endpoints. You can see the ZigBee stack layers in the figure above.
Network layer: It adds routing capabilities that allows RF data packets to traverse multiple devices (multiple "hops") to route data from source to destination (peer to peer).
MAC layer manages RF data transactions between neighboring devices (point to point). The MAC includes services such as transmission retry and acknowledgment management and collision avoidance techniques.
Physical layer: It defines how devices are connected to make a network; it defines the output power, number of channels and transmission rate. Most ZigBee applications operate on the 2.4 GHz ISM band at a 250kbps data rate.
Most XBee families have flow control, I/O, A/D and indicator lines built in which can be configured using appropriate commands. Analog samples are returned as 10-bit values. The analog reading is scaled such that 0x0000 represents 0V, and 0x3FF = 1.2V. (The analog inputs on the module cannot read more than 1.2V)
To convert the A/D reading to mV, do the following:
AD (mV) = (A/D reading * 1200mV) / 1023
Data Transmission in ZigBee
You can call a network as combination of software and hardware which is capable of sending data from one location to another. Hardware is responsible for carrying the signals from one point of network to another. Software consists of instruction sets that make it possible to work as we expect.
Generally the data transmission by ZigBee packets can be done in two ways: unicast and broadcast.
In simple words Broadcast means the information/programme transmitted by radio or TV. In other words broadcast transmissions are sent to many or all devices in the network. Broadcast transmissions with the ZigBee protocol are propagated in the whole network such that all nodes receive the transmission. To accomplish this, the coordinator and all routers that receive a broadcast transmission will retransmit the packet three times.
Unicast transmissions in ZigBee route data from one source device to another destination device. The destination device could be an immediate neighbor of the source device, or it could have several hops in between the way. An example is shown below in the figure explaining mechanism for recognizing the reliability of the bi-directional link.
Basics of network for Xbee routers and Coordinator
To reach your friend’s house, what you need? You just need his address. Similarly, for sending the data from one Xbee module to other, you need its unique address. Just like with people, Xbee even have several addresses, each one have a particular role in networking. There are two types of addresses Static address (64-bit address) and Dynamic address (16-bit address).
64-bit address is unique universally; it is firmed inside the Xbee module by the manufacturer. No other ZigBee radio on earth will have that same static address, on back of every xbee module you can see this address as shown below, and notably the higher part of address “0013A200” is same for every xbee module.
A device receives a 16-bit address which should be unique locally, when it joins a ZigBee network. The 16-bit address 0x0000 is reserved for the coordinator. All other devices receive a randomly generated address from the router or coordinator device that allows the join. The 16-bit address can change when two devices are found to have the same 16-bit address or a device leaves the network and later joins (it can receive a different address).
It is always easier for our brain to remember strings instead of number. Hence, each Xbee module in a network can be assigned with a node identifier. Node identifier is set of characters i.e. strings which can be more human friendly way of addressing a node in a network.
Personal Area Networks:
Network developed by these Xbee modules are called personal area networks or PANs. Each network is defined with a unique PAN identifier (PAN ID). This identifier is common among all devices of the same network. ZigBee supports both a 64-bit and a 16-bit PAN ID. Both PAN addresses are used to identify a network uniquely. Devices on the same ZigBee network must share the same 64-bit and 16-bit PAN IDs. If multiple ZigBee networks are operating within range of each other, each should have unique PAN IDs.
The 16-bit PAN ID is used to address MAC layer in all RF data transmissions between devices in a network. But, due to the limited addressing space of the 16-bit PAN ID (65,535 possibilities), there may be chance that multiple ZigBee networks (within range of each other) can have the same 16-bit PAN ID. To resolve these conflicts, the ZigBee Alliance created a 64-bit PAN ID. ZigBee defines three different device types: coordinator, router, and end device.
One coordinator is always required in every network for charging of setting up the network. So, it can never sleep. It is also responsible for selecting a channel and PAN ID (both 64-bit and 16-bit) to start the network. It can allow routers and end devices to join the network. It can assist in routing data in a network.
There can be multiple routers in a network. One router can get signals from other routers/EPs (End Points). It can also never sleep. It must join a Zigbee PAN before it can transmit, receive, or route data. After joining, it can allow routers and end devices to join the network. After joining, it can also assist in routing data. It can buffer RF data packets for sleeping end devices.
There can be multiple End Points as well. It can go in sleep mode to save power. It must join a ZigBee PAN before it can transmit or receive data and it cannot even allow devices to join the network. It is dependent on parent for transmit/receive data.
Since the end device can go in sleep mode, the parent device must buffer or hold incoming data packets until the end device wakes up and receive the data packets.
Different Network Topology in ZigBee
Network topology refers to the way in which network has been designed. Here, the topology is geometric representation of relationship of all the links and linking devices (Coordinator, Router and End devices) to one another.
Here we have four basic topology mesh, star, hybrid and tree.
In Mesh Topology, every node is connected with each other node expect the end device because end devices can’t communicate directly. To enable simple communication between two ZB radios, you'll need to configure one with the coordinator firmware, and one with router or endpoint firmware. Main advantage of Mesh network is that if one of the links becomes unusable, it does not incapacitate the entire system.
In a star topology, each device has a dedicated point-to-point connection to a central controller (Coordinator). All the devices are not directly linked to each other. Unlike a mesh topology, in star topology one device can’t send anything directly to another device. The coordinator or hub is there for exchange: If one device wants to send data to another, it sends the data to the coordinator, which further sends the data to the destination device.
Hybrid network are those networks which contains two or more types of communication standards. Here, hybrid network is combination of star and tree network, few end devices are connected directly to the coordinator node and other end devices needs the help of parent node to receive the data.
In Tree network, routers forms the backbone and end devices generally clustered around each router. It’s not very different from a mesh configuration except the fact that there routers are not interconnected you can visualize these networks using figure shown above.
The XBee Programmable module is equipped with a Free scale application processor. This application processor comes with a supplied boot loader. This XBee ZV firmware is based on Embernet 3.x.x ZigBee-PRO stack, XBee-Znet 2.5 modules can be upgraded to this functionality. You can check the firmware using ATVR command which we will discuss later in the chapter. XBee version numbers will have 4 significant digits. A version number can also be seen using ATVR command. The response returns 3 or 4 numbers. All numbers are hexadecimal and can have a range from 0-0xF. A version is reported as "ABCD". Digits ABC are the main release number and D is the revision number from the main release. The API discuss in chapter 4 and AT commands are almost same for Znet 2.5 and ZB firmware.
In telecommunications, the entire Hayes command is a language specific commands developed for the Hayes modem Smart Modem, 1981 they were a series of short words to control the modem making communication and setting of up of a modem simple in those days.
XBee also works on command mode and has set off AT Commands which stands for ATTENTION, these commands can be sent to XBee via terminals XBee and AT configured XBee radios have two modes of communication
Transparent: The radio only passes the information it receives to the remoter radio address it has been configured to. The data sent through serial port is received by XBee as it is.
Command: This mode is used to talk to radio and configure some preconfigured modes, we communicate to the modules while in this modes and change configuration.
You can type +++ and wait one second without pressing any other buttons, the message OK should then appear as the image of the terminal just up. By OK, the XBee tells us he spent in COMMAND mode and is ready to receive configuration messages.
If you wait more than 10 seconds without pressing a button, the XBee returns TRANSPARENT mode. You must then retype +++ to return to COMMAND mode.
XBee AT Commands:
AT (TEST): This is the test command to check if the module is responding an OK as reply confirms the same.
ATDH: Destination Address High. To configure the upper 32 bits of the 64-bit destination address DL and DH combined gives you 64 bit destination address.
ATDL: Destination Address Low. This again for configuring the lower 32 bits of the 64-bit destination address.
ATID: This command changes the PAN ID (PersThe ID is 4 bytes of hexadecimal and can range from 0000 to FFFF
ATWR: Write. Write parameter values to non-volatile memory so that parameter modifications persist through subsequent resets.
Note: Once WR is issued, no additional characters should be sent to the module until
After the "OK\r" response is received.
ATRE (Restore Defaults): Restores factory settings to the module, is very useful if the module does not responds.
To configure your module using AT command after entering command mode(i.e pressing +++) you need to type in terminal AT(XY) for example ATID 1001( this value can be anything from 0 to FFFF ,XBee commands always uses hexadecimal values).press enter if it returns OK then you can quickly type in terminal ATID to see if the value has been changed this will be finally written only after Using ATWR in the session the written value vanishes as soon as the module is powered off if ATWR is not used.
If you want to learn more about ZigBee Modules then here is the great resource from Digi.