BT broken after using cam

Hi
i discovered a strange behaviour on my Raspi 4. I use a flow to get temperature and humidity from a Xiaomi Bluetooth device. Additionaly a pic is taken by the camera connected via csi.

I use:
node-red-contrib-camerapi
node-red-contrib-xiaomi-ble

Reading the data works well, but as soon i take a picture BT is broken. From this point node-red doesnt receive any data from the BT device. The only solution is to restart the raspi.
Maybe someone knows whats the matter with it.
Thank you

Flow:

[{"id":"cbeb9ed1.70bc5","type":"tab","label":"bt cam test","disabled":false,"info":""},{"id":"89f5972.77c78e8","type":"camerapi-takephoto","z":"cbeb9ed1.70bc5","filemode":"1","filename":"latest.jpg","filedefpath":"0","filepath":"/home/pi/Pictures/","fileformat":"jpeg","resolution":"9","rotation":"0","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"100","agcwait":"1.0","led":"0","awb":"sunlight","name":"","x":360,"y":100,"wires":[["35f3c52e.99f8fa"]]},{"id":"35f3c52e.99f8fa","type":"debug","z":"cbeb9ed1.70bc5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":590,"y":100,"wires":[]},{"id":"9f3419b.606d668","type":"Xiaomi BLE","z":"cbeb9ed1.70bc5","name":"Mijia","address":"58:2D:34:39:E7:CC","scanningTimeout":60,"x":320,"y":180,"wires":[["35f3c52e.99f8fa"]],"icon":"node-red/bluetooth.png"},{"id":"b0f1c9a9.7a1ef8","type":"inject","z":"cbeb9ed1.70bc5","name":"","topic":"","payload":"","payloadType":"date","repeat":"15","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":180,"wires":[["9f3419b.606d668"]]},{"id":"3aa864c.97c381c","type":"inject","z":"cbeb9ed1.70bc5","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"30","x":140,"y":100,"wires":[["89f5972.77c78e8"]]}]

searching

no data

There may be something useful in the node red log. Restart node red using

node-red-stop
node-red-start

Leave the terminal open and get the flow to fail, then copy/paste the log output here. Copy/paste if possible please rather than a screenshot.

Thank you for your fast reply.

That happens when i take a picture:

23 Mar 11:42:50 - [info] [mqtt-broker:Thingsboard/Mijia3] Verbindung zum Broker mqtt://localhost:1883 hergestellt.
(node:2177) DeprecationWarning: Deep requiring like `const uuidv4 = require('uuid/v4');` is deprecated as of uuid@7.x. Please require the top-level module when using the Node.js CommonJS module or use ECMAScript Modules when bundling for the browser. See https://github.com/uuidjs/uuid#deep-requires-now-deprecated for more information.
CameraPi (log): /home/pi/Pictures/latest.jpg written with success!

I hope it helps

===== EDIT

i just tried uuid in console and it didnt work. Do i have to install it?
npm install uuid

Looks like it wrote a file.

Yes thats right, but after that bluetooth connection doesnt work anymore

I m using raspian lite

Post the full log output please, from the welcome message.
Also run the BT operation to see if that puts anything in the log.

This was my procedure:

  1. Start node-red
  2. Start flows getting data via bluetooth
  3. Take picture after 5 min
  4. Bluetooth: "no data"
  5. Waiting 10 min
Start Node-RED

Once Node-RED has started, point a browser at http://192.168.178.251:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
23 Mar 13:35:19 - [info]
Willkommen bei Node-RED!
===================
23 Mar 13:35:19 - [info] Node-RED Version: v1.0.4
23 Mar 13:35:19 - [info] Node.js  Version: v12.16.1
23 Mar 13:35:19 - [info] Linux 4.19.108-v7l+ arm LE
23 Mar 13:35:19 - [info] Paletten-Nodes werden geladen
23 Mar 13:35:22 - [info] Einstellungsdatei: /home/pi/.node-red/settings.js
23 Mar 13:35:22 - [info] HTTP-Statisch: /home/pi/Pictures
23 Mar 13:35:22 - [info] Kontextspeicher: 'default' [ module=memory]
23 Mar 13:35:22 - [info] Benutzerverzeichnis: /home/pi/.node-red
23 Mar 13:35:22 - [warn] Projekte inaktiviert: editorTheme.projects.enabled=false
23 Mar 13:35:22 - [info] Flow-Datei: /home/pi/.node-red/flows_green.json
23 Mar 13:35:22 - [info] Server wird jetzt auf http://127.0.0.1:1880/ ausgeführt.
23 Mar 13:35:22 - [warn]
---------------------------------------------------------------------
Die Datei mit den Datenflowberechtigungsnachweisen wird mit einem vom System generierten Schlüssel verschlüsselt.
Wenn der vom System generierte Schlüssel aus irgendeinem Grund verloren geht, werden Ihre Berechtigungsnachweise
Die Datei kann nicht wiederhergestellt werden. Sie müssen sie löschen und erneut eingeben.
Ihre Berechtigungsnachweise.
Sie sollten Ihren eigenen Schlüssel mit Hilfe der Option 'credentialSecret' in
Ihre Einstellungsdatei. Node-RED wird dann Ihre Berechtigungsnachweise erneut verschlüsseln.
Datei mit dem ausgewählten Schlüssel beim nächsten Deployen einer Änderung verwenden.
---------------------------------------------------------------------
23 Mar 13:35:22 - [info] Flows starten
23 Mar 13:35:22 - [info] Flows gestartet
23 Mar 13:35:22 - [info] [mqtt-broker:Thingsboard/MiFlora1] Verbindung zum Broker mqtt://localhost:1883 hergestellt.
23 Mar 13:35:22 - [info] [mqtt-broker:Thingsboard/Mijia2] Verbindung zum Broker mqtt://localhost:1883 hergestellt.
23 Mar 13:35:22 - [info] [mqtt-broker:Thingsboard/Mijia3] Verbindung zum Broker mqtt://localhost:1883 hergestellt.
23 Mar 13:35:22 - [info] [mqtt-broker:thingsboard weather] Verbindung zum Broker mqtt://localhost:1883 hergestellt.
(node:1973) DeprecationWarning: Deep requiring like `const uuidv4 = require('uuid/v4');` is deprecated as of uuid@7.x. Please require the top-level module when using the Node.js CommonJS module or use ECMAScript Modules when bundling for the browser. See https://github.com/uuidjs/uuid#deep-requires-now-deprecated for more information.
CameraPi (log): /home/pi/Pictures/latest.jpg written with success!

I don't see anything wrong there. I don't know what the problem might be.
If you stop node-red and use another method of monitoring the bluetooth and taking a photo does bluetooth keep working?

So i deactivated the bluetooth devices in node-red.
I connected the thermometer as described here.

  1. I get data from the thermometer by console
  2. Taking picture with node-red
  3. Result:
pi@green:~ $ python3 /home/pi/mitemp/demo.py --backend bluepy poll 58:2D:34:39:E4:A8
Getting data from Mi Temperature and Humidity Sensor
FW: 00.00.66
Name: MJ_HT_V1
Battery: 100
Temperature: 22.9
Humidity: 32.1
pi@green:~ $ python3 /home/pi/mitemp/demo.py --backend bluepy poll 58:2D:34:39:E4:A8
Getting data from Mi Temperature and Humidity Sensor
Traceback (most recent call last):
  File "/home/pi/mitemp/btlewrap/bluepy.py", line 27, in _func_wrapper
    return func(*args, **kwargs)
  File "/home/pi/mitemp/btlewrap/bluepy.py", line 56, in connect
    self._peripheral = Peripheral(mac, iface=iface, addrType=self.address_type)
  File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 391, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 439, in _connect
    raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 58:2D:34:39:E4:A8, addr type: public

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/mitemp/demo.py", line 96, in <module>
    main()
  File "/home/pi/mitemp/demo.py", line 92, in main
    args.func(args)
  File "/home/pi/mitemp/demo.py", line 26, in poll
    print("FW: {}".format(poller.firmware_version()))
  File "/home/pi/mitemp/mitemp_bt/mitemp_bt_poller.py", line 90, in firmware_version
    with self._bt_interface.connect(self._mac) as connection:
  File "/home/pi/mitemp/btlewrap/base.py", line 47, in __enter__
    self._backend.connect(self._mac)
  File "/home/pi/mitemp/btlewrap/bluepy.py", line 33, in _func_wrapper
    raise BluetoothBackendException() from last_error
btlewrap.base.BluetoothBackendException
pi@green:~ $

So taking the picture is messing with the bluetooth. What if you take a picture without using node-red?

Thanks for your help.

  1. Node-red started
  2. Getting BT data
  3. raspistill -o image.jpg
  4. Still getting BT data

So when taking a picture by console, bluetooth is not broken,
Its just when taking pictures with node-red

It seems that it is most likely a problem with node-red-contrib-camerapi. I see that the node hasn't been updated in two years and issues raised in that time have not been addressed. https://github.com/O-Hahn/node-red-contrib-camerapi/issues
I suggest either looking for an alternative camera node or you could just use an Exec node and pass it the raspistill command.

See this simple example of using raspistill to grab a pic in a flow
https://flows.nodered.org/flow/2b6c2f0d7a316f1a6831782d33a0d40c

Colin you are right. I tried it with an exec node and raspistill and it worked for me.
node-red-contrib-camerapi seems to be broken in that point.

Thank you very much guys! You made my day

Please submit an issue against the node on it's github page (which is linked from the npm page) so that others having a problem will see it and know that the node has a problem.

Just submitted the issue

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