Zigbee API interface

Forum and Topics about ZigBee devices.

Moderators: Digit, Willem4ever

Post Reply
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Zigbee API interface

Post by Digit »

Since 4 weeks i have a Digi XStick. This is a USB module that provides connectivity to a XBee network:
xstick_resize.png
xstick_resize.png (45.73 KiB) Viewed 14481 times
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 factory default 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 powerful 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 responses 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 exercise, 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 :-)

And since all information is available, you can read all about it here:
http://ftp1.digi.com/support/documentat ... 0976_D.pdf
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Re: Zigbee API interface

Post by Bwired »

Great job! :P
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Zigbee API interface

Post by Digit »

Thanks, but this is just the beginning, job is not finished yet, moving on to the next level at this moment 8)
User avatar
Codeblack
Starting Member
Starting Member
Posts: 46
Joined: Fri Dec 11, 2009 4:02 pm
Location: Netherlands
Contact:

Re: Zigbee API interface

Post by Codeblack »

Digit, where did you get your XStick from? I'm not able to find a webshop that offers them...
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Zigbee API interface

Post by Digit »

I've got mine from Willem (willem4ever), don't know exactly where he he bought them...
But you'va got enough links now :)
User avatar
Codeblack
Starting Member
Starting Member
Posts: 46
Joined: Fri Dec 11, 2009 4:02 pm
Location: Netherlands
Contact:

Re: Zigbee API interface

Post by Codeblack »

Thanks guys :). And I almost ordered... But there are so many types of modules, that I decided to read & check before I buy. And that NEVER happened to me before :P. So this feels awkward, but please hear me out ;).

Adafruit only sells one type of module, sparkfun sells a whole bunch and with digikey, mouser or farnell you can pick from over 40 types :(. 1mW, 2mW, series 1, series 2. Then I looked back to the XStick links from Esteban (thanks again) and found that one mentiones 802.15.4, another series 2 ZB and yet another just ZB.

Luckily I found a helpfull page by ladyada through the adafruit shop, listing the types of modules and their differences. I understand all XBee's talk 802.15.4, and not all can do mesh networking or talk ZigBee. I assume it's all about the firmware that's installed.
One confusing thing is that the links to digikey/mouser behind the XBee ZB Series 2 appear to link to ZNet modules which, according to the list, are legacy. And since I can't find the ZNet modules on digi.com, I guess they are legacy. The Series 2.5 modules from Sparkfun are ZNet modules, by the way (according to the product information and datasheet/manual they link to).
Another confusing thing is that most sites (e.g. farnell) even refer to the 802.15.4 modules as ZigBee modules or mention ZigBee as one of the protocols it's capable of (in the example, farnell mentions ZigBee development as possible application and shows the ZigBee logo as part of the product image; it is an XBee 802.15.4 however, convertable to mesh, but not ZigBee). Maybe it is possible to do ZigBee with any XBee, either by updating the firmware (but why not ordering the XBee with the ZigBee firmware?) or by writing your own ZigBee layer outside the XBee (even if possible, this really sounds pointless).

So, instead of ordering, I've got some more reading to do. I (think ;) I) need a mesh network. And for that it seems there are two options: DigiMesh or ZigBee. And ZigBee sounds like the better plan; it may be a little more complex to implement, but I don't want to come up with my own (yet another, incompatable) protocol based on 802.15.4. XBee 802.15.4 & DigiMesh modules can apparently be converted to one another, but these and the ZigBee modules are not interchangeable. They can't even communicate. And the XStick also comes in these two flavors: 802.15.4 and ZigBee.

Sorry about the long post (again :P). I hope I've got it right, but please tell me if I messed up.
WooTz
Starting Member
Starting Member
Posts: 31
Joined: Tue Jun 28, 2011 12:19 am

Re: Zigbee API interface

Post by WooTz »

Hi Code,

Which one did you end up buying? I just had a quick look and am facing the same problems.

Digit,
What was your basis for the development? I just had a look at the 600 pages spec from ZigBee...., or does the Stick have its own API? I assume it acts as a serial interface?
User avatar
Codeblack
Starting Member
Starting Member
Posts: 46
Joined: Fri Dec 11, 2009 4:02 pm
Location: Netherlands
Contact:

Re: Zigbee API interface

Post by Codeblack »

Hi WooTz,

It has been a while... but I never ordered the XBee or ZigBee. I found it all to unclear and the ZigBee protocol not open enough. Actually, I have only just restarted my domotica project, after being dormant for over a year.

But now I'm starting back up, I've decided to go for 6LoWPAN. To have all devices talking IP, using open source protocols, is just so appealing. I'm still figuring out what protocol(s) to use on top of 6LoWPAN though, but it should all be as open standard as possible.
Post Reply

Return to “ZigBee Forum”