# BT broken after using cam

**URL:** <https://discourse.nodered.org/t/bt-broken-after-using-cam/23494>\
**Category:** General\
**Created:** [23 March 2020 10:25 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494 "2020-03-23T10:25:54Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [23 March 2020 10:25 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/1 "2020-03-23T10:25:54Z")

</div>

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:

```auto
[{"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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/e/eede33fd2422ef6a0f3d16697e92311c82b4321f.png)

![no data](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/5891e296ae2ace9464f0db76a6d875cf0f657f7c.png)

---

<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:** [23 March 2020 10:53 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/2 "2020-03-23T10:53:40Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [23 March 2020 11:47 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/3 "2020-03-23T11:47:29Z")

</div>

Thank you for your fast reply.

That happens when i take a picture:

```auto
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`

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [23 March 2020 12:03 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/4 "2020-03-23T12:03:15Z")

</div>

> [@mruch](#):
>
> /home/pi/Pictures/latest.jpg written with success!

Looks like it wrote a file.

---

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [23 March 2020 12:04 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/5 "2020-03-23T12:04:58Z")

</div>

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

I m using raspian lite

---

<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:** [23 March 2020 12:30 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/6 "2020-03-23T12:30:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [23 March 2020 13:50 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/7 "2020-03-23T13:50:11Z")

</div>

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

```auto
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!

```

---

<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:** [23 March 2020 15:56 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/8 "2020-03-23T15:56:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [23 March 2020 19:15 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/9 "2020-03-23T19:15:17Z")

</div>

So i deactivated the bluetooth devices in node-red.  
I connected the thermometer as described [here](https://zsiti.eu/xiaomi-mijia-hygrothermo-v2-sensor-data-on-raspberry-pi/).

1. I get data from the thermometer by console
2. Taking picture with node-red
3. Result:

```auto
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:~ $

```

---

<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:** [23 March 2020 20:14 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/10 "2020-03-23T20:14:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [23 March 2020 21:05 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/11 "2020-03-23T21:05:36Z")

</div>

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

---

<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:** [23 March 2020 21:35 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/12 "2020-03-23T21:35:43Z")

</div>

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](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.

---

<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:** [23 March 2020 21:41 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/13 "2020-03-23T21:41:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [24 March 2020 15:50 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/14 "2020-03-24T15:50:33Z")

</div>

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

---

<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:** [24 March 2020 17:39 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/15 "2020-03-24T17:39:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mruch](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mruch](https://discourse.nodered.org/u/mruch)\
**Post date:** [25 March 2020 18:18 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/16 "2020-03-25T18:18:01Z")

</div>

Just submitted the issue

---

<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:** [24 May 2020 18:18 UTC](https://discourse.nodered.org/t/bt-broken-after-using-cam/23494/17 "2020-05-24T18:18:05Z")

</div>

Closed on 24 May 2020 18:18 UTC

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