Bluetooth LE RSSI for proximity detection iOS - iphone

I'll start with the question.
Is the BTLE RSSI a good way to indicate two devices proximity to each other or not? does it only work with small devices like fobs etc?
The Issue:
I am currently looking at making an app that will use BTLE and allow connections based on proximity. In this regard it is much like the demo app that apple show in the Advanced Core Bluetooth keynote (When two devices are almost touching they then connect).
As I understand it the proximity is determined based on the RSSI value when the central discovers the peripheral. When I try this however with two iPads the signal seems too strong for this it is also too inconsistent to have an accurate stab at the proximity as it doesn't show very much correlation to the devices proximity.
I have tried the Apple sample code and that is similar in that the devices don't have to be close at all for the information to pass from one to another.
If only there was a way to reduce the signal strength of the peripheral devices advertisement....
Thanks in advance for any help.

The experience of Matthew Griffin matches mine. However - when we can measure for a fair period of time two things have helped us calibrate this better.
We did have to wrap a simple (kalman) filter on the antenna orientation and the IMU to get a rough running commentary though - and this is not very CPU or battery light.
Using the IMU you get a fair idea of the distance/direction of travel - and if this is over a short period of time - we assume the other 'side' is stationary. This helps a lot to get a value for 'current' orientation and 'callibrate current environment noise.
Likewise - do the same for rotations/position changes.
We've found that in general a re-orientation of the device is a better way to get direction; and that distance is only reliable some up to some 30 to 600 seconds after a 'move' calibration' and only if the device is not too much rotated. And in practice once needs some 4-5 'other' devices; ideally not too mobile, to keep oneself dynamically calibrated.
However the converse is quite reliable - i.e. we know when not to measure. And the net result is that one can fairly well ascertain things like 'at the keyboard' and 'relocated'/moved away through a specific door/openning or direction. Likewise measuring a field by randomly dancing through the room; changing orientation a lot - does work well once the receiver antenna lobes got somewhat worked out after a stationary period.

You are entirely correct about RSSI jumping wildly and randomly. You should retrieve your RSSI values every two seconds (any faster and you get a bunch of errors). Throw out the RSSI values that are more than a ~-40 decibel spike and use an aggregate of the past values before you declare your approximate range to the user.
As for your following statement, you are in luck.
If only there was a way to reduce the signal strength of the
peripheral devices advertisement....
The service you are looking for is called the TX Power Service. Implementing this service on your peripheral will allow you to decrease the transmit power of the device. That way you can throttle down the range that the advertisement data is visible from. We unfortunately do not however, have access to this service on an iOS device. But if you are writing your own firmware for a BLE peripheral, this is the service you want.

I've spent the last week dealing strictly with RSSI, trying to use Wifi and Bluetooth LE sensors for location triangulation and for distance conversion.
Unfortunately, what I have found is that RSSI is just too finicky and unreliable to consistently use to determine distance. In theory, the RSSI and distance behave according to the inverse square law (double the distance, and the RSSI will go down a fixed number of decibels), but in practice the RSSI is affected by uncontrollable factors such as weather (dry weather allows RF fields to travel better) and obstacles (any metal objects or humans in the path from one sensor to another will cause attenuation, and any metal objects closely positioned by one of the sensors will cause gain in the signal strength).
There are ways to try to compensate for this. This paper is one of the best papers I read on how to get accurate results, but the bottom line is that is an unreliable method unless you just want a general idea of where the device is.

If I understand well, you are trying to implement similar functionality that to what seen in the WWDC demo and what apps like Bump implement. For that RSSI will be adequate. Test for appopriate threshold values (e.g. >-30) and you will be fine.

Related

Is there a way to know which direction one iPhone is from another?

Presume I have two+ iPhones connected to the same server.
Using the sensors built in the iPhone and any possible calculations based on their information, is there any way to tell which direction one phone is from another?
They would be in the same room, so the fluctuation of GPS would not work very well here.
I've tried to model two points on a graph using only their compass readings, but I do not think this will work alone. I could be wrong though.
You could setup a calibration phase in your program where you start each phone in an exact position, and then using the 6 axis motion continually calculate the exact current position (in all 6 axis). But the longer you run that calculation the further from true position you will be and eventually (given a long enough time) one phone could think it's in canada and the other in Mexico.
So It could work for short term spurts if you do a calibration every time you want to start.
There is also the possibility of bluetooth localization, but that would require at least 3 phones and the sharing of positional data between them. Or you could do wifi location, but that would require the same as the bluetooth.
Long story short if you want inches localization it's not going to happen. If you want yards localization it's possible, but not as usable.
As you already mentioned, GPS does not work very well when used inside buildings. Thus, it is not possible to get the direction, as you don't have two reliable positions.
Indoor localisation should be much easier with iOS7 and location beacons .. but this does not help much now.

distance between two iPhones without using GPS

Is there any way to find the distance between two iPhones without using GPS in iOS??
i am working on finding out the exact distance between two iPhones which are few feet away.
Any suggestion, tutorial/links would be appreciated.
Looking forward for reply...
You could create some sort of sonar type thing. Use bluetooth between the devices to "arrange" a date stamp and emit a sound from one of the devices at the exact time stamp.
On the second device listen for the sound and mark the timestamp that it comes in at.
Then you can work out how long it took to get from one to the other.
I don't know how accurate that would be though.
Or possibly easier would be to emit a sound from one device then when the second device picks it up it re-emits another sound.
Then the first device listens out for the reply and can find the distance between them in time.
The only thing that comes to mind is some sort of audio chirp that you could measure the latency between, but at a few feet apart, I don't know that you'd be able to get the two iPhones synchronized closely enough to be able to take an accurate measurement.
As long as there isn't too much noise, you could pair the devices using bluetooth and use the signal intensity as a measure of distance. This will probably require a lot of trial and error, but I think that without gps it might be your best choice.
You could also go for wifi triangulation if you had enough access points with known locations, but this might be even more inaccurate.

WiFi triangulation on the iPhone

Lets say you have a zoo and you want to create an app which shows you details on each animal whenever you are next to the cage. (just for the sake of this question ... GPS signals are not an option)
If there was a WiFi router next to each cage, are there any methods the iPhone app can use to work out that the phone is nearby? I guess this is WiFi triangulation.
Or are there other methods to do this kind of geolocation without GPS?
The iPhone can detect the intensity of the signal.. So it may be enough having a router inside each cage, with some calculated emission power.
However, if it gets crowded, mapping the routers and comparing intensities of different routers might work.
Nice idea =)
--hiring a guide might also do the job :D
The iPod touch actually uses this kind of triangulation to get the iPod's location, but it requires a lot of data mining and is a lot less precise than GPS.
You could try it though, in a smaller area (like a zoo) it imagine it would be possible: calculate the intensity of the signal from every router and estimate the distance from three of them according to signal strength.
Another option in this specific case would be to offer an app to scan a bar code at every cage and display the animal info.

Typical time and horizontalAccuracy of iPhone CLLocation in practice

I'm wondering if anybody has done thorough empirical testing of the iPhone's ability to find its location. Obviously the performance and accuracy will depend on the type of area one is in (urban vs suburban vs remote).
Just testing from the Simulator, I get a horizontalAccuracy of < 100 meters (98 meters) in a few seconds. I believe it is because it's using WiFi.
But, for user experience purposes, how fast would it be to get this kind of accuracy using EDGE or GPS (assuming both are available)? Does the timing vary in very dense urban areas vs suburban?
It would be great it there were some empirical results published on this so that apps could modify their user experience accordingly.
The simulator just sends one event with the coordinates of Apple's headquarters after a few minutes delay.
There is a difference in accuracy between models of iPhone, in whether "real" GPS, or wifi triangulation, or cell tower location are being used, as well as issues from sky coverage and the particular satellites in view when GPS is being used, as well as how long you wait.
In practice, the range I've seen is from infinite (or maybe the diameter of the planet) when I'm in an elevator (Faraday cage), to telling me when I walk from the front to the back of my car.

What are your CoreLocation best practices?

I am working on a CoreLocation based application which should show the position of the user on a map.
My current problem is, that the precision of CL is not very good.
I am testing the app in an urban environment, so i am walking through a the streets around our office and see how precise it is. The horizontalAccuracy is usually around 47m - 50m when i am walking, and updates occur randomly between every 10 seconds and 1 minute. The updated position can vary between almost accurate and 20 meters or more off my real position. When i stop and wait for a minute, the position will almost always be correct within a minute, and the precision may rise to 17m.
I have tested this with three iPhone (3G and 3GS) and one iPod Touch(which is less precise).
However, there is a difference in the final usage of the product: The target audience of our product will use it in a rural, open environment without any houses nearby.
Will this improve accuracy?
How accurate can the iPhone get at best in terms of horizontalAccuracy?
Are there any best practices, tips and tricks to improve the precision?
Your problem is not CL, but the urban environment. Buildings block view of the GPS satellites used to calculate location. The more satellites you can see the better the accuracy.
The iPod Touch doesn't have GPS capability and location based solely on WiFi signals it can detect and lookup in an online database. It will probably give poor or no location data when in a rural environment since it depends entirely on nearby WiFi signals.
For more info see:
iphone-gps-performance
iphone GPS Tips and Tricks
The absolute best accuracy you can expect is about 2.5m (8') without WAAS and with SA turned off. You won't get that in an urban environment though, you need a clear sky for that best case accuracy.