IoT(Internet Of Things)

 

 

 

WPAN - XBee

 

XBee is a brand name (not a name of a technology) which is implemented based on IEEE 802.15.4. It is designed for point-to-point and star communications at over-the-air baud rates of 250 kbit/s. In terms of basic standard, it is similar to other 802.15.4 based technology like ZigBee, but Xbee is designed for lower cost and easy to use solution that may sacrifice some of functionality (e.g, Mesh Network capability) from the standard. It looks as shown below. You can easily embed this onto your board or more easily plug into Arduino and have fun.

 

XBee module from MaxStream and XBee PRO module from Digi

Figure 1. An XBee module from MaxStream and an XBee PRO module from Digi. Both carry a wire antenna and two rows of 10 pins.

Is XBee the same as ZigBee ?

The opening paragraph calls XBee a brand name rather than a technology. That point is easy to lose, because people often use XBee and ZigBee as if they were the same thing. Let's separate the module from the protocol that runs on it.

XBee is a family of radio modules made by Digi International. The first modules came from MaxStream, a company that Digi bought, so the left module in Figure 1 still carries the MaxStream name. The module is hardware. The protocol it speaks depends on the firmware loaded into it.

The original XBee and XBee-PRO modules, often called Series 1, run IEEE 802.15.4 firmware. This is the plain 802.15.4 MAC with point-to-point and star links and no mesh routing, which is the behaviour described in the opening paragraph. XBee Series 2, later sold as XBee ZB, runs ZigBee firmware instead. So it supports the Coordinator, Router and End Device roles and mesh routing. Digi also offers its own mesh protocol, DigiMesh, on some modules. The newer XBee 3 modules can run any of the three on the same hardware.

This has a practical consequence. Two XBee modules do not always talk to each other. A module on 802.15.4 firmware and a module on ZigBee firmware use different network layers, so they cannot form one network. Check the firmware before you mix modules. An XBee can therefore be a ZigBee device, but only when it runs ZigBee firmware.

The two modules in Figure 1 also differ in transmit power. The XBee transmits at about 1 mW, or 0 dBm. The XBee-PRO transmits at up to 63 mW, or 18 dBm, in the versions sold in the US. So it reaches much further with the same receiver.

  • XBee is hardware, and ZigBee is a protocol : the firmware decides which protocol the module speaks.
  • Series 1 is 802.15.4 without mesh : it gives point-to-point and star links, as described at the top of this page.
  • Modules with different firmware do not interoperate : 802.15.4, ZigBee and DigiMesh modules cannot join each other's networks.

How does a host talk to an XBee module ?

An XBee module never works alone. A microcontroller, an Arduino or a PC drives it over a serial line. So the next question is what the host sends to the module, and the module offers two different answers.

The module has 20 pins at 2 mm pitch, which does not fit the 2.54 mm pitch of a normal breadboard. This is why most people plug it into an adapter board or an Arduino shield. The host connects to the UART pins, DIN and DOUT, and the module runs from about 3.3 V. The default UART rate is 9600 bps.

The first mode is transparent mode, also called AT mode. Whatever the host writes to the UART goes over the air to one destination address. Whatever arrives over the air comes out of the UART. To change a setting, the host sends +++ with a silent guard time before and after it. The module then accepts AT commands, such as ATID for the PAN ID, ATCH for the channel, ATMY for its own 16-bit address and ATDL for the destination address.

The second mode is API mode. Here the host and the module exchange structured frames instead of raw bytes. Each frame names its own destination, so the host can talk to many modules without any reconfiguration. A received frame also reports the source address and the signal strength. The table below shows the frame format.

 

Field

Size

Content

Start Delimiter

1 byte

0x7E

Length

2 bytes

Number of bytes in Frame Data, MSB first

Frame Data

variable

API identifier of one byte, then the data for that identifier

Checksum

1 byte

0xFF minus the lowest 8 bits of the sum of all Frame Data bytes

 

The receiver checks the checksum in one step. It adds all Frame Data bytes and the checksum, and keeps the lowest 8 bits. The result must be 0xFF. Transparent mode is enough for a simple cable replacement between two boards. API mode is the better choice as soon as a network has more than two nodes.

  • The host uses a UART : the module needs only power, DIN and DOUT to work.
  • AT mode works like a wireless serial cable : data goes to one fixed destination, set by ATDL.
  • API mode carries the address in every frame : each frame has a 0x7E delimiter, a length, the frame data and a checksum.

Reference

[1] Is XBee ZigBee?