XBeePins.md

November 18, 2015 ยท View on GitHub

Configuring an XBee for I/O samples can be a frustrating experience. First you have to look in the Digi command reference table to find out what pins support Digital or Analog, then determine the location of the physical pin, and finally determine the API method to call to get the value. This guide attempts to simply the process.

The following image shows the physical layout of pins 1 through 20 of an XBee. Although this is a series 2 XBee, the pin layout is identical to series 1 (805.15.4), both Pro and standard.

http://xbee-api.googlecode.com/svn/trunk/docs/diagrams/xbee-series2-pin-layout.png

If you are using the XBee Explorer, remember it has two extra pins, GND and 5V, as shown

http://xbee-api.googlecode.com/svn/trunk/docs/diagrams/xbee-explorer.png

802.15.4 (Series 1) Pin Assignments

Pin #AT CommandDescriptionDefault ConfigurationSupported Configurations (Value)Analog I/O MethodDigital I/O Method
1n/aPower Supplyn/an/an/a
2n/aUART Data Outn/an/an/a
3n/aUART Data Inn/an/an/a
4n/aDigital Output 8 (not supported as of 2/28/09)n/an/an/a
5n/aModule Reset (reset pulse must be at least 200 ns)n/an/an/a
6P0PWM Output 0 / RX Signal Strength IndicatorRSSI_PWMDISABLED (0x0), RSSI_PWM (0x1), PWM_OUTPUT (0x2)n/an/a
7P1PWM Output 1DISABLEDDISABLED (0x0), RSSI_PWM (0x1), PWM_OUTPUT (0x2)n/an/a
8n/aDo not connectn/an/an/a
9D8DTR / Pin Sleep Control Line or Digital Input 8DISABLEDDISABLED (0x0), DIGITAL_INPUT (0x3)n/aisD8On()
10n/aGroundn/an/an/a
11D4Analog Input 4 or Digital I/O 4DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog4()isD4On()
12D7Clear-to-Send Flow Control or Digital I/O 7CTS_FLOW_CTRLDISABLED (0x0), CTS_FLOW_CTRL (0x1), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD7On()
13n/aModule Status Indicatorn/an/an/a
14n/aVoltage Reference for A/D Inputsn/an/an/a
15D5Associated Indicator, Analog Input 5 or Digital I/O 5ASSOC_LEDDISABLED (0x0), ASSOC_LED (0x1), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog5()isD5On()
16D6Request-to-Send Flow Control, Analog Input 6 or Digital I/O 6DISABLEDDISABLED (0x0), RTS_FLOW_CTRL (0x1), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD6On()
17D3Analog Input 3 or Digital I/O 3DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog3()isD3On()
18D2Analog Input 2 or Digital I/O 2DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog2()isD2On()
19D1Analog Input 1 or Digital I/O 1DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog1()isD1On()
20D0Analog Input 0 or Digital I/O 0DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog0()isD0On()

Example: You want to read an analog sensor on a remote XBee end device. Look in the table for an available pin that supports ANALOG_INPUT; let's use 11. In the table we can see that the AT Command for pin 11 is D4 and the ANALOG_INPUT parameter value is 0x2. Now plug your end device into your computer and open X-CTU. Select enable API mode and use escape characters. On the Modem Configuration tab and click "Read". Find D4 in and set to "2 - ADC". Now enable I/O samples by setting IR to "1388" (every five seconds) and click "Write" to save the configuration. Now connect the XBee coordinator to your PC and start receiving the samples with the getAnalog4() method in the IoSample.java class.

ZNet/ZB Pro (Series 2) Pin Assignments

Pin #AT CommandDescriptionDefault ConfigurationSupported Configurations (Value)Analog I/O MethodDigital I/O Method
1n/aPower Supplyn/an/an/a
2n/aUART Data Outn/an/an/a
3n/aUART Data Inn/an/an/a
4P2Digital I/O 12UNMONITORED_INPUTUNMONITORED_INPUT (0x0), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD2On()
5n/aModule Reset (reset pulse must be at least 200 ns)n/an/an/a
6P0PWM Output 0 / RX Signal Strength Indicator / Digital IORSSI_PWMDISABLED (0x0), RSSI_PWM (0x1), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD10On()
7P1Digital I/O 11UNMONITORED_INPUTUNMONITORED_INPUT (0x0), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD1On()
8n/aDo not connectn/an/an/a
9n/aDTR / Pin Sleep Control Linen/an/an/a
10n/aGroundn/an/an/a
11D4Digital I/O 4DISABLEDDISABLED (0x0), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD4On()
12D7Clear-to-Send Flow Control or Digital I/O 7CTS_FLOW_CTRLDISABLED (0x0), CTS_FLOW_CTRL (0x1), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5), RS485_TX_LOW (0x6), RS485_TX_HIGH (0x7)n/aisD7On()
13n/aModule Status Indicatorn/an/an/a
14n/aNot used on this module. For compatibility with other XBee modules, we recommend connecting this pin to a voltage reference if Analog sampling is desired. Otherwise, connect to GNDn/an/an/a
15D5Associated Indicator, Digital I/O 5ASSOC_LEDDISABLED (0x0), ASSOC_LED (0x1), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD5On()
16D6Request-to-Send Flow Control, Digital I/O 6DISABLEDDISABLED (0x0), RTS_FLOW_CTRL (0x1), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)n/aisD6On()
17D3Analog Input 3 or Digital I/O 3DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog3()isD3On()
18D2Analog Input 2 or Digital I/O 2DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog2()isD2On()
19D1Analog Input 1 or Digital I/O 1DISABLEDDISABLED (0x0), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog1()isD1On()
20D0Analog Input 0, Digital IO 0, or Commissioning ButtonNODE_ID_ENABLEDDISABLED (0x0), NODE_ID_ENABLED (0x1), ANALOG_INPUT (0x2), DIGITAL_INPUT (0x3), DIGITAL_OUTPUT_LOW (0x4), DIGITAL_OUTPUT_HIGH (0x5)getAnalog0()isD0On()

Example: You want to read an digital sensor on a remote XBee end device. Look in the table for an available pin that supports DIGITAL_INPUT; let's use pin 20. In the table we can see that the AT Command for pin 20 is D0 and the DIGITAL_INPUT parameter value is 0x3. Now plug your end device into your computer and open X-CTU. Select enable API mode and use escape characters. On the Modem Configuration tab and click "Read". Find D0 in and set to "3 - DIGITAL INPUT". Now enable I/O samples by setting IR to "1388" (every five seconds) and click "Write" to save the configuration. Now connect the XBee coordinator to your PC and start receiving the samples with the isD0On() method in the ZNetRxIoSampleResponse.java class.

Note: Both these tables were generated by the printAll method in XBeePin.java You may find this class useful for programmatically determining the capabilities of XBee pins.