Bluetooth presence detection

Simple occupancy detection via Bluetooth

This flow checks whether a Bluetooth device is in range. It does not require BT pairing because name lookups are allowed on any device. Tested on a Raspberry Pi 3 with the integrated BT receiver and some cellphones.

Usage

  • For Raspian, install hcitool with sudo apt-get install bluez
  • Verify that BT works, e.g. with hciconfig
  • The user running Node-RED must be a member of the bluetooth group, e.g. sudo usermod -a -G bluetooth nodered
  • Replace the MAC in the cellphone node with the target device's MAC. If unsure where to find it, make the device discoverable and do hcitool scan
[{"id":"a2aa8fbd.4cf9c8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"f01d11e6.a3026","type":"exec","z":"a2aa8fbd.4cf9c8","command":"/usr/bin/hcitool","addpay":true,"append":"","useSpawn":"false","timer":"10","oldrc":false,"name":"bt presence","x":350,"y":160,"wires":[["124fdc39.b4a09c"],[],[]]},{"id":"124fdc39.b4a09c","type":"function","z":"a2aa8fbd.4cf9c8","name":"nonempty","func":"msg.payload = msg.payload ? 1 : 0;\nreturn msg;\n","outputs":1,"noerr":0,"x":520,"y":160,"wires":[["df8114bf.397578"]]},{"id":"df735f89.216f8","type":"inject","z":"a2aa8fbd.4cf9c8","name":"cellphone","topic":"","payload":"name 84:B1:53:E3:8A:18","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":160,"wires":[["f01d11e6.a3026"]]},{"id":"df8114bf.397578","type":"debug","z":"a2aa8fbd.4cf9c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":680,"y":160,"wires":[]}]

Flow Info

Created 5 years, 6 months ago
Rating: 5 4

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • exec (x1)
  • function (x1)
  • inject (x1)
Other
  • tab (x1)

Tags

  • presence
  • raspberrypi
  • bluetooth
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option