# BLE Intermittent Crashing

**URL:** <https://discourse.nodered.org/t/ble-intermittent-crashing/66337>\
**Category:** General\
**Created:** [11 August 2022 19:00 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337 "2022-08-11T19:00:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [11 August 2022 19:00 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/1 "2022-08-11T19:00:40Z")

</div>

I have another post on the forum called "Help with Bluetooth" where I discuss general tips for getting a Bluetooth project to work. I hope I'm not violating the forum rules by creating another post as this is also about Bluetooth but this post involves trying to solve an error.

I am using a Raspberry Pi (RPI OS Bullseye) running Node-RED (v3.0.0) to communicate to an Arduino Nano 33 IOT microcontroller over BLE. I am using `node-red-contrib-generic-ble` v4.0.3, and the ArduinoBLE library (specifically the LEDCallback example).

I can connect, read, and write successfully with no issues, for a while. I will post the flow if it is helpful but I have one characteristic that turns off and on an LED on the Arduino. I read the state of the characteristic once every two seconds.

This will run with no problems for about 5 minutes or so, then node-RED crashes and reboots and I lose connection to my Arduino and I have to manually stop and restart node-RED to re-establish a connection. I have tried lowering the frequency of the read to once every 30 seconds but for my case I can't lower it any further. I will post the log I see in the command window with the error below.

If there is another node package or a better way to achieve BLE communication from the Pi to Arduino I would be interested.

Thank you!

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [11 August 2022 19:01 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/2 "2022-08-11T19:01:36Z")

</div>

```auto
Starting as a systemd service.
11 Aug 13:22:54 - [info]
Welcome to Node-RED
===================
11 Aug 13:22:54 - [info] Node-RED version: v3.0.0
11 Aug 13:22:54 - [info] Node.js version: v16.16.0
11 Aug 13:22:54 - [info] Linux 5.15.32-v7l+ arm LE
11 Aug 13:22:55 - [info] Loading palette nodes
11 Aug 13:22:58 - [info] Dashboard version 3.1.7 started at /ui
11 Aug 13:22:58 - [info] Settings file : /home/mtg/.node-red/settings.js
11 Aug 13:22:58 - [info] Context store : 'default' [module=memory]
11 Aug 13:22:58 - [info] User directory : /home/mtg/.node-red
11 Aug 13:22:58 - [info] Projects directory: /home/mtg/.node-red/projects
11 Aug 13:22:58 - [info] Server now running at http://127.0.0.1:1880/
11 Aug 13:22:58 - [info] Active project : Auto_Test_Panel
11 Aug 13:22:58 - [info] Flows file : /home/mtg/.node-red/projects/Auto_Test_Panel/flow.json
11 Aug 13:22:58 - [warn] Using unencrypted credentials
11 Aug 13:22:58 - [info] Starting flows
11 Aug 13:22:58 - [info] Started flows
11 Aug 13:22:58 - [info] [GenericBLE] Start BLE scanning
11 Aug 13:33:49 - [red] Uncaught Exception:
11 Aug 13:33:49 - [error] DBusError: Connection ":1.70" is not allowed to add more match rules (increase limits in configuration file if required; max_match_rules_per_connection=512)
    at _methodReturnHandlers.<computed> (/home/mtg/.node-red/node_modules/dbus-next/lib/bus.js:339:27)
    at handleMessage (/home/mtg/.node-red/node_modules/dbus-next/lib/bus.js:98:11)
    at EventEmitter.<anonymous> (/home/mtg/.node-red/node_modules/dbus-next/lib/bus.js:147:9)
    at EventEmitter.emit (node:events:527:28)
    at /home/mtg/.node-red/node_modules/dbus-next/lib/connection.js:112:14
    at Socket.<anonymous> (/home/mtg/.node-red/node_modules/dbus-next/lib/message.js:63:9)
    at Socket.emit (node:events:527:28)
    at emitReadable_ (node:internal/streams/readable:578:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Consumed 38.421s CPU time.
nodered.service: Scheduled restart job, restart counter is at 1.
Stopped Node-RED graphical event wiring tool.
nodered.service: Consumed 38.421s CPU time.

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 August 2022 08:55 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/3 "2022-08-12T08:55:15Z")

</div>

> [@jgreenmt](#):
>
> `DBusError: Connection ":1.70" is not allowed to add more match rules (increase limits in configuration file if required; max_match_rules_per_connection=512)`

This appears not to be a BT problem at all but rather a modbus one.

---

<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:** [12 August 2022 09:29 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/4 "2022-08-12T09:29:53Z")

</div>

I think this is DBus rather than Modbus. I believe that DBus may be involved when using bluetooth hardware.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 August 2022 11:05 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/5 "2022-08-12T11:05:24Z")

</div>

Oops, yes my bad. Too used to seeing modbus in the comments these days 🙂

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [12 August 2022 13:12 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/6 "2022-08-12T13:12:02Z")

</div>

So what does this mean? And is there a way to keep the DBus from crashing?

---

<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:** [12 August 2022 13:35 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/7 "2022-08-12T13:35:06Z")

</div>

> [@jgreenmt](#):
>
> node-red-contrib-generic-ble

I was going to suggest asking on the node's github page, but since the author has not responded to any issues raised there since January 2021 I think that may be pointless. It appears the node is no longer supported. I don't know if there is a better one.

---

<div class="post-metadata">

**Author:** ![Frida](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/frida/32/68250_2.png) [@Frida](https://discourse.nodered.org/u/Frida)\
**Post date:** [12 August 2022 17:27 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/8 "2022-08-12T17:27:56Z")

</div>

Maybe this can be used, I only use the scanner part.  
node-red-contrib-ble-sense.

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [12 August 2022 18:06 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/9 "2022-08-12T18:06:00Z")

</div>

@Colin Thank you for the information. It is frustrating that none of the BLE modules appear to be maintained. I know in my other post a debate broke out on whether BLE is even worth pursuing, but in my case I would like to try to make it work. This is the farthest I've gotten with any of the BLE packages.

@Frida While waiting for a response to this thread I tried the package you mentioned and I had no trouble scanning and connecting to my device. But I found the response to be rather bulky and I haven't been able to write a value to the characteristic. I can read it, but not write. Also in a past project I remember having issues with the connect node randomly disconnecting from the Arduino, and only a shutdown and restart of Node-RED would allow it to connect again.

I realize that BLE is a pain to develop and interface with but I wish there was a straightforward way to comminicate. I'm also going to try `node-red-contrib-noble-bluetooth` in hopes that it will work.

If I'm out of luck with any of the built in functions of Node-RED would any of the following be possible?

1. Use an external npm package/module with a function node

2. Interface with a Linux/Python script using an exec node

3. Tie a BLE device to a serial port and use the Serial nodes

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 August 2022 19:34 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/10 "2022-08-12T19:34:44Z")

</div>

> [@jgreenmt](#):
>
> I realize that BLE is a pain to develop and interface with but I wish there was a straightforward way to comminicate. I'm also going to try `node-red-contrib-noble-bluetooth` in hopes that it will work.
> 
> If I'm out of luck with any of the built in functions of Node-RED would any of the following be possible?
> 
> 1. Use an external npm package/module with a function node
> 2. Interface with a Linux/Python script using an exec node
> 3. Tie a BLE device to a serial port and use the Serial nodes

I may be somewhat bias but none of my experiments with BT over the years have gone well. Also, I note from many years of enterprise IT experience that even vendors with very deep pockets can struggle to deal with the bizarre thing that is BT.

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [12 August 2022 20:15 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/11 "2022-08-12T20:15:27Z")

</div>

I've heard many echo your sentiment, here and elsewhere.

The part that frustates me specifically is that I haven't had issues with BLE between Arduinos or ESP32s. I only started experiencing issues when I involve the Pi. But I've only tried Node-RED specific solutions. It also seems that what I am trying to do seems very basic, but even that won't work reliably.

I guess I'm just in denial. I don't really have a reason not to use an Arduino or ESP32 as a gateway between BLE to Serial, other than stubborness. And with the ESP32 I can just use ESP-NOW instead of BLE altogether.

I just wanted to see if there was an approach using the Pi's builtin BLE capabilities. Whether through Node-RED or something I can expose to Node-RED.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 August 2022 20:47 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/12 "2022-08-12T20:47:05Z")

</div>

> [@jgreenmt](#):
>
> ESP32s

Have certainly had some issues. I think that (at least for early models), trying to have both BT and wifi active together tended to make the device unstable I believe.

You could maybe see if anyone in the Python world has had better success? You could then either call to Python directly or create a small BT server and interface to Node-RED.

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [12 August 2022 20:59 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/13 "2022-08-12T20:59:38Z")

</div>

If that's the case then I at the very least can have a Serial connection.

Where would you recommend reaching out for Python help?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 August 2022 21:09 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/14 "2022-08-12T21:09:13Z")

</div>

> [@jgreenmt](#):
>
> If that's the case then I at the very least can have a Serial connection

Might be better now, I've not tried for a long time.

> [@jgreenmt](#):
>
> Where would you recommend reaching out for Python help?

Hmm, not sure really, I stopped using Python regularly (and PHP completely!) when I started using Node.js. I've done a bit more with it recently for a variety of reasons but only really basic stuff I'm afraid. Do let us know if you find a good and helpful Python forum though, always useful 😃

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [12 August 2022 21:39 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/15 "2022-08-12T21:39:49Z")

</div>

I'm going to assuming chasing the Python route will be better than chasing Node.js or Linux?

Would it be inappropriate if I opened a new thread on this forum but specifically asked about Python handling bluetooth and calling from Node-Red?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 August 2022 00:10 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/16 "2022-08-13T00:10:23Z")

</div>

> [@jgreenmt](#):
>
> I'm going to assuming chasing the Python route will be better than chasing Node.js or Linux?

Sorry , I can't really say. Too many unknowns.

> [@jgreenmt](#):
>
> specifically asked about Python handling bluetooth and calling from Node-Red?

Not so much about the Python but interfacing to NR is fine.

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [13 August 2022 00:45 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/17 "2022-08-13T00:45:23Z")

</div>

Ok thank you all for your help.

I think my plan of attack is

1. Try the `node-red-contrib-noble-bluetooth` and `node-red-contrib-ble-sense` packages

2. Try to find a Python route to handle the bluetooth and then find a way to expose it to Node-RED

3. Give up

I will post any success I find.

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [13 August 2022 02:31 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/18 "2022-08-13T02:31:47Z")

</div>

I have an important update.

I have not been able to work on the project today but while away from my computer I've been working in some reading and re-visited the page for `node-red-contrib-generic-ble`. I read the section "Installation Note (Linux)" and it jogged my memory.

I glanced over this initially because when I worked on a Bluetooth project back in March I had done this. But I since had to wipe my Pi and had not done this on the new install. Upon doing this I have not had the error...SO FAR. Previously I was getting the error within 15-30 minutes. It has been almost 2 hours as of now and the error has not happened.

I am going to let this run over night and see if the error stays away. If so, I will rejoice and mark a solution.

---

<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:** [13 August 2022 07:51 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/19 "2022-08-13T07:51:26Z")

</div>

> [@jgreenmt](#):
>
> I read the section "Installation Note (Linux)"

What was it in there that you had not done the first time?

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [13 August 2022 14:10 UTC](https://discourse.nodered.org/t/ble-intermittent-crashing/66337/20 "2022-08-13T14:10:12Z")

</div>

`sudo usermod -G bluetooth -a pi`

I was doing a lot of different things trying to make BLE work for a project back in March and was using the same Pi for development. I had tried to get this package working and had ran this command when i first installed the package. I decided to go a different direction for that project and halted any BLE work.

Around June I wrapped up that project and wiped my Pi and did a fresh OS install. I had not executed the above command on the new install.

[Next page](https://discourse.nodered.org/t/ble-intermittent-crashing/66337.md?page=2)
