Home > Support > Knowledge Base
Knowledge Base
Reset Search



XBee 802.15.4 Digital Input/Output Line Passing

« Go Back


Problem Resolution

The basic concept behind Digital Input/Output (DIO) lines is to pass a digital signal on the DIO pins, in addition to the serial UART data that the XBee sends. The XBee is capable of directly sending these DIO signals from one module to another without any additional hardware. The XBee has 8 usable DIO lines that can be used to send digital data. The ninth DIO line is used for /DTR passing.

Enabling the DIO Lines (Remote):

The DIO feature can be enabled on the remote with the ATDn=3 where n= 0-7(the DIO pin you wish to use).

Enabling the DIO Lines (Base):

The DIO feature can be enabled on the base with ATDn=4,5 (4 is DO default low and 5 is DO default high) where n= 0-7(the DIO pin you wish to use). Remember that the inputs and outputs need to be mapped together, so if you enable DI2 on the remote you must enable DO2 on the base. Each DIO line is connected to a specific pin on the module and some pins may have other features on them.

DIO Line Sampling and Timers:

Once the proper DIO lines have been enabled then you should set the sampling rate and timeout timers of the DIO lines. The sampling rate needs to be set on the remote and the timer needs to be set on the base. On the remote the sampling rate can be set with the IR parameter (the sampling rate is in units of ms). The timer is set on the base by the Tn parameter where n=0-7 (the Tn parameter is in units of 100ms). If after the Tn timer has expired and the module hasn't received any new data then the DOn will return to its default state. This means that you should always set the sampling rate less than (in most cases much less than) the timeout timer.

Change Detect:

The XBee can also be setup for change detect where it will transmit a DIO shift whenever a change takes place. If Change Detect is not enabled (default) the module will not transmit when the DIO lines change, but only on their sample interval. To enable Change Detect set IC to the Bit Mask of the corresponding DIO lines, where DIO0 is the LSB and DIO7 is the MSB.

Samples Before Transmission:

The XBee allows the user to set the number of samples to be taken before the data is transmitted, this command is ATIT. The XBee can buffer up to 90 bytes worth of sample data, since all the DIO information is stored in 2 bytes the XBee can buffer up to 22 samples or ATIT=0x44.


As an example for a simple DIO link the radios could be set as follows:

Remote Base
DL = 0x1234 DL = 0x5678
MY = 0x5678 MY = 0x1234
D3 = 0x3 D3 = 0x4
D4 = 0x3 D4 = 0x4
IC = 0x18 T3 = 0x64
IT = 0x2 T4 = 0x64
IR = 0x32 IA = 0x5678 (or FFFF)

These settings will set the remote to sample DI3 & DI4 once each every 50ms. It will then buffer 2 samples each before sending them back to the base. That should lead to the base receiving a 16 byte transmission (4 bytes data and 12 bytes framing) every 100ms.

UART Output:

The XBee can transmit the DIO data through the XBee's UART, the XBee can also still send/receive standard UART serial data. There are two methods for reading the DO data as it comes into the XBee. By default , when the appropriate DI pin is toggled, the module will toggle the corresponding DO pin on the base module. The other method for reading the digital data is through the UART. To enable the module to output UART data simply set ATIU=1 on the base (this is the default setting). When the data is sent out the UART the data is automatically in API format, so the API doesn't need to be enabled. Below is an example of a DIO UART data stream taken from the example above.

7E 00 0C 83 56 78 2E 00 02 00 18 00 18 00 18 36

Where the UART API data stream can be broken down as:

7E Start Delimiter
00 0C Length Bytes
83 API Identifier Byte for 16bit DIO data (82 is for 64bit DIO data)
56 78 Source Address Bytes
2E RSSI Value Bytes
00 Option Byte
02 Sample Quantity Byte
00 18 00000000 00011000 Channel Indicator *
00 18 Sample Data DIO 3 & 4 (Where 1 represents high and 0 represents low)
36 Check sum

* bit field where the bits line up as (Ax=ADCx & Dx=DIOx):

MSB = 0x00 LSB = 0x18

0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0

NA A5 A4 A3 A2 A1 A0 D8 D7 D6 D5 D4 D3 D2 D1 D0



Was this article helpful?



Please tell us how we can make this article more useful.

Characters Remaining: 255