# Configuring Serial Node for Bluetooth Communication

**URL:** https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943
**Category:** Developing Nodes
**Created:** [28 January 2021 17:05 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943 "2021-01-28T17:05:09Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)
#### Post date: [28 January 2021 17:05 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/1 "2021-01-28T17:05:09Z")

</div>

Hello,

I am connecting Arduino to Rapberry Pi over bluetooth. On Raspberry Pi if I create **rfcomm channel** via `sudo rfcomm hci0 MAC_HERE 1`, I can use **serial input node** in Node-RED and get data as **/dev/rfcomm0** appears when configuring the node. However, if the connection is established via python socket module, there is no **/dev/rfcomm0** is created.

So the question is how should I configure the serial node so I can see the transmitted data on Node-RED when using python socket module?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [28 January 2021 19:12 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/2 "2021-01-28T19:12:30Z")

</div>

If python had already directly grabbed the port then Node-RED can’t also get hold of it. The /dev/rfcomm0 version is the one to use

---

<div class="post-metadata">

### Author: ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)
#### Post date: [28 January 2021 19:33 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/3 "2021-01-28T19:33:43Z")

</div>

Hi dceejay,

I need to figure out how to bind that socket to virtual port /dev/rfcomm0. Unfortunately I could not find useful bluetooth node that I can use after pairing.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [28 January 2021 19:48 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/4 "2021-01-28T19:48:58Z")

</div>

Not sure what you mean. It’s a serialport so use the serialport node

---

<div class="post-metadata">

### Author: ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)
#### Post date: [29 January 2021 09:52 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/5 "2021-01-29T09:52:46Z")

</div>

Sorry for the confusion. Let me explain in detail.

**rfcomm** is a deprecated command line of **BlueZ** which is the official linux bluetooth protocol stack.  
The command of `sudo rfcomm hci0 00:0E:12:34:56:67 1` does the following:

- Creates an **rfcomm** channel at port 1.

- Binds that channel to virtual **/dev/rfcomm0** port/device.

In that case we can grab **/dev/rfcomm0** by using the **serial input** node from **Node-RED** and read the data. However, I want to avoid using **rfcomm** command line tool because it is **deprecated**.

The second way to do that is utilizing **python socket module**. However, socket module **does not** create virtual port/device as **/dev/rfcomm0** , hence we cannot grab it by using **Node-RED Serial Input** node. Here we can do three things:

1. Find a way to bind created python socket to /dev/rfcomm0 (I am also working on this, first we need to manually create that port.).
2. Find a node from Node-RED that can grab, rfcomm connection which is not virtually bound to that serial port.
3. Find a bluetooth node from Node-RED which can do all.

The 2nd and 3th methods are the reason why I posted my question here.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [29 January 2021 11:09 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/6 "2021-01-29T11:09:55Z")

</div>

Ah right,  
I've not been following the internals of the Bluetooth stack. Presumably if it is now a socket then it must bind to a network port in some way ? pan0 etc ? so you may be able to use the TCP or UDP nodes ? Or maybe you can add the device to a network bridge (outside of Node-RED) so that it then is visible as a network device ? Just hypothesising here of course.

---

<div class="post-metadata">

### Author: ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)
#### Post date: [29 January 2021 11:27 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/7 "2021-01-29T11:27:03Z")

</div>

> Presumably if it is now a socket then it must bind to a network port in some way ?

Exactly. However I couldn't figure this out from the [documentation](https://docs.python.org/3/library/socket.html) of socket module. I will try the nodes you mentioned and provide a feedback asap.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [29 January 2021 11:32 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/8 "2021-01-29T11:32:01Z")

</div>

Maybe something like [Bluetooth Programming with Python 3 - Kevin Doran](https://blog.kevindoran.co/bluetooth-programming-with-python-3/)

---

<div class="post-metadata">

### Author: ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)
#### Post date: [29 January 2021 11:44 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/9 "2021-01-29T11:44:28Z")

</div>

I am pretty aware of that module, however:

> **This project is not under active development.**

as stated at their [GitHub.](https://github.com/pybluez/pybluez). Also, the module itself do not add anything different than **socket module** regarding creating rfcomm connection. The module offers additional services such as discovering devices etc., however I would suggest using **D-BUS API** as documented in official [BlueZ](https://github.com/bluez) repo which I am currently using to pair my devices.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [29 January 2021 11:48 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/10 "2021-01-29T11:48:31Z")

</div>

OK - good luck !

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [30 March 2021 11:49 UTC](https://discourse.nodered.org/t/configuring-serial-node-for-bluetooth-communication/39943/11 "2021-03-30T11:49:23Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
