Assume that I have 3 beacons in a horizontal line, I want to check the distance how far away from mid point, so I want to get the positive and negative value of the area. Which mean I want to declare the right or left position of the beacon, so I can estimate the point of current location of the beacon.
This is the something looking like the google map navigation, I want to show the pointer on the circle area with horizontal line, so before that I want to know how to get the positive or negative X-axis of the Ibeacon.
There are solutions to this problem. but they are complex and we'll beyond what can be answered with a simple code snippet in a StackOverflow answer.
The primary issue is that beacon signals are omnidirectional. So if you estimate based on the beacon's signal strength that you are 3 meters away, you have no idea which direction. For the 2D axis in your question, you do not know if you are left or right.
The second problem is that once you get beyond 1-3 m, the noise on the signal measurement gets quite high, making the error on the distance estimate high as well. This makes techniques like trilateration work poorly even at such moderate distances.
For 2D indoor location, the general solution is to use RSSI fingerprinting. This requires a training data set where a vector of relative signal levels of each beacon is recorded at each point on a 2D grid. (The same would work for a 1D line.) After training, this data set is used to find the location. Create a new vector for the relative signal levels of each beacon. Then search the training set for the closest vector match. That gives you your position.
You can look up a concept known as trilateration or multilateration. Given that you know the position of at least 3 beacons, positioned in such a way that they're separate but with signal overlaps, you can solve for an arbitrary point between those beacons.
So what your mobile app needs to do is :
1) Have knowledge of the position of each beacon.(e.g x,y) before hand. These positions can be arbitrary as long as they're consistently applied for all beacons in a coordinate system
2) Scan for each beacon's advertising data which should include that beacon's RSSI. You can use that to estimate the distance of each detected beacon from your phone.
3) Knowing the position of each beacon and the distance of your phone from each, you can compute the position of the phone relative to the beacons using a multilateration function. Plenty of libraries out there that can do this, something based on non-linear least squares algorithm can work.
I've done the above on some indoor nav apps, and the quality and accuracy depends highly on your beacon positioning. You need to ensure that in any area you want to cover that there are 3 to 4 beacons positioned nearby to provide decent RSSI readings.
Related
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.
For my project I need to estimate the distance between a Smartphone and a bluetooth module. The Estimation doesn't have to be very precise. I only need to determine the distance with a margin of error of about 50cm.
I did test the RSSI of two bluetooth modules at distance-steps of 10 cm. I measured the RSSI 5 times for each step and got the average of the 5 measurements. The averages are shown in the graph below:
The red and blue lines resemble the two Bluetooth modules. You can see that the results are not very linear. One of the reasons for this is interference, so i searched for ways to tackle the interference issue. Two ways i found are:
Signal Noise Ratio(SNR): Understanding ibeacon distancing
ratio of the iBeacon signal strength (rssi) over the calibrated transmitter power (txPower). The txPower is the known measured signal strength in rssi at 1 meter away: http://www.princeton.edu/~achaney/tmve/wiki100k/docs/Signal-to-noise_ratio.html
However i don't really understand how the above techniques would be used to get more accuracy. For SNR i need the Noise value, how do i even get the Noise value?
For ratio rssi/txPower, I can get the txPower by simply measuring the rssi at 1 meter from the module. So I know all the needed values. But I don't know what to do from here on out. How do i use these values to get a more accurate distance estimations?
Are there any other techniques i can use to improve accuracy?
You are running into the practical limitations on this technology. Getting estimation accuracy of +/- 50 cm may be possible under ideal conditions at short distances (under 2 meters) not at long distances of over 10 meters.
I wrote a longer blog post about the limits here: http://developer.radiusnetworks.com/2014/12/04/fundamentals-of-beacon-ranging.html
To answer your specific questions:
No, there is no practical way to know what part of a single RSSI measurement comes from signal and what part comes from noise. You can take an average over many samples, which partially removes noise if the transmitter and receiver are stationary over the sample interval.
The techniques you ask about do work to give you distance estimate, but they have the limitations of the technology described above.
I have an app that scans for a specific UUID that another phone is broadcasting and measures the signal strength between them and tells you whether you're getting closer or further away from them. I want to add an arrow for direction. I know you can use triangulation if you have 3 points but I want to get something somewhat accurate with 2 points.
Any algorithm or suggestion that would help?
My current idea (since for this app's use case one node will be relatively still) is to have some algorithm learning as you walk. Like if you get further away the arrow knows to disregard this direction and keep refining itself as you walk different directions.
I found a bunch of research papers on the topic but I'm not an electrical engineer so it's easy to get lost. Also I read this post and understand the many pitfalls How to measure distance between two iphone devices using bluetooth?
Thanks!
Such a solution is extremely convoluted.
Getting the direction of the signal requires far more data than normal app usage can provide. The user would have to slowly rotate the phone while taking many samples of all directions.
Getting the relative distance, as you said like "getting closer" or "going farther away" is kinda possible within a 12 meter range using the formula posted below. Above 12 meters it gets very buggy. But it's quite complex and requires you to use a moving average solution with a length that you consider adequate.
You can calculate the relation between RSSI and distance using the following formula:
RSSI = -(10*n*log10(d) + A)
In this case,
n = path loss exponent, since you don't want an exact distance, just a way to check if it's closer or further, you can use 2 as a value, I found this the most realistic one in most cases.
A = the measured RSSI value at 1 meter distance, you need to measure this in advance to do your calculations, but since this varies a lot, just use a value like -60dB. Also this one is about average in most situations.
So getting a crudely guessed distance in meters can be achieved by the formula:
distance = 10 ^ ((-RSSI - 60) / (10 * 2));
This isn't very exact but will be sufficient to tell you if it is closer/farther within a limited range.
Considering I have two smartphones, A and B. If I am holding smartphone A, is there a way to determine the location of B in relation to myself?
So if we had the situation of this image:
:
it would tell me B is at position (2, 1).
Inventive methods like using the strength of wifi signals to get position are more then welcomed. Could I also determine if there is a wall between the two phones?
As far as I understand, both Bluetooth and Wi-Fi signals move in a radial wave in all directions - so while you may be able to measure the distance between the two terminals, I doubt this would give you a correct reading, since it could either be on your "side" of the circular area or another one equidistant to the source of the signal.
While GPS may be the obvious solution since it provides exactly what you're looking for, I'm not sure if you're including this as an option. Once you get the two coordinate sets for the devices, it's a matter of calculating the offset (N/S and E/W) from device 1.
This makes me think on the accuracy given by GPS, which considering that you were including the tag Bluetooth in the question and since Bluetooth has a range of around 15-30 feet (type 2-3) and the GPS has an error margin of 25-35 feet, this may not be good either.
If you do manage to get a connection (Bluetooth) between the two devices, you'd already know your in that range, but not in what direction. You can get a signal strength measure from Android 2.1: How do I poll the RSSI value of an existing Bluetooth connection? but there-again I'm not sure as to how to detect in what direction the user is relative to you, just how close he is, in any direction. Hell the other device could be on top of you or under you and you'd get virtually the same reading as next to you given equal distances.
This is all on a "static" approach, meaning both devices are stationary. However if you measure that value and then take a step to your left and re-measure you can tell if you're closer or further away from the source, so with a little trial and error of one of the devices moving you could determine a relative position, this however may not be useful for you since you'd either need to tell the phone manually that you moved left and to re-measure or use something more complicated like monitoring the accelerometer of the phone which could tell in what direction the phone moved and map the strength of the signal.
Am I losing my mind? Probably.
No answer as far as I'm concerned for now, just thoughts. Depending on what the application will do, there may be other viable approaches. This is my brain-dump answer so hopefully someone else can read it and come up with a more elaborate answer instead of rumbling thoughts.
If the distance from A to B is more than a few metres, then if you can get the GPS location of both A & B, you can easily calculate distance and bearing between them using the Location.distanceTo() and Location.bearingTo() methods.
Depending on the physical environment, it is probable that two GPSs which are physically close together will be using the same satellites for calculation, and that the errors will be similar in both. So in some cases using GPS may work for small distances.
The android's distanceTo() and distanceBetween() function gives results when I reach the destination lat and lon. But I need to cover the case when latitude and longitude may not be changed (e.g. if I walk in the street with high buildings around, enter the building or walk short distance by taking more turns). For those conditions how to calculate distance in android?
When I was searching through stackoverflow others answers, I gone through here.
I tried the following answer. The code is good and fine but when I tried to calculate distance by that code everytime it gives a constant value even when I am not walking.
Please help me in calculating the distance between two points
When you enter the building you have GPS lat/long, but after that it will not change because there is no GPS coverage. So, question is how to handle such a case, having just last position. I would approach that interesting issue this way:
Use WiFi networks info for location as well (not just GPS).
Use sensors. You have orientation and accelerator sensors. I remember some phones having feature of number of steps counting (I had that on SonyEricsson without GPS).
Accelerator sensor may give you info if person is moving and help you to count the number of steps (you need to take some average step distance value estimate). You can easily conclude if person is in the elevator, and if he is going up or down, and roughly estimate number of floors.
Orientation sensor may give you info about direction of movement change (turning around the corner).
GSM signal strength based location. NeighboringCellInfo from android.telephony gives you information about RSSI (Received Signal Strength Indication) for cells around you, but for accurate calculation of the position (approx 50 m precision) based on triangulation you need exact position of Base stations (which you cannot get without support from the operator).
It is understood how inaccurate such estimation may be, but I see no other approach.
In any case, stuff for lots of fun exploring/developing.