# NR+XBee Conection

**URL:** <https://discourse.nodered.org/t/nr-xbee-conection/48450>\
**Category:** Hardware\
**Created:** [15 July 2021 10:25 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450 "2021-07-15T10:25:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [15 July 2021 10:25 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/1 "2021-07-15T10:25:09Z")

</div>

Hi, I came across this topic ([Node-Red and Xbee S2C](https://discourse.nodered.org/t/node-red-and-xbee-s2c/42023)), I noticed that they use this ([GitHub - angryelectron/xbmq-java: XBee / Mqtt Gateway](https://github.com/angryelectron/xbmq-java)  
[GitHub - angryelectron/xbmq-js: NodeJS XBee to MQTT Gateway](https://github.com/angryelectron/xbmq-js)) and this ([XBee · PyPI](https://pypi.org/project/XBee/)). So, is this the best ''formula'' for establishing Xbee connection in NR?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 July 2021 11:11 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/2 "2021-07-15T11:11:51Z")

</div>

It should be obvious to you by now that nobody here has any experience of XBee with node red or they would have helped you already.

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [15 July 2021 11:17 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/3 "2021-07-15T11:17:07Z")

</div>

This is a really ''sweet'' rejection

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 July 2021 11:19 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/4 "2021-07-15T11:19:54Z")

</div>

That is not a rejection, just pointing out that it appears that nobody here knows.

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [15 July 2021 11:35 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/5 "2021-07-15T11:35:37Z")

</div>

In this topic there is a comments.

> [@Node-Red and Xbee S2C](https://discourse.nodered.org/t/node-red-and-xbee-s2c/42023/7):
>
> As the help in that document says... Alternatively, use a change node to build this object. set msg.payload to JSON then copy/paste that code in This is about as basic as node-red gets. If you dont understand that then you need to spend a little time playing and learning. I strongly recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A s…

I just want to know the algorithm:

1. First, I need to install the RPI XBee connection library?
2. Then install XBee MQTT Gateway project?
3. Finally, to obtain data in NR through Xbee nodes and / or zigbee2mqtt nodes?

Am I on the right way or not?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 July 2021 12:03 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/6 "2021-07-15T12:03:27Z")

</div>

Hi @Martin10

I'm sorry that you aren't getting the answer you are looking for here. But Colin makes a reasonable point that if no-one reading this knows the answer, then we can't give you an answer.

I have _never_ used XBee. So I cannot give you a definitive answer. The thread you link to ends with the user says 'dont bother with the MQTT stuff'. That suggests they had success with [node-red-contrib-xbee (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-xbee) - but I could be reading that wrong.

Have _you_ tried [node-red-contrib-xbee (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-xbee)?

A very quick google search finds this (quite old) instructable page - [https://www.instructables.com/Raspberry-Pi3-XBee-MQTT-Node-Red-IoT/](https://www.instructables.com/Raspberry-Pi3-XBee-MQTT-Node-Red-IoT/)

Maybe there's something there you could learn from?

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [15 July 2021 12:47 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/7 "2021-07-15T12:47:43Z")

</div>

Yes, I read that. Nothing useful in it.  
I wrote to Rescue (the author of other xbee topic), but no answer. Did anyone know him?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 July 2021 12:49 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/8 "2021-07-15T12:49:27Z")

</div>

> [@Martin10](#):
>
> Yes, I read that. Nothing useful in it.

Nothing? Do you mean it didn't work for you? Or what? Clearly its a set of instructions that do work - its just a matter of apply it to your setup.

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [15 July 2021 12:51 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/9 "2021-07-15T12:51:26Z")

</div>

It didn't work for me, because there is nothing about xbee configuration.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 July 2021 12:53 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/10 "2021-07-15T12:53:47Z")

</div>

When I read through it, there was this section all about his configuration:

Have you searched for the sparkfun exploring xbee tutorial he recommends?

> There are great tutorials at how to get started with XBee´s like the one in Sparkfun Exploring XBee,
> 
> I took some screenshots and commented them here on this step so you can have an overview of my configuration, note the following:
> 
> • All your XBee devices have to be the same value for ID : PAN\_ID parameter  
> • I did set encryption on my devices, by enabling parameter EE, and used a private KY:Encription\_Key  
> • I use the same Digital Out pins on my XBee's for simplicity's sake  
> • I use the same Digital IN pins on my XBee's for simplicity's sake
> 
> Very Important, write down the MAC address of your devices (you can retrieve those MAC addresses using XCTU), you will need them to access MQTT topics.

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [15 July 2021 12:59 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/11 "2021-07-15T12:59:41Z")

</div>

I meant the xbee configuration in NR. That's why i wrote hire, i wish to config. XBee in a way i can use it in NR?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 July 2021 13:17 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/12 "2021-07-15T13:17:02Z")

</div>

The tutorial explains how to setup XBMQ-Java outside of Node-RED that connects to the Xbee devices and relays their information to an MQTT broker.

Within Node-RED you use the MQTT nodes to connect to the same broker and subscribe to get the data.

That is exactly what you asked how to do.

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [16 July 2021 08:18 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/13 "2021-07-16T08:18:02Z")

</div>

There is very little information in this tutorial about the configuration of xbee, and more specifically the configuration of the frame. The configuration of the framework is important because it determines what type of information / data we will use. Also, this tutorial uses third-party software that will complicate the process unnecessarily.

I wish to begin with something simple like this, but just can't run it properly..

[https://flows.nodered.org/flow/a10d1cce0344d0cd839e37a35c1291f1](https://flows.nodered.org/flow/a10d1cce0344d0cd839e37a35c1291f1)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 July 2021 08:31 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/14 "2021-07-16T08:31:15Z")

</div>

> [@Martin10](#):
>
> I wish to begin with something simple like this, but just can't run it properly..

So you are now back to trying out the `node-red-contrib-xbee` node?

> but just can't run it properly

Did you follow the info on that flow?

> Remember to configure your Port number before deploying. This can be found in Windows by going to 'Device Manager' and seeing which ports are connected.

Also, on the [readme](https://flows.nodered.org/node/node-red-contrib-xbee) for `node-red-contrib-xbee` node it states is uses "[xbee-api](https://github.com/jankolkmeier/xbee-api) The xbee-api Node.js module" If you look at the [xbee-api](https://github.com/jankolkmeier/xbee-api) page there is a lot of info - perhaps that will help you form the correct payload?

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [16 July 2021 09:34 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/15 "2021-07-16T09:34:32Z")

</div>

I have to go back to basics.  
In general, there is an alternative ([ncd-red-wireless (node) - Node-RED](https://flows.nodered.org/node/ncd-red-wireless)) that is easier to use, but can only work with NCD products. I try this examples with my XBee, but I can't run it.

I copy this flow ([xBee transmit and recieve (flow) - Node-RED](https://flows.nodered.org/flow/a10d1cce0344d0cd839e37a35c1291f1)), replacing the frame settings with my Xbee settings, but I still can't run it.  
[Xbee transmit / recieve example · Issue #8 · ramonmata/node-red-contrib-xbee · GitHub](https://github.com/ramonmata/node-red-contrib-xbee/issues/8)  
This flow does not use xbee-api.

I have not see specific xbee-api flow (if you know one, please tell me), i've try to use it (as node) with combination with the above example, but don't get any difference. As far i understand, xbee-api convert msg.payload in to frame, but in the above example there is a function node that, i think do the same work, or not?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 July 2021 10:03 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/16 "2021-07-16T10:03:09Z")

</div>

> [@Martin10](#):
>
> [Xbee transmit / recieve example · Issue #8 · ramonmata/node-red-contrib-xbee · GitHub](https://github.com/ramonmata/node-red-contrib-xbee/issues/8)  
> This flow does not use xbee-api

Yes it does...

> <https://github.com/ramonmata/node-red-contrib-xbee/blob/544a759c18aa2196a1fc664b81404c334e079da0/package.json#L26>

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [16 July 2021 10:49 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/17 "2021-07-16T10:49:38Z")

</div>

I meant it don't use xbee-api as a node in the flow

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 July 2021 10:51 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/18 "2021-07-16T10:51:41Z")

</div>

I'm lost.

Can you answer this...

> [@Steve-Mcl](#):
>
> So you are now back to trying out the `node-red-contrib-xbee` node?

---

<div class="post-metadata">

**Author:** ![Martin10](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Martin10](https://discourse.nodered.org/u/Martin10)\
**Post date:** [16 July 2021 11:04 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/19 "2021-07-16T11:04:01Z")

</div>

Yes, i'm

> <https://github.com/ramonmata/node-red-contrib-xbee/issues/8>
>
> Hi, i try this example, but i can't see the message ''Hello'', that supposed to …come up and i've got this in the debug node.
> Where can be my mistake?
> 
> 
> !\[107935345-f1a11300-6f89-11eb-8a1d-62609c6c066b\](https://user-images.githubusercontent.com/50946705/125917791-7675186b-6def-4ccd-a2ed-1e9f89caeb5c.jpeg)
> 
> !\[107935357-f6fe5d80-6f89-11eb-84ae-0d11e0da767b\](https://user-images.githubusercontent.com/50946705/125917812-3f42ddea-f997-4ae5-8e22-c813ea23463b.jpeg)
> 
> 
> !\[107935378-fcf43e80-6f89-11eb-9abd-5a141081610f\](https://user-images.githubusercontent.com/50946705/125917820-16b69c79-cbc2-49ff-86bf-5087007ca0e0.jpeg)
> 
> 
> !\[114191291-ec8e8d80-9954-11eb-9de8-19101f112aef\](https://user-images.githubusercontent.com/50946705/125917839-d7291723-f221-480f-8d60-f52651529bf9.jpg)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 July 2021 11:16 UTC](https://discourse.nodered.org/t/nr-xbee-conection/48450/20 "2021-07-16T11:16:18Z")

</div>

> [@Steve-Mcl](#):
>
> So you are now back to trying out the `node-red-contrib-xbee` node?

> [@Martin10](#):
>
> Yes

ok, so 'node-red-contrib-xbee' uses [xbee-api](https://github.com/jankolkmeier/xbee-api) under the hood.

That means you could get clues from the xbee-api documentation.

  

for example, the demo flow you linked to...

> [@Martin10](#):
>
> I wish to begin with something simple like this, but just can't run it properly..
> 
> [https://flows.nodered.org/flow/a10d1cce0344d0cd839e37a35c1291f1](https://flows.nodered.org/flow/a10d1cce0344d0cd839e37a35c1291f1)

... has this code in the function...

```auto
var myDataFrame1 = { 
        type: 0x10, 
        id: 0x01, 
        destination64: "0013a200400a0127",
        destination16: "fffe",
        broadcastRadius: 0x00,
        options: 0x00,
        data: flow.get("words")||"hello"
    };
msg.payload=myDataFrame1;

return msg;

```

... If you look at the docs for [xbee-api](https://github.com/jankolkmeier/xbee-api) you will see almost exactly the same example ...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e23a29226b1c9a6e682f2afab29d570602b34c12.png)

* * *

My point was, read the xbee-api documents as it is the code used by the `node-red-contrib-xbee` node

[Next page](https://discourse.nodered.org/t/nr-xbee-conection/48450.md?page=2)
