aioscilloscope / Learn / An XBee's power-up commands

See what a device sets its XBee to at power-up

Many products set up their radio module every time they start: the network, the channels, the addresses, the baud rate. Those commands travel over two pins you can probe. Our example is a Digi XBee-PRO S3B; the method works for any module with a serial port.

CH1The pins

Through-hole XBees share a 20-pin footprint (Digi's user guides 90002173, 90000982, 90001500):

PinNameWhat it is
1VCCPower: 2.1 to 3.6 V on the XBee-PRO S3B
2DOUTWhat the radio sends to the device (its replies)
3DIN / CONFIGWhat the device sends to the radio (its commands)
10GNDGround

Surface-mount XBees and other makers' modules use other pins: the module's data sheet names its TX and RX.

CH2AT command mode and API mode

AT command mode is readable text: a second of silence, +++, another second, and the radio answers OK. Then each command is AT, two letters and an optional hexadecimal value: ATID7FFF. ATCN leaves command mode.

API mode (AP = 1 or 2) uses binary frames starting with 0x7E: two length bytes, the frame data, a checksum. Setting the preamble ID to 2 looks like 7E 00 05 08 01 48 50 02 5C: type 0x08 (AT command), frame ID 01, the letters H and P, the value 02, and the checksum 0xFF minus the low byte of the sum. Decode API traffic in Hex.

CH3The commands you will see

For the XBee-PRO 900HP (S3B), from Digi's user guide 90002173; values are hexadecimal.

CommandWhat it setsDefault
ATIDNetwork ID: radios talk only to the same ID0x7FFF
ATHPPreamble ID, 0 to 70
ATCMChannel mask: one bit per frequency it may hop onevery channel but 19
ATDH, ATDLDestination address, high and low 32 bits0 and 0xFFFF (broadcast)
ATSH, ATSLAsk the radio's own 64-bit addressread only
ATBDSerial baud rate: 3 is 9600, 6 is 57,600, 7 is 115,200; it switches when command mode ends3 (9600)
ATAP0 transparent (AT), 1 API, 2 API with escaped characters0
ATPLTransmit power, 0 to 44
ATWRSave the settings, so they survive a power cycle
ATCNLeave command mode and apply the changes
ATVRAsk the firmware versionread only

CH4Capture the whole start-up

  1. Connect two channels. CH1 to the radio's DIN (pin 3 on a through-hole XBee: the commands), CH2 to DOUT (pin 2: the replies), both grounds to GND (pin 10). Both at 1 V/div, DC, probe 10×.
  2. Make the record long and deep. The deepest memory offered, 500 ms/div (5 s across the screen), the trigger point near the left edge.
  3. Check the samples a bit. Sample rate = memory depth / time across the screen: 10 Mpts over 5 s is 2 MSa/s, 17 samples a bit at 115,200 baud. Aim for 10 or more.
  4. Arm on the first command. Edge trigger, CH1, Falling, 1.6 V, Single. Press Single, then switch the device on.
  5. Decode the whole record. Serial decoder with CH1 as one line and CH2 as the other, thresholds 1.6 V, the measured or Auto rate, ASCII (Hex for API mode).
  6. Read it and save it. The decoder's event table lists every command and reply in time order. Save it as a CSV file to keep it.

What it can look like

An illustration of a typical start-up, not a capture of any particular product:

DIN (device to radio)DOUT (radio to device)Meaning
+++OKCommand mode
ATID1A2BOKNetwork ID 0x1A2B
ATDH0, ATDLFFFFOK, OKBroadcast to the network
ATBD6OK57,600 baud, from when command mode ends
ATWR, ATCNOK, OKSaved; back to transparent mode at the new rate

A start-up that changes rate partway needs each part decoded at its own rate (why).

Export the decoded traffic

Save the decoder's event table as a CSV file, which a spreadsheet opens.

Storage > Save: the Decode table row saves each decoder's event table as a .csv file. Here B1 decodes a Rigol DG902 Pro's serial line.

Questions

Which XBee pin is TX?

On a through-hole XBee, DOUT (pin 2) is the radio's transmit line to the device and DIN (pin 3) its receive line. GND is pin 10.

Why don't I see +++ at power-up?

Either the radio was configured once and saved with ATWR, so the device sends nothing, or it uses API mode: binary frames starting with 0x7E. Switch the decoder to Hex.

What baud rate does an XBee use?

Whatever its BD setting says: 9600 from the factory (BD = 3). Measure it if unsure: how.

More to try

Every guide