BLE Intermittent Crashing

Another update.

Last night I established a connection, made sure I could read and write, then left it overnight. I checked about two hours in and still had a connection. In the morning the device had disconnected but I didn't have any errors. I assumed it might have been because I wasn't keeping the connection alive via a "ping" of some kind.

I changed the program to toggle the value on for 10 seconds, then off again, every 5 minutes. In addition to reading the state every 2 seconds. Everything worked properly for about 6 hours at which the device disconnected. I could not scroll far enough up the terminal to see if there was an error, but Node-RED appeared not to have crashed or reset, but was generating an error every 2 seconds due to trying to read from a disconnected device.

I checked right before I had to step out for some errands and upon seeing the disconnection without any errors I closed my laptop in frustration which turned off my Arduino. When I came back and turned on the laptop again I was able to reconnect without restarting my Node-RED program.

I'm still going to try the other BLE packages to try to get better results but I fear this might be the sort of thing I run into with any of them. I'm going to check again, but I don't think I can use a catch node to catch the disconnect state. I would feel better if I could at least detect a disconnect so that I could attempt to reconnect. Is there another way besides a catch node to catch an error?

Last update for a little while.

I have spent the last few hours working with node-red-contrib-noble-bluetooth and the scan, connect, and read part was easy and worked properly. I have not been able to get a "write" to work. I can inject a buffer object with a hex value of 0x01 which is what I was using to turn on the LED when I was using node-red-contrib-generic-ble but it is not working.

I get no errors, but the message is not being sent to the Arduino. I have the serial monitor open for the Arduino which gives me feedback about when devices connect, disconnect, or a message is received. I get a "connected device" message, but nothing when I send the write. The device remains connected.

Here is my Node-RED flow if someone would like to help me figure out what is going wrong. I would also appreciate anyone chiming in who has used this package to successfully read and write to a peripheral device.

[{"id":"204c2dc0.c9dcb2","type":"inject","z":"f04655a6.2e0548","name":"Start scan","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"start","payload":"{}","payloadType":"json","x":120,"y":360,"wires":[["35c7b3f4.1bddfc"]]},{"id":"35c7b3f4.1bddfc","type":"BLE scanner","z":"f04655a6.2e0548","name":"","services":"19b10000e8f2537e4f6cd104768a1214","servicesType":"str","continuous":false,"x":290,"y":380,"wires":[["bd89d1.4ab0063"]]},{"id":"bd89d1.4ab0063","type":"BLE device","z":"f04655a6.2e0548","name":"","x":470,"y":380,"wires":[[]]},{"id":"067b3cad9215e4d9","type":"debug","z":"f04655a6.2e0548","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":480,"y":460,"wires":[]},{"id":"faebedd8db71416e","type":"inject","z":"f04655a6.2e0548","name":"Stop scan","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"stop","payload":"{}","payloadType":"json","x":120,"y":400,"wires":[["35c7b3f4.1bddfc"]]},{"id":"bc867c0d3e1bede0","type":"BLE in","z":"f04655a6.2e0548","topic":"read","characteristic":"19b10001e8f2537e4f6cd104768a1214","name":"Read manufacturer","x":290,"y":460,"wires":[["067b3cad9215e4d9"]]},{"id":"2e68bb70a9aefd0b","type":"inject","z":"f04655a6.2e0548","name":"","props":[{"p":"peripheral","v":"84cca8777466","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":460,"wires":[["bc867c0d3e1bede0"]]},{"id":"2e8f6f036825a497","type":"inject","z":"f04655a6.2e0548","name":"","props":[{"p":"peripheral","v":"84cca8777466","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":520,"wires":[["b3b3b4f995bdb926"]]},{"id":"13cf4b0257c0ae34","type":"BLE out","z":"f04655a6.2e0548","characteristic":"19b10001e8f2537e4f6cd104768a1214","name":"","x":480,"y":520,"wires":[]},{"id":"b3b3b4f995bdb926","type":"function","z":"f04655a6.2e0548","name":"function 1","func":"msg.payload = Buffer.from(\"01\", \"hex\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":520,"wires":[["13cf4b0257c0ae34"]]}]

Does anyone have any experience with the node-red-contrib-epi-bluetooth package? This seems to treat the Pi as a server/peripheral that an Arduino/ESP32 client/central can read/write?

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