Xbee API Mode - Coordinator -> Router -> End Device

Hi All,

Right now I have a setup in API mode where I am able to send my sensor data from my end device (Arduino attached to an XBee Shield) directly to my router (Also an Arduino/Shield combo). With this code:

XBee xbee = XBee();
uint8_t data[2] = {0,0};
XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x4198E12F);//Router MAC Address
ZBTxRequest zbTx = ZBTxRequest(addr64, data, sizeof(data));


Then, I have code running in the Router to send that same message directly to my coordinator MAC address. This really is the same code as above, but with the Coordinator MAC Address.

Am I doing this correctly? I am manually coding the E -> R -> C network, which works but I am not sure if it is correct. I believe in API mode I have to do this, but I am not 100% sure. Isn’t the Zigbee network supposed to handle the forwarding? Or is that only in non-API mode?

So, now, I want to send messages from the Coordinator back out to the end device. My first thought was to now have the Coordinator send the message to the Router and then to the End Device. Great, but this only works if I have one end device. How does the Router know which one to send to? The only way, which seems overly complex, is to embed that information (maybe the MAC of the end device or some key) in the data of the message. I must be doing something wrong.

After a few tests, I have suddenly found that the Coordinator itself can send a message directly to the End Device, using this code (Python on Raspberry PI):

from digi.xbee.devices import RemoteXBeeDevice
from digi.xbee.devices import XBee64BitAddress
coordinator = XBeeDevice(SERIAL_PORT, BAUD_RATE)
end_device = RemoteXBeeDevice(coordinator,XBee64BitAddress.from_hex_string(“0013A2004198E12F”))


This in a way defies my earlier implementation, as it seems to bypass the Router.

What is actually happening here in the above implementation? Is the Router XBee getting the message and not telling me? I see no System.out showing a message was received by it, so this must not be the case. Instead the Coordinator seems to be bypassing the Router.

In XcTU tool, my network for my Coordinator shows that the Router is in-between it and the end devices, so I think it should have to go through the Router. Does it have another connection to the end devices I don’t know about, directly?

I am sure that my issue is a lack of understanding of how this all works. Can any one shed any light on my problems? How do I get data back to my end devices in a proper way?


I think you are over doing it. The mesh is designed as such as that if I want to send data from Node G to Node A, all I need to do is to provide the MAC address of Node A in the DL and DH fields of Node G and then send the data. The mesh will figure out how to get it from one point to the other on its own.

Yes thank you you have confirmed my suspicions that I am indeed overdoing things.

So when I send a message from end device to the coordinator, I would send the data to the MAC address of the coordinator from all my end devices? In other words, if the mesh needs the router device(s), it will use them to route to the coordinator automatically?

That is correct.

Hi dear friend! I have a project to do a comunication between one coordinator and a router and two end-device. My question about this is how can I do to send DATA from my end-device to coordinator? I’m using arduino uno to each xbee module. thanks

With this code on end device in Arduino sketch:

XBee xbee = XBee();
uint8_t data[2] = {0,0};
XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x4198E12F);//Coordinator MAC Address
ZBTxRequest zbTx = ZBTxRequest(addr64, data, sizeof(data));


You do it the same way as above. Just in your code and you use API mode on all of the nodes. The reason for that is because most Arduino libraries access the XBee in API mode.

Ok! But I need send to my coordinator one data code, for exemple, “alarm” and I need that the coordinator see the end device address… what do you used the uint8_tdata“[2]” ? Two bit?

Yes you can do that like this:

// Create an array for holding the data you want to send.
uint8_t data[]= {‘a’, ‘l’, ‘a’, ‘r’, ‘m’};

Hi dear! To send the data with:

uint8_[] = { ‘a’, … } ;

How can I do to send the frame API to my coordinator without MAC address? Tks