Find the nearest beacon - android

I am developing an application, that uses iBeacons. Its main feature is to detect the nearest beacon (distance does not matter, I need simply the nearest one) and present some content according to it.
On IOS it works like a charm, there is no question.
On Android I have strange experiences. I know, it is up to the hardware, bluetooth chip vendor etc. but even if a I tried a lot of things (averaging rssi, queing...), I can't make it stable. The beacons are some 3-5 meters away from each other, there are 8 pieces of them in a ~80 square meters room.
I use Android AltBeacon library. I can not detect the nearest beacon in a stable way: sometimes a Beacon, which is some 5 meters away from the device is 'nearer' by RSSI, than a beacon, which is right next to the device and so on. (beacons use the same TX power and advertising interval, altbeacon scanperiod is 250 msec)
What should I do to make it stable? What, when and how should I average rssi? Or should I do it at all? Or...?
Thank you very much!

The RSSI value will depend on a number of things beside the TX power, among them:
Multipath reflections: The 2.4 GHz will reflect from the walls, so if the reflection helps the distant beacon and attenuates the close beacon, then the distant beacon could get at stronger RSSI.
The placement of the antenna: Holding the phone the right way can make a big difference.
I can't say why iOS should work better then Android, but it could be that they have an averaging algorithm that works well. From my two points this is not a simple thing to get right.
To learn more about these issues I recommend reading Deploying iBeacon and Common Questions and Answers in Getting Started with iBeacon.

Related

Find Bluetooth devices within specific distance

I'm developing an android application to find Bluetooth devices within a specific distance. Now, I developed an application to get all nearby Bluetooth devices with their RSSI. now I want to find devices that only being within 2 meters. Actually approximate distance is enough. I read more. but I couldn't find a solution. Is there any way to do that.
I did tests with some Bluetooth low energy Beacons and the distance calculation is very unreliable.
It is done according to the intensity of the received signal, also in the configuration of the beacon that I used, you can select the emission power (weaker to be detected only at close range) but even so many times it said that the strongest signal came from one farther away.
I think the only thing you can hope is to say that some beacon (or bluetooth device) is close, within a radius of about 10m; but not to say which one is closer or which one is at 2 m or less
Hope it will help.

Room entry/exit detection using iBeacon RSSI

I'm detecting if a person enters or exits a room using iBeacon. The implementation is as follows:
1. Two beacons are placed per room. One in the door and the other is inside near the door.
2. To detect entry, the user must pass the door beacon then the one inside the room. For exit, it's the other way around.
Issue:
In case that there are rooms that are too adjacent with each other, an overlap will occur causing an error in the detection
Planned Solution:
Use RSSI to detect which one is the last nearest beacon when the inside room is detected. I'm thinking of checking the skewness of the distribution of the RSSI on a given time, say around 1 to 2 seconds since the user detected an inside beacon.
Is there other statistical analysis or any data analysis that can be used to determine or check with a probability which room the user entered?
Unless the rooms are very large (which it sounds like they are not based on the troubles you are having) I think any technique you find will have a high error rate. You might be able to get this error rate down far enough to be acceptable by recognizing cases where you simply cannot make a determination and refusing to do so in these cases to avoid false determinations.
Your best bet is to sample multiple RSSI measurements from different beacon packets (a minimum of 10 to filter out noise), then average them, perhaps throwing out the highest and lowest value before doing so. If this average RSSI is strong enough, say < -80 dB (and it is the strongest signal you have seen from all beacons) there is a high probability you are in the room indicated by the beacon.
The RSSI may drop off if you go far away from the beacon in the room so just because the criteria above are not met does not mean you are not in the room.
Keep in mind that it is impossible to determine which beacon is closest if all signals are weak -- noise becomes more important than signal. So make no conclusions unless one beacon has RSSI stronger than, say -85 dBm.
Make sure your beacons are transmitting as strongly as possible and advertising as often as possible. The latter will ensure that you get enough RSSI samples in a short time.
Finally, keep in mind that different Android phones have different Bluetooth antennas and receive the same beacon packets more or less strongly. A Huawei P9 Lite detects BLE signals at an RSSI 20 dB weaker than a similarly placed Moto G4+. Regardless of this, phones typically do not detect beacon signals weaker that -100 dBm and below -90 dBm the measurement is so weak as to become almost useless for relative distance determination.

iBeacon Accuracy While Android Device In Motion

I am testing out a positioning system using iBeacon and Altbeacon. I have found that my triangulation results are actually pretty accurate, but sometimes it takes upwards of 5 seconds to see the proper results.
For example, say I am currently standing at Point A. Altbeacon + my triangulation has me properly placed very close to Point A. However, when I move 5 meters away to Point B, I remain around Point A for around 6 seconds and all of the sudden I snap into place right near Point B. Is this an issue with Altbeacon, or possibly the communication between my iBeacons and my Android tablet?
Note: I am using a Kindle Fire 10, running FireOS 5.1.1 on top of Android. The Bluetooth iBeacon technology is BLE, and broadcasts at around 1Hz.
The issue of time lag that you describe may be caused by averaging intervals on the signal measurement. You do not say what scanning framework you are using, or if you are using raw RSSI or a distance estimate as input to your algorithm. The Android Beacon Library by default uses a 20 second averaging interval (configurable) for its distance estimates. Other framework's use similar averaging.
Reducing the averaging interval will lessen the lag, but increase the noise as an input to your algorithm.
EDIT: To reduce the distance estimate sampling interval to 3 seconds from the default 20 seconds, call:
RunningAverageRssiFilter.setSampleExpirationMilliseconds(3000l);
I have tried previously what you were trying to do. There was a lot of issues making it impossible to get correct triangulation results.
Theoretically it should work, but
Practically you will have a lot of challenges, like the fact the Bluetooth Beacon uses the 2.4GHz frequency, almost all Bluetooth Beacon has non-directional antenna, which means that you might risk not measuring the signal source but the reflection of the signal surrounded by the beacon.
The other fact is the noise from other sources or Bluetooth Beacon in your environment.
Depending on the Android phone model, the receiver antenna of Bluetooth is not necessarily mount same place in the phone, that means how you hold the phone will change the RSSI reading
Holding the phone in hand or near human body might also give different readings or no reading at all, since the human body contains water that is a signal reducer/killer for Bluetooth signal.
So even thus you improve your latency time of Bluetooth Beacon by software, you will still have these challenge make it almost impossible to get the right results.
I have seen a new directional Bluetooth Beacon I have not testing it yet, but it sounds like it solving some the mentioned issues.
It is correct what #davidgyoung wrote, but that won’t change the fact of real world scenario.
Btw, I have worked with Altbeacon a very nice and respected tool, and I used both RSSI and distance estimate with different type of Bluetooth Beacon and different phones and it did not help much, it is not Altbeacon the problem.
And regarding the university project I mentioned in my comments, we ended up using Bluetooth Beacon in different way to help us finding directions to target for visually impaired people, and we have developed scientific paper on it.
Finally for inspiration of what you are doing and what I mentioned in my answer, see this video it shows triangulation experiment, the provider of this video is btw also a user at Stackoverflow.
Note: my answer here is focusing on the context of triangulation and the challenges here make it as not a sweet solution.

How to measure the distance between an iPhone acting like an iBeacon and an Android device

I'm using my iPhone as an iBeacon device, and on the other side I have an Android 4.4.2 device scanning for the Bluetooth LE iBeacon signal from the iPhone. I searched for a good and easy way to calculate the distance between iBeacons and my Android phone, but I couldn't find anything that can help me with this.
Could you help me on this matter?
It's impossible to measure beacon distance accurately, I'm afraid, which is why Apple's own code just says "Immediate", "Near", "Far" and "Unknown". The best you can do is set up a reconstruction of the conditions you expect then do trial and error tests to map signal strength to probable distance. Trust me: I've spent a lot of time trying to do beacon distance measurement using a range of hardware.
Remember that the LE in Bluetooth LE means "Low Energy" – this stuff really is designed to use as little power as possible. That means the signal from iBeacons gets interrupted by people, walls and other objects. So, if I'm holding a beacon in my hand and put my phone next to it, I'll get a strong signal. If I move the beacon behind my back, the signal strength will collapse. If I just turn around, that has the same effect (for the same reason).
If you want to go down the "best you can do" approach, you effectively have to recreate at least partially the environment where your app will be used. So, if your app will be used in an office, find an office and place some beacons around there. Same for being in a shop.
Then get your app out and measure beacon strength at various distances to the beacon, potentially with obstacles in the way. With some averaging, you end up with something like "at 1 metre my signal strength was X, at 5 metres it was Y, at 10 metres it was Z", etc, and you then feed that into your distance calculation. It is, effectively, an educated guess.
If you find any library that claims to do beacon distancing for you, it just means they've taken their own educated guess based on their own signal strength testing.
One tip: if you're able to, stick your beacons to the ceiling. This minimises the chance of obstacles (read: people) getting between your beacon and your app.
We built a distance estimation formula into the Android Beacon Library of the form: d=A*(r/t)^B+C, where d is the distance in meters, r is the RSSI measured by the device and t is the reference RSSI at 1 meter. A, B, and C are constants. You can read more about it here. To use it with the library, you range for a beacon and then simply call:
beacon.getDistance();
This returns a distance estimate in meters. The library code is open source, so if you don't want to use the library you can copy the formula and use it directly.
As #TwoStraws notes, distance estimates are pretty rough guesses of how far a beacon is away, and the results you get vary with lots of factors:
The gain of the antenna on the receiving device. (Every Android device model is slightly different)
The noise on the A/D converter inside the phone that measures bluetooth signal strength.
The radio noise in the room.
Any obstructions between the transmitter and receiver.
Any surfaces (especially metal) that reflect radio signals.
Just be sure you set your expectations properly. Distance estimates are good for deciding if a beacon is close or far, or whether one beacon is closer than another. But they are less useful for measuring absolute distance.

Determining distance accuracy from beacon

I have couple of questions regarding the Radius networks Beacon.
How can we get the accurate distance between android devices and
beacon? So far the distance we're getting through
"android-beacon-library" is fluctuating.
How can we limit the beacon's transmission radius, say allowing
beacon to transmit only for 5 meters or to 20 cms ?
Please find the image with beacon distance reading for various devices (Moto g , Nexus 5 , Nexus 4 and iPhone 5s)
You will always see fluctuation on beacon distance estimates, so you have to set your expectations appropriately. Beacon distance estimating works by starting with a measurement of the radio signal strength using the bluetooth radio on the mobile device. A stronger signal means that the beacon is closer, where a weaker signal means the beacon is further away. The beacon transmits a reference value of its expected signal strength at 1 meter, saying in effect "If you are one meter away, you should see my signal level as -56 dBm". A formula inside the mobile phone then tries to make a guess of how far it is away based on the signal level at any given time. If the signal is a little bit weaker than -56dBm, such as -65dBm, the formula might estimate that the distance is 2.5 meters.
This technique is imperfect, and there are several reasons for fluctuation:
There is always background radio noise (like the static on an old AM radio) which causes individual signal strength measurements to vary.
There is error on the analog to digital converter inside the bluetooth radio, which also causes individual signal strength measurements to vary.
The bluetooth radio waves reflect off of some objects and are absorbed by others, making the actual signal strength change at different positions the same distance away, and when other objects in the vicinity move around.
The antenna pattern on both the transmitter and the receiver are not perfectly spherical. This means that when you rotate your phone or the beacon, you will see a slightly different signal level.
There are a few things you can do to minimize the error:
Use a beacon that transmits as frequently as possible, preferably at 10Hz or more. More transmissions mean more statistical samples of the signal level, which when averaged together help mitigate errors from sources 1 and 2 above.
Use as high of a transmitter power setting on your beacon as possible. The stronger the signal, the lower the noise level will be (relatively speaking) from source 1 above.
When possible, place your beacons where there is a clear line of sight to the receiving devices. Overhead often works best.
However, the best you can hope to do is reduce the variation as much as possible. You cannot eliminate it. For this reason, you must design your app so such variation is acceptable. If it helps your use case, you can also lower the beacon transmitter power so that devices only detect the beacon when they are relatively close.
Using Radius Networks' RadBeacon USB and RadBeacon Tag models, you can adjust the transmitter power using the free RadBeacon configuration app for iOS and OSX. The apps have a slider control to increase and decrease the transmitter power.
You should note, however, that by lowering the transmitter power, you will also increase the amount of variation on your distance estimates. This is because the signal to noise ratio will be lower.
Full disclosure: I am Chief Engineer for Radius Networks.
you can't really tell the distance to one beacon. That's why indoor localization is so hard.
you can't say exactly how far a beacon should transmit its signals, but on most beacons (I don't know about Radius networks) you can change the txPower / transmit power. This varies from beacon to beacon (and also depends on the environment around the beacon), so you'll have to do your own experiments to find the sweet spot.

Categories

Resources