I wanted to get the RSSI value to measure how far a device is from a handset...the problem I am currently facing is whether the RSSI value keeps on changing even after the devices are paired and also if can the value be directly used as short?
The RSSI value will fluctuate significantly.
It is proportional with distance, but it is affected by interference, and also by the 2 connected devices' power table (they might reduce their tx power if they are close).
That being said, RSSI will still appreciate with devices getting closer.
I preferred logging the RSSI data I receive on my other(embedded) device and sending it back to Android, showing it there. My embedded device has clear access to the Bluetooth stack, and so can get more accurate and more intense readings of the RSSI.
Ofc, getting the RSSI of the other device from Android should also work, but probably not so good (you have too many layers on top of the actual Bluetooth stack - linux bluez, then Android...).
I have my own graphing application for Bluetooth RSSI monitoring in Android, here are 2 printscreens from my app:
You can also look at Link Quality...this is another useful parameter(it it susceptible to duplications of the signal).
Here is a scientific paper on the subject.
Related
I want my android device to pick a BT device in range with a best RSSI and connect to it. Is there a way to implement such thing?
Ex: I have 5 ESP32-based devices around my house and need my phone to reconnect to the closest device (with a strongest RSSI). Is there a way to make app automatically pick the best RSSI from the available list of devices, terminate previous connection and reconnect to the device with best RSSI?
Your help is greatly appreciated. Thanks.
Yes this is definitely doable. All your app needs to do is the following:-
Scan for devices for a specific interval (e.g. 5 seconds).
Filter the scanned devices based on their name (i.e. you want to make sure that you only have the ESP32 devices and not other random Bluetooth devices).
Find the device with the best RSSI.
Connect to the device with the best RSSI.
If you want the process to be continuous, then go back to step 1.
However, keep in mind that RSSI does not always equate to distance/range. The device with the best RSSI might actually be further than other devices. The links below go over this plus some other useful data that you might need for your application:-
The ultimate guide to Android Bluetooth Low Energy
Using BLE for indoor positioning
Bluetooth LE RSSI for proximity detection
I have a BLE device (self made) that I pair with my app (iOS+Android).
I want to notify the user when the bluetooth signal is weak or better - when the device is about to disconnect.
Searching the web resulted with RSSI being the only value that is related to signal, yet I was unable to find a RSSI threshold that hints possible disconnection.
Is there a way to know?
Thanks a lot,
Giora.
The ability to connect to a BLE device with weak RSSI varies a lot depending on the phone you're using to connect to your device.
With some smartphones, especially those running on Android 8+, you might be able to stay connected to a BLE device advertising with a weak RSSI, whereas with some other smartphone, you're might have issue staying connected to a device with a strong RSSI.
It also depends on the quality of the BLE chip on your peripheral.
To answer your question, I would say you need to run some calibration tests, establishing the average RSSI at which your center or peripheral throws a disconnection, and start from there.
You'll need to calculate this average across several types of phones, including Android and iOS's, or, even better, set a threshold per OS.
I have two android phones and can successfully measure each of their respective RSSI measurements to connected Wireless Access Points. I would like to be able to read the RSSI between the two phones themselves, with a view to estimate the distance between each device.
One way I see in order to calculate the RSSI between each other is the following logic:
Make the one Android device (lets say device_1) to be the Access Point using WiFi tethering
Let the other Android device (lets say device_2) to measure the RSSI from the device_1. This is possible now because due to the wifi tethering of device_1 now the device_2 will be able to see the device_1 in its wifi scan results and even if you want connect to that.
Now make the opposite one. Make the device_2 to make use of WiFi tethering and then let device 1 to calculate the RSSI from device_2.
In order to catch any possible questions on that, you have to do it both ways, meaning that both devices must use the WiFi tethering and get 2 measurements. This is for two reasons. Firstly, multiple devices have defferent transmit powers so, you will read different rssi values (even if the transmitted power is the same then again due to different scatterring environment the rssi values would differ). Secondly, you will be more accurate if you obtain 2 values and even better if you repeat this methodology more than one time and make an average of them, but keep in mind that you cannot divide dBm values. You can take a look in my answer on the following post for that
WiFi readings unstable in android
I need to measure bluetooth signal between two or more mobile phones and detect nearest phone in range. After a lot of researching I came to idea to do periodically discovering for new bluetooth devices and measure rssi via EXTRA_RSSI that returned by ACTION_FOUND. All devices must be always in discovery mode and also must periodically scan for other devices.
Is this approach good or there are some better solution? What problems I can expect with this approach?
This solution Android 2.1: How do I poll the RSSI value of an existing Bluetooth connection? doesn't work for me because need phones to be rooted.
RSSI is a bad indicator for distance under real world conditions.
It could work under ideal conditions (free space propagation) but in reality you always have obstacles like walls, trees, etc. that affect the propagation.
See this article for more detailed information on propagation models.
RSSI doesn't indicate which phone is nearest, only which phone has the strongest signal.
so I'm trying my hand at android developing this summer. I was trying to make a sort of alarm app when a pair of connected devices go out of range of each other.
From looking around on the internet / stack overflow, it seems that looking at the RSSI value will help me achieve this.
However, it seems that the RSSI value can only be read at the time of connection with the device, that is it doesn't update itself (or there is no method to do so).
Is the RSSI value the only way to achieve my goal?
Would it be possible to use RemoteDevice and RemoteDeviceHelper? Has anyone tried this?
Any other suggestions and hints would be much appreciated
You could establish a connection with the device and exchange heartbeat information with the device , you can use the reception of valid heartbeat information to detect device being in range and or going out of range..
Your algorithm can use this information in conjunction with the connection loss to detect device being out of range and set off the alarm.
RSSI in Android available via public APIs is only during the discovery process, the other non public means of reading the RSSI (like in RemoteDeviceHelper) should also be possible , but RSSI by itself is not a good indication of distance.