Home/Support/Support Forum/How do I write C code that talks to a XBee?
New and improved user forum site going live on 12/6 (All users will need to reset their password when the new forum is active)
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How do I write C code that talks to a XBee?

0 votes
This is the first time I've ever worked with XBee and the Zigbee protocol. So far I've played around a little with the XCTU software to connect XBee's to write to digital I/O pins and now I want to try writing C programs which I can execute from my computer to send a message from one XBee to the other using Zigbee protocol to write high to one of the Digital I/O pins. Any help or useful links would be very much appreciated as it seems that documentation for writing in C code is very limited.
asked Jun 19, 2017 in Linux by FlipFlop New to the Community (2 points)

Please log in or register to answer this question.

1 Answer

+1 vote
Best answer
The only C code that Digi provides is used for the programmable xbee product.

As far as Digi is concerned, you would write the UART functionality just like you would if the XBee was not being used. That is data in = data out. May I suggest you start with that.
answered Jun 19, 2017 by mvut Veteran of the Digi Community (15,515 points)
selected Jun 20, 2017 by FlipFlop
Oh that makes sense, thanks so much.  Are there any references you would recommend for packet formatting?
It can be anything you want.  Just keep the packet below 84 bytes.
I understand that but I just meant what should my start and end bits be.  Also would Zigbee packets be structured differently?
The start and stop bits can be anything you want as you are using transparent mode. So it really means just that.

As for Zigbee packets. That is dependent on if you are truly wanting to develop a Zigbee application that is going to be certified or if you just want to send data over a mesh.
After reading into it some more I realized I could make this question more specific.  "How do I send a packet with an AT command to a XBee in API mode using serial communication from my laptop's USB port?"
Is the radio that is connected to the PC in API mode or transparent mode? If it is in transparent mode, than it is just that. send what ever you want by opening the COM port at the correct baud rate and send data.  If the module connected to the PC is in API mode, you still open the COM port the say way. You just need to send Hex API frame data packets. In this case a Local AT command API frame.