Since 4 weeks i have a Digi XStick. This is a USB module that provides connectivity to a XBee network:
This XStick ZB is configured to behave as a coordinator within a mesh topology. The XStick can be plugged directly into the USB port of a PC and doesn’t require batteries or power adapter since it’s USB powered. Last 2 weeks i’ve been working on a Zigbee interface for my domotica system, using ths XStick.
First some things you need to know..
An Xbee module has three communication modes:
- Transparent mode,
- Command mode
- API mode.
At startup, an Xbee module is in transparent mode. In this mode, the module acts as a serial line replacement. All data received from the DIN pin is transmitted, and when RF data is being received, it is sent out on the DOUT pin. A pair of XBee modules can act as invisible cables in this mode.
Command mode is where you can change a large amount of settings of the XBee module. To enter Command mode you must send the characters “+++” and wait a second. Once the XBee enters command mode, it will answer with OK. Most of us will remember this behavior from modems. While in command mode you can change baud rate, destination address, etc etc. Leaving command mode can be accomplished by executing the ATCN command.
Sending messages to constantly changing targets (=other XBee modules), API mode is the best mode to choose. It is the most powerfull but also the most complicated mode to use. API (Application Programming Interface) mode is a frame-based method for sending and receiving data to and from an XBee.
API mode has some special abilities:
- Changing parameters without entering command mode;
- RSSI and source address information;
- Receive packet delivery confirmation on every transmitted packet
Since API mode seems to be the most flexible, i decided to create an API-mode interface. With more then 140 pages of information of how to interface with XBee/XBee-PRO ZB RF modules i knew this was a job that could take a while, but today i managed to get a sequence of API mode commands working.
The first command i started with was the Node Discovery command, which will let every device on the network respond with basic information about that device. These reponses are received by the XStick, the address information of the responding XBee devices is stored and the next step is to send a request to all of the responding devices to request information about their hardware version. Today i succeeded in doing this first excercise, as you can see here:
Execute Node Discovery Sending frame:7E 00 04 08 01 4E 44 64 Serialport.RxCount:33 RxBuffer:7E 00 1D 88 01 4E 44 00 86 23 00 13 A2 00 40 31 B9 04 45 44 41 54 32 00 00 00 02 00 C1 05 10 1E 12 *** Processing frame *** ApiID = 88 Checksum Ok=True ATCommandResponse, 29 bytes: FrameID=1 Command=ND Status=0 MY 8623 SH,SL 5526146518202628 (0013A2004031B904) NI [EDAT2] PARENT 00 00 DEVICE_TYPE 02 STATUS 00 PROFILE_ID C1 05 MANUFACTURER_ID 10 1E Request Hardware Version for Node 8623 Sending frame:7E 00 0F 17 01 00 13 A2 00 40 31 B9 04 86 23 00 48 56 BD Serialport.RxCount:21 RxBuffer:7E 00 11 97 01 00 13 A2 00 40 31 B9 04 86 23 48 56 00 19 44 E0 *** Processing frame *** ApiID = 97 Checksum Ok=True RemoteATCommandResponse, 17 bytes: FrameID=1 Command=HV Status=0 Response=19 44
So the XBee module that responded has a Hardware Version of 1944 🙂