Bluetooth proximity sensor
Posted: 05 Sep 2016 01:02
Hi,
i'm wearing a smart watch. Pebble Watch. Newly i thought, may be it possible to use my pebble as a proximity sensor. I tested it and it seems to be working. It can also used together with a smartphone.
Namely it is possible to establish a bluetooth connection to a device if you know mac address of the device. And you do not need to pair device. Once you connected to the device, you can obtain a RSSI value (Received signal strength indication). The closer is device to doungle the lower is the RSSI.
I have installed banana pi with razzberry in my workroom. I connected a bluetooth dongle to banana pi and installed bluetooth stuff.
Such i wrote a bash script like this
I saved the script as The script gets as paraemter mac address and returns back the RSSI value.
Add btping to /opt/z-way-server/automation/.syscommands
now you can create CodeDevice (sensorMultilevel) based on btping.
Now i can create logical rules based on this proximity sensor. For example turn on light if rssi is < 3 and turn off if rssi >3. It works perfectly. Or i can "track" my phone if i lost it again somewhere.
I have polling interval 10 seconds. I do not know, how much it stress the battery of my pebble. But i hope not very significant.
In order to find out mac address of pebble, smartphone or other device you have to put it in discoverable mode and start hcitool scan in command line on banana pi
For example pebble goes in discoverable mode if you go to bluetooth setting menu. An android smartphone is also in discoverable mode if you open bluetooth settings.
greetings
i'm wearing a smart watch. Pebble Watch. Newly i thought, may be it possible to use my pebble as a proximity sensor. I tested it and it seems to be working. It can also used together with a smartphone.
Namely it is possible to establish a bluetooth connection to a device if you know mac address of the device. And you do not need to pair device. Once you connected to the device, you can obtain a RSSI value (Received signal strength indication). The closer is device to doungle the lower is the RSSI.
I have installed banana pi with razzberry in my workroom. I connected a bluetooth dongle to banana pi and installed bluetooth stuff.
Such i wrote a bash script like this
Code: Select all
hcitool cc $1 2>/dev/null;
PRESENT=$(hcitool rssi $1 2>/dev/null | sed -e "s/RSSI return value: -*//")
hcitool dc $1 2>/dev/null
if [ -z $PRESENT ]
then
echo "250"
exit 250
else
echo "$PRESENT"
exit $PRESENT
fi
Code: Select all
/usr/bin/btping
Code: Select all
root@bananapi:/opt/z-way-server/automation# btping B0:B4:48:02:1B:8E
1
Code: Select all
root@bananapi:/opt/z-way-server/automation# cat .syscommands
btping
Code: Select all
parseInt(system('btping B0:B4:48:02:1B:8E')[1])

I have polling interval 10 seconds. I do not know, how much it stress the battery of my pebble. But i hope not very significant.
In order to find out mac address of pebble, smartphone or other device you have to put it in discoverable mode and start hcitool scan in command line on banana pi
Code: Select all
root@bananapi:/opt/z-way-server/automation# hcitool scan
Scanning ...
B0:B4:48:02:1B:8E Pebble 1B8E
C4:46:19:E2:6A:EE ubuntu-0
greetings