User Manual
XBee® Wi-Fi RF Modules
© 2012 Digi International, Inc. 47
I/O Sampling
The XBee modules have the ability to monitor and sample the analog and digital I/O
lines. I/O samples can be read locally or transmitted to a remote device to provide
indication of the current I/O line states.
There are three ways to obtain I/O samples, either locally or remotely:
• Queried Sampling
• Periodic Sampling
• Change Detection Sampling.
IO sample data is formatted as shown in the table below
Bytes Name Description
1 Sample Sets
Number of sample sets in the packet. (Always set to 1.)
2 Digital Channel mask
Digital IO line on the module.
• bit 0 = DIO0
• bit 1 = DIO1
• bit 2 = DIO2
• bit 3 = DIO3
• bit 4 = DIO4
• bit 5 = DIO5
• bit 6 = DIO6
• bit 7 = DIO7
• bit 8 = DIO8
• bit 9 = DIO9
• bit 10 = DIO10
• bit 11 = DIO11
• bit 12 = DIO12
For example, a digital channel mask of 0x002F means DIO0 1, 2, 3, and
5 are enabled as digital IO.
1 Analog Channel Mask
Indicates which lines have analog inputs enabled for sampling. Each bit
in the analog channel mask corresponds to one analog input channel.
• bit 0 = AD0
• bit 1 = AD1
• bit 2 = AD2
• bit 3 = AD3
• bit 4 = AD4
Variable Sampled Data Set
If any digital IO lines are enabled, the first two bytes of the data set
indicate the state of all enabled digital IO. Only digital channels that
are enabled in the Digital Channel Mask bytes have any meaning in the
sample set. If no digital IO is enabled on the device, these 2 bytes will
be omitted.
Following the digital IO data (if any), each enabled analog channel will
return 2 bytes. The data starts with AD0 and continues sequentially for
each enabled analog input channel up to AD4.
The sampled data set will include 2 bytes of digital I/O data only if one or more I/O lines
on the device are configured as digital I/O. If no pins are configured as digital I/O, these
2 bytes will be omitted.
The digital I/O data is only relevant if the same bit is enabled in the digital I/O mask.
Analog samples are 10 bit values and aligned on a 16 bit boundary. The analog reading is
scaled such that 0x0000 represents 0V, and 0x3FF = VREF. VREF may be either 1.25
volts or 2.5 volts based on the setting of the AV command, where 2.5 volts is the