Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measure distance to iBeacon from Android device

I am working on an app that has to measure the distance to an iBeacon. When a user is within a distance (1 meter) the user should be notified.

It is working fine on iOS but on Android I get various results. I am using the Estimote Android SDK (https://github.com/Estimote/Android-SDK) and Android 4.3.

Below is measurement from a Nexus 4 and a Nexus 5. The iBeacon is placed one meter away from the phone (the measurements are consistent with more samples):

Nexus 4:
08-25 11:39:04.788: : Major: 27485 Accuracy: 0.36351308115918884 Power: -74 Rssi: -67
08-25 11:39:05.880: : Major: 27485 Accuracy: 0.31923897946172497 Power: -74 Rssi: -66
08-25 11:39:06.911: : Major: 27485 Accuracy: 0.31923897946172497 Power: -74 Rssi: -66
08-25 11:39:07.962: : Major: 27485 Accuracy: 0.41856988869951295 Power: -74 Rssi: -68
08-25 11:39:09.003: : Major: 27485 Accuracy: 0.31923897946172497 Power: -74 Rssi: -66

Nexus 5:
08-25 11:35:31.443: : Major: 27485 Accuracy: 0.14058401218665711 Power: -74 Rssi: -61
08-25 11:35:32.483: : Major: 27485 Accuracy: 0.14058401218665711 Power: -74 Rssi: -61
08-25 11:35:33.513: : Major: 27485 Accuracy: 0.17333602268971005 Power: -74 Rssi: -62
08-25 11:35:34.553: : Major: 27485 Accuracy: 0.17333602268971005 Power: -74 Rssi: -62
08-25 11:35:35.593: : Major: 27485 Accuracy: 0.17333602268971005 Power: -74 Rssi: -62

As noted none of them is close to one meter. The Nexus 4 has the closest result with 0.42 meters. The Accuracy is taken from Utils.computeAccuracy in the Estimote SDK.

The big problem is that different devices gives different results. Most devices I tried (Nexus 4, Nexus 7, HTC One Mine) gives results similar to Nexus 4. However the Nexus 5 indicates to be much closer than other devices.

Is there a way to make all devices give (close to) similar results? Alternative a way to know how different devices measure (so an algorithm can compensate for different results)

Also has anyone found a way to enhance the sampling rate on Android Bluetooth LE?

I really would like to prevent using some calibration when the user starts up the app.

I have to use iBeacons (customer demand) but another Library could be an option if this would help solving the problem.

like image 334
D3vinno Avatar asked Aug 25 '14 09:08

D3vinno


2 Answers

The open source Android Beacon Library (the successor to the library mentioned by @tar contains a filter that keeps a 20 second running average of RSSI measurements, discarding the top and bottom 10 percent of samples. This gives a distance estimate that is quite stable, with the tradeoff that it lags in time as the user moves relative to the beacon. That said, it is similar to the behavior of iOS device estimates.

The other challenge with Android devices is that each model has a different Bluetooth antenna with a different gain. This means that the average received signal level on two different device models in the exact same position relative to a beacon will be different. I can confirm from my testing that the Nexus 4 and the Nexus 5 have very different antenna gains.

The formula in the Android Beacon Library is designed for the Nexus 5, but it is open source so you can customize the code for any device model you wish. To make a new formula for a different device, you need to take several 60 sec average RSSI measurements at various distances (0.5m, 1m, 2m, 3m,... 10m, 12m ... 20m) then do a best fit calculation.

The future plan for the open source library is to have a different formula built in for the most common device models, and key the distance formula used based on a device check. This is a lot of work, so if you can help volunteer, please tap on my photo to contact me!

like image 166
davidgyoung Avatar answered Oct 19 '22 08:10

davidgyoung


Well, for starters the distance is an estimation, and no SDK will give you consistent answers because the RSSI depends on so many factors that are out of its control. If you want some reading material, Shane Russell posted "A Semi-Technical Lowdown on Working with iBeacons".

Radius Networks used to have an open-source library for Android and iOS. You may be able to ask them nicely for it, although they took it down late this summer. Also, they seem to have made a replacement AltBeacon library that may suit your needs. Plus, being GitHub...that repo still contains all the code it used to, so feel free to look back through it and take what you need.

As for your concern that the measurements are so far from 1 meter, that may be due to the beacon being uncalibrated. Look at the documentation for your hardware and you will almost certainly find a way to input a calibration value. That value gets broadcast to anything listening so those devices can estimate the distance.

Note that some iBeacon devices have a configurable power level, so if you change that you will also need to recalibrate it.

like image 22
tar Avatar answered Oct 19 '22 08:10

tar