Setting Serial Adapter Baud Rate

Setting the Xbee RS-232/485 Serial Adapter settings such as Baud Rate

Although the title of this page is setting the serial baud rate, it is designed to explain the full serial-specific setup. You should also review the appropriate XBee Module Product manual to understand the capability for buffers, flow control and Transparent-vs-API modes of operation.

This Digi support page lists the most recent XBee Product manuals.

The General Paradigm

In most serial protocol systems - such as Modbus or Allen-Bradley/DF1 - the remote XBee RS232/485 Adapters are loaded with the Router AT-Mode firmware. Any serial messages they receive over the RF are send out the serial pins - either to the attached microcontroller, or via RS-232/485 drivers to an external device.

Since the attached device does not understand how to address packets on the mesh, the XBee returns any serial response received either to the node addressed by the DH/DL setting, or by default "Mesh Aggregator". In Znet and Zigbee this means the coordinator in the Digi gateway.

See Serial encap by API for a fuller discussion of encapsulating legacy protocols over mesh.

Using XCTU

Loading Firmware

XCTU allows you to reload the Xbee firmware, as well as set the parameters (often referred to as AT commands/settings).

The Digi XBee RS-232 Adapter and XBee RS-485 Adapter expect the normal Router AT firmware. The Digi XBee RS-232PH Adapter (PH = Port Harvesting) requires a special firmware build since it must function as an end-device and sleep some percentage of the time.

If your attached device is programmable and can understand the Digi/MaxStream API protocol, then you can use the Router API firmware.

With very specialized host firmware you can also set the XBee serial adapters to deep-sleep and power remote devices from battery. For example, the adapter could sleep for one hour, then wake and issue a dummy I/O sample to the host. The host must be waiting for this message, then send the serial poll and expect a serial response. While this sounds easy, in practice it is difficult to get the timing correct.

Restoring the Product Code/DD Parameter

If you reflash an Xbee module, the Product Code or DD parameter is reset to zero. You should restore the lower 16-bit to the values below. If you leave this set to zero, then your X4 Web interface will display the device as Unspecified and not allow you to set the serial baud rate and other settings.

It is also possible that some host programs will not work properly with an adapter with a product type of zero - for example, if the program expects to confirm RS-485 setting, it might require than the lower 16-bits of the DD parameter be 0x0006.

DD lower word for Digi Product Type of XBee serial adapters:

0x0000 Unspecified
0x0005 XBee RS-232 Adapter
0x0006 XBee RS-485 Adapter
0x0009 XBee RS-232PH (Power Harvesting) Adapter

The full list and discussion of Product Codes in on this wiki page

Setting the Baud Rate / BD Parameter

The Baud rate is the BD setting, with standard baud rates defined as the codes 0 to 7.

0x0000 1200 bps
0x0001 2400 bps
0x0002 4800 bps
0x0003 9600 bps - factory default
0x0004 19200 bps
0x0005 38400 bps
0x0006 57600 bps
0x0007 115200 bps

Notes:

Setting the Serial Parity / NB Parameter

The Serial Parity is the NB command, with standard settings defined as the codes 0 to 3.

0x0000 No Parity- factory default
0x0001 Even Parity
0x0002 Odd Parity
0x0003 Mark Parity (bit is always logical 1)

Notes:

Currently it is not possible to set 7,E,2 or 7,O,2 in the XBee

Setting the Stop Bits / SB Parameter

The Stop Bits is a the NB command - not all XBee support this (see notes)

0x0000 1 stop bit - factory default
0x0001 2 stop bits (disables use of MARK parity)

Notes:

This command makes debut in XB24-ZB firmware versions 2x6x - so available SUMMER 2009

Setting the Data Bits / Not Possible

As of May 2009, it is not possible to set 7 data bits in the XBee, so is not possible to set 7,E or 7,O in the XBee. However, host software can manually set the 8th parity bit and send as 8,N.

Setting the Packetization Timeout / RO Parameter

The XBee receiving serial data buffers the incoming data until one of this becomes true:

Note that RO is character times - not milliseconds! It is also not how many bytes per packet, so do not set to 6 if you expect 6 byte packets.

The default of 3 means roughly 3 msec at 9600 baud, but 25 msec at 1200 baud. The default of 3 works for any dedicated processor which can sustain a steady flow of serial bytes. If you are having packets sent prematurely, consider bumping RO to 20, then 50 if the problem continues.

Setting the Flow Control / D7 Parameter

For RS-232 and RS-485 outbound flow (or hardware duplex) control is accomplished by the DOI7 pin.

0x0000 n/a No Flow Control
0x0001 RS-232 CTS flow control
0x0006 RS-485 Transmit enable on low signal
0x0007 RS-485 Transmit enable on high signal

See the most recent XBee Product manuals for a fuller discussion of RTS/CTS flow and RS-485.

If you are using the XBee RS-485 Adapter - Support for XBee RS-485 AdapterDigi XBee 485 Adapter and configuring it through the web UI, uncheck the CTS flow control check-box (turn it off) on the Basic Settings page, then go to the Advanced Settings page and enter a seven (7) into the DIO7 configuration (D7): setting.

Using the Gateway Web Interface

If your XBee serial adpater is properly associated with your Digi gateway - and the correct DD values are loaded into your adapters, then you can set the serial settings from the comfort of the Web interface. The product types should be listed as RS-232 Adapter, RS-232 PH Adapter, or RS-485 Adapter. If this is true, then you will see a Network View of XBee Devices looking like this:

Note The sorting by Node ID is a new feature in the March 2009 X4/X8 firmware - the CLI disp mesh command retains the old order to prevent breaking automated scripts. It is not case sensitive - notice the one mistaken lower-case 'n' in the above example. Placing the '_' on the gateway id causes it to be listed first.

Click (select) the desired adapter, and you will see a web page showing Basic Settings, including Basic Radio Settings, Advanced Radio Settings, and Serial Interface Settings. If you receive an error that the device has no configurable parameters, then either it is sleeping or has left the network - in both of this situations the adapter is still listed in the Xbee route tables, but does not respond to parameter reads.

The settings are explained above on this page, plus the Web UI help quotes the Xbee Product Manual PDFs quite closely - that is the little blue "?" patiently waiting for your attention in the upper right hand corner of the page. remember to hit the APPLY button after making your changes.

Note The Packetization Timeout (RO) parameter is mistaken listed as msec - this will be fixed in future gateway firmware.