# XBee: Send data to specific Node in a Mesh

**URL:** <https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381>\
**Category:** XBee & XBee Gateway\
**Tags:** arduino-xbee, xbee\
**Created:** [May 19, 2020, 11:14am UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381 "2020-05-19T11:14:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonioGR96](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@AntonioGR96](https://forums.digi.com/u/AntonioGR96)\
**Post date:** [May 19, 2020, 11:14am UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381/1 "2020-05-19T11:14:59Z")

</div>

Hi mates.

I’m working on a mesh network made up of 1 Coordinator and several Routers (every XBee S2, API mode), that can join the network at any time. That’s why I’m using the NodeDiscovery function. The coordinator discovers every Router joined, and inside the ND function, every Router sends back a packet that has its Address. So I’m able to store those addresses in a matrix: for example, int devices[50][17] 50 maximum devices.

I know the way to send data from Coordinator to one specific Router:

-XBeeAddress64 addr (0x0013a20040a1f246)  
-ZBTxRequest zbTx = ZBTxRequest(addr, payload, sizeof(payload));  
-xbee.send(zbTx);

But instead of doing this last step, is there a way in which I could use the stored address of some XBee Router in the previous matrix?

//\*\*\*//  
int devices[100][17];  
…

//Once inside the NodeDiscovery function

while(xbee.readPacket(timeout)) { // should be receiving AT command responses  
if (xbee.getResponse().getApiId() == AT\_COMMAND\_RESPONSE) {  
xbee.getResponse().getAtCommandResponse(response);  
if (response.isOk()) {  
for (int i = 2; i \< 10; i++) {  
devices[nodeCount][i]=response.getValue()[i]; //Stores the addres of the Nodes found  
Serial.print(devices[nodeCount][i],HEX);  
}  
nodeCount++;  
Serial.println(“”);

}  
}  
}

//\*\*//

The code may not be correct at all. I’m a beginner. My apologies.

To sum up, I’m trying to find a way to store the address of every Router found in order to use it later to send data. For example ‘Hi1’ to Router1, ‘Hi2’ to Router 2, etc.

If anyone has some advice I would appreciate it.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [May 19, 2020, 2:20pm UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381/2 "2020-05-19T14:20:59Z")

</div>

Antonio,

No, not really. Not unless you want to off load the routing to your code.

---

<div class="post-metadata">

**Author:** ![AntonioGR96](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@AntonioGR96](https://forums.digi.com/u/AntonioGR96)\
**Post date:** [May 19, 2020, 4:05pm UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381/3 "2020-05-19T16:05:01Z")

</div>

First of all, thank you very much for responding, I appreciate it. I’m a student and I’m kind of stuck right now.

Well how should I proceed to do something like this? If I have a network with routers that can join at any time, would it be impossible to save their addresses in some way and use them later?

It is a university project in which I do not know the routers that I will have in the network.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [May 20, 2020, 10:00am UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381/4 "2020-05-20T10:00:56Z")

</div>

I would suggest using API mode along with the Join Notification (JN) function. This way when a node joins, an API frame comes out with its 64 bit MAC address.

---

<div class="post-metadata">

**Author:** ![AntonioGR96](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@AntonioGR96](https://forums.digi.com/u/AntonioGR96)\
**Post date:** [May 20, 2020, 1:57pm UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381/5 "2020-05-20T13:57:49Z")

</div>

I’m not sure, but I think I got the JN enabled. Using the Node Discovery, every Router sends an API frame including is 64 bit MAC. I can print these addresses (the part of the code I wrote does), but not store them.  
And what about the SL and SH. Would there be some way to save them in two array variables of 10 devices, for example, like the following?

uint32\_t Msb();

uint32\_t Lsb();

XBeeAddress64 remoteAddress = XBeeAddress64(uint32\_t Msb,uint32\_t Lsb);

Sorry if I bother you.  
Perhaps the best way is to create XBeeAddress64 variables, as many as routers the network has , and add by hand the rest when they join.

I am Spanish, maybe my English is not good sometimes. sorry.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [May 20, 2020, 2:00pm UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381/6 "2020-05-20T14:00:29Z")

</div>

I am not sure I can answer that one as that is dependent on your processor and what language it uses. But in most cases, you should be able to.

---

<div class="post-metadata">

**Author:** ![AntonioGR96](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@AntonioGR96](https://forums.digi.com/u/AntonioGR96)\
**Post date:** [May 21, 2020, 10:11am UTC](https://forums.digi.com/t/xbee-send-data-to-specific-node-in-a-mesh/21381/7 "2020-05-21T10:11:12Z")

</div>

Thanks for your time, mvut. I appreciate it. I’ll try to find out more about it.
