I was wondering at; At what maximum rate would I be able to obtain the RSSI of Bluetooth device on my android phone? I have run a code identical to that given by Memochipan at the bottom of this thread:
Get bluetooth signal strength
It simply turns on “discovery”-mode on the phone, which then goes to scan for Bluetooth devices. However, it takes about 10-20 seconds to get an update from a specific device, which is too much for, what I’m doing. So, is it even possible to get an update quicker? What stops the other Bluetooth device from sending a signal back to my phone sooner? Physical limitations? Also, from what I read, actually connecting to device won’t give me a “reliable” RSSI-value at all.
Thank you very much
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'm right now focusing on Android, but I believe the answers to these questions apply to any operating system, they just will use different functions to get the data.
Once I've established a BLE connection, I can BluetoothGatt.readRemoteRssi() to "Read the RSSI for a connected remote device."
First question: am I understanding this function correctly, it is returning to me the strength of the signal (transmitted from the remote BLE device) that my Android device is receiving, right? I think it's the function name that's throwing me off, shouldn't the name just be readRssi()? readRemoteRssi() makes me think there's a companion function readLocalRssi() somewhere.
Second question: assuming I am understanding the function correctly, is there anything built into Bluetooth that lets me ask "what is the remote BLE device seeing for RSSI?" In other words, of the signal that the Android device is transmitting, how much of that is reaching the remote BLE device?
ADDED LATER
Based on the answer I got, apparently I'm not explaining myself very well. Let me try again.
The remote BLE device is transmitting with a certain power, and those radio waves head out in all directions, and some of those waves are received by my mobile device. My mobile device measures how strong those waves are, and that's reported as RSSI. RSSI stands for "Received Signal Strength Indicator" and since it's the local mobile device that's doing the receiving, it seems strange to name the function "remote". Of course RSSI measures something coming from a remote transmitter - otherwise it wouldn't be very useful.
Similarly, the mobile device is transmitting with a certain power, and those radio waves head out in all directions, and some of those radio waves are received by the remote BLE device. That remote BLE device measures the strength of those waves, and that would be his RSSI. My second question is asking whether there's anything in the Bluetooth standard (a predefined characteristic, for example, like "Battery Level") that lets me mobile device query the remote BLE device and ask "Hey dude, how much signal you getting?"
am I understanding this function correctly, it is returning to me the strength of the signal
(transmitted from the remote BLE device) that my Android device is receiving, right?
Actually rssi is calculated by ble chip based on the advertising packets that are received from the remote device. We don't directly get the rssi value from remote device.
I think it's the function name that's throwing me off, shouldn't the name just be readRssi()?
No. We are actually reading remote device's rssi.
readRemoteRssi() makes me think there's a companion function readLocalRssi() somewhere.
No there is no such method as rssi is determined at the other end to which the current device is connected to.
assuming I am understanding the function correctly, is there anything built into Bluetooth that lets me ask "what is the remote BLE device seeing for RSSI?" In other words, of the signal that the Android device is transmitting, how much of that is reaching the remote BLE device?
It is rssi. It is calculated based on how many advertising packets received against total packets.
Note: some of my answers are my guess based on my experience.
I'm currently trying to make an Android app that will have some interaction with a BLE device. That device doesn't have the Ibeacon protocol.
What I want to do is auto connect to that device every time it is in range even (and almost 99% of the time) when the app is not in foreground. The only thing I know is that it is a BLE device, I have access to it name and address (00:1E:C0:29:BD:F8).
It is crucial tha the app connect to it every time it come in range. Even if the phone is lock it must connect no matter what (except if the phone is shut down XD). But as soon as the phone has booted and that bluetooth is activated, I must be sure that my app will be able to connect to tha device if it come in range.
I wanted to know what is the best way to do so.
The only way I can think of is to start a service as sticky, that will scan every 15 seconds (or something similar) for the device it already has registered to auto-connect.
The downfall of that method I guess is that it will surely drain the battery, I'm not sure about that but doing a scan for 3 to 4 second every 15 second must use up a lot of battery.
What do you guys think of that ?
Does anybody know a better solution I could use ?
Thank in advance for the help.
Am working on a BLuetooth Low energy module embedded in a custom board . whenever i press an interrupt (push button) the ble module advertises some number once and goes to sleep ,again when interupt given it advertises the next number(incremented value) once and goes to sleep .These values are scanned in a custom android app running in nexus 5.Though the phone is scanning most of the packets ,sometimes it fails to capture some datapackets.the custom board advertises once and goes to sleep ,the phone must be able to capture this advertisement packets,but some times it miss the data packets. So my question is Is it normal that the BLE compatible phones cannot capture all datapackets from a pheriperal device i.e there may be loss of some data packets.Or is it the problem with smart phone nexus 5 ble hardware.
BLE is transmitting with low power on in a crowded spectrum. Some packet loss is to be expected (though I agree it is more than I'd like).
A higher level protocol will detect packet loss and request retransmission. In the case of BLE, instead of using advertisments for data you can actually connect to the device and then use notifications. These are far more reliable and shouldn't be dropped. The downside is most devices only support connecting to a handful of peripherals, usually 7. Listening for advertisments doesn't require connection and therefore there's no fixed limit to the number of advertisers you can listen to.
The packet loss also depends on what is listening. A nRF51822 trasmitting to my Nexus 4 with Android 5.0 at zero range gets >50% PLOS. When transmitting to another nRF51822 it gets around 20% PLOS. I guess the Nexus 4 tries to save power so maybe it doesn't listen continously.
I had a similar problem, that only some data packets were arriving. It seems that enabling the SCAN_MODE_LOW_LATENCY mode with ble scanner helps - your device will keep listening continously, so no data will be missed (unless there is clutter, bad range etc. like Timmmm suggested).
https://developer.android.com/reference/android/bluetooth/le/ScanSettings
hope this helps