I am currently using raspberry pi and want to get RSSI of a non-connected Bluetooth address. I am using
import bluetooth
result=bluetooth.lookup_name('XX:XX:XX:XX:XX:XX',timeout=5)
if(result !=None):
print("user near")
else:
print("user far")
but I want to be a little more precise and go to the else block in a closer distance and hence I need an RSSI value. Please help. I am new with raspberry and Python. (I am working in python3)
Getting the RSSI value on a Raspberry Pi is supported by the BlueZ device API.
In the example below I have used pydbus as the library to access BlueZ's D-Bus API. This example scans for 60 seconds and writes the device address and RSSI value to a file. You could modify the code to take an action when a particular address and RSSI value is found.
If you need to install the
gi.repository
library then follow the "Installing the system provided PyGObject" for Debian instructions at: https://pygobject.readthedocs.io/en/latest/getting_started.html#ubuntu-getting-started