I'm fairly new to iBeacon but I have spent the day trying to get informations and a working Android application with iBeacon.
I have stumbled upon Android iBeacon Library samples and gave it a try. I used the latest aar file (0.7.3) and basically copy/paste their examples in a new project.
I have created a beacon using an iPad with AirLocate (compiled from Apple's code from the Dev Center) and launch the code.
My problem is the range fluctuating all the time with no logic.
For example, the phone (in this case a Nexus 5, original rom, no modification) placed half a meter away from the iPad gives me the following measures :
0.01m
0.03m
0.07m
0.48m
0.01m
0.02m
etc.
When I use another iPad with AirLocate on it, it gives a more stable and realistic measure. Excluding the beacon as the source of the problem.
I have made the test with a Nexus 7 2013 (Original rom, not modified) and I got the same issue. I have read the wifi can cause problem so I disabled it but it is still the same.
I also have the same issue with Radius Networks application on the Play Store: iBeacon Locate
I was wondering if the anyone else have the problem with this library ?
Is there something I can do to help fix this problem ?
Do you know another library I can use which won't cause that kind of problem ?
Any help is appreciate. Thank you in advance.
A big part of the variation you see is Android is caused by a limitation in the way Android allows access signal strength measurements from Bluetooth LE. Unfortunately, there isn't much that can be done about this without changes to Android.
In both iOS CoreLocation and the Android iBeacon Library, the distance estimate is only an estimate, and fluctuations with noise on signal strength measurements cause the estimates to bounce around.
The algorithm in the Android iBeacon Library is not the same as in iOS CoreLocation, because the iOS CoreLocation implementation is closed source. The intention is that they behave in a similar way. The Android iBeacon Library is based on a 10 second running average of 80th percentile measurements (e.g. the top and bottom 10th percentile measurements are thrown away for the average.) You can see the details of the calculation here:
protected static double calculateAccuracy(int txPower, double rssi) {
if (rssi == 0) {
return -1.0; // if we cannot determine accuracy, return -1.
}
double ratio = rssi*1.0/txPower;
if (ratio < 1.0) {
return Math.pow(ratio,10);
}
else {
double accuracy = (0.89976)*Math.pow(ratio,7.7095) + 0.111;
return accuracy;
}
}
On Android, the Bluetooth LE Scan API only allows a single signal strength measurement per scan. On iOS, it is possible to get a different measurement for each advertisement broadcasted. By default, the Android iBeacon Library does one bluetooth scan every 1.1 seconds when it is in the foreground, therefore allowing one measurement every 1.1 seconds. So if you have an iBeacon that is transmitting 30 times per second (as iOS devices acting as iBeacons do), iOS will be able to get 300 samples in a 10 second period, and Android only 9. This explains why the estimate has higher noise on Android. And again, there is very little that can be done about it without operating system changes.
Depending on your use case, you may be able to reduce the noise in the distance estimate on Android by implementing a custom calculation that includes more samples over a longer period of time. This would only be appropriate if your use case does not need rapid updates in the estimate. If you are interested in this, you might open a feature request in the open source library.
Related
I am developing an android application to find the distance from Eddystone beacon to the mobile device. I am using Android Beacon Library and following this example. when I locate my beacon nearly 1 meter away from my device, it shows like below. it shows small values and changes continuously. How to solve this and get at least nearly accurate value.
The "underestimate" shown in the question suggests one or more of the following may be true:
The Beacon has not been calibrated.
The receiving phone device model may have an unusually high measurement of signal strength requiring a device-specific adjustment of its distance calculation.
See here for more information on how to address these issues.
Even once you address the above, set your expectations properly. Bluetooth LE distance estimates are rough. They are useful for telling you if another device is within a couple of meters or many meters away. But they cannot tell you the precise distance to a bluetooth transmitter.
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.
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.
I am using the altbeacon library with 2 iBeacons.
I downloaded the sample app for android studio from http://altbeacon.github.io/android-beacon-library/ and added the iBeacon Layout ("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24").
When I start the ranging activity the beacons are detected - but very sporadic.
See:
https://dl.dropboxusercontent.com/u/63333482/Screenshot_20160322-191422.png
I also installed the Locater App - and it seems to be quite the same here.
I'm testing with HTC m8.
Has anyone an idea what could be the problems (Beacons, Mobilephone, etc.?)
Thanks
Remember that beacons send at a rather low frequency. Usually once a second if you haven't configured them. That means you will see loss of "pings". You need to use a timer per beacon or compare timestamp with current time to keep tab on real loss of communication.
What frequency (or rather interval) are they set for?
Do they have different IDs?
How far away are the beacons?
I'm not saying you can rule out phone problems though, as the series of zeros seems odd.
Cheers,
Anders
guys
I'm using Altbeacon Android Library to do some Bluetooth app for demo. It provides with a getDistance() method that I can use to get distance between my phone and external Bluetooth device with Altbeacon protocol uploaded. However, as the devices are different, I think the distance might vary with a large error (I get 0.05m when I'm at 1m away, so on and so forth). This makes me think that if we do some calibration work for the getDistance() method will be useful. Is there any way of doing this? (Currently I have no idea how to modify the getDistance method, maybe #override it? Not very sure)
Many thanks.
I am not aware of any calibration functionality in the library. However, you can change distance calculation by implementing your own DistanceCalculator.
The default distance calculator is ModelSpecificDistanceCalculator and it set in the BeaconServices onCreate method (check this). So, simply creating your own version of the DistanceCalculator and set it after BeaconService is created can do what you want;
// after beacon service is created
DistanceCalculator customCalculator = ...;
Beacon.setDistanceCalculator(customCalculator);
However, you should now that device is also causes variation;
Each model may have a different Bluetooth chipset and antenna, and therefore may receive a different signal level when in the same position relative to a beacon. In order to address this, the library uses a different formula for calculating distance for different Android device models. Because not all devices have custom formulas built into the library, the library will fall back to the default device calculation for the Nexus 5 if no matching formula is found.
For more information about distance calculation, please visit AltBeacon - Distance Calculations page. This page also explains how distance calculation works as well as how you can contribute to enhance the library for device variation.
By the way, you can also check CurveFittedDistanceCalculator but this one requires you to give device specific coefficients (explained in this page). For more info about this, check its source code.