Want to improve this question? Update the question so it focuses on one problem only by edi开发者_运维问答ting this post.
Closed 2 years ago.
Improve this questionI'd like to do something in the following using bluetooth.
- Measure and display how far my iPhone is from another iPhone.
- Display direction of my iPhone.
For example,
I'd like to display something in the following on my iPhone application.
My iPhone is connected to another iPhone:Harry's iPhone.
In this case,
- Distance : 3m 45.3cm (Accuracy:milimeter)
- Direction : North East(one of 8 available directions)
Does anyone know how to do this?
Using bluetooth for localization is a very well known research field (ref.). The short answer is: you can't. Signal strength isn't a good indicator of distance between two connected bluetooth devices, because it is too much subject to environment condition (is there a person between the devices? How is the owner holding his/her device? Is there a wall? Are there any RF reflecting surfaces?). Using bluetooth you can at best obtain a distance resolution of few meters, but you can't calculate the direction, not even roughly.
You may obtain better results by using multiple bluetooth devices and triangulating the various signal strength, but even in this case it's hard to be more accurate than few meters in your estimates.
You could use sound and knowledge of speed sound to calculate the distance between the iphones.
In iOS7 Apple introduced iBeacons. This will give you the distance between 1 phone and another. It is simple to setup, check out the WWDC sample AirLocate.
You can't do this with bluetooth. You could meassure the distance between two BT devices by analysing the BT reception quality - but this will strongly differ in every new environment (e.g. simply a new room or in the open air). For direction: here is exactly the same problem, especially inside buildings. A lot of BT signal echos will make it almost impossible to receive useful direction data. There are ways to determine distance and directions via wireless connections (doesn't matter if BT, WLAN or ZigBee or something else) - not with standard customer devices, but with real-hitech laboratory equipment.
For direction, you would have to hold the phone away from you and spin in a circle allowing the phone to measure the increase/decrease in signal strength. Not sure how good the iPhone signal reception will be.
You could estimate the distance by looking at the signal receive strength. You will have to perform many tests, in different environments in order to get some half decent metrics to use within your app.
You can't do it against only one Bluetooth device, but you might with 2. Assuming the 2 remote devices are in static location (speakers), and you move your mobile (pun intended) Bluetooth device. You should be able to derive your angle based on speed of distance change from the 2 devices. Only problem is that the solution has 2 values, but that might be doable if you know which side of the plane you're on.
As what Giuseppe Cardone has mentioned, using the signal strength wont work. However, I would suggest requesting the location information of the other device (let's say that, you install an app on the other device that replies to location requests.). Once you get the location information from the other device you may compare it with your device's location and calculate the distance and the direction.
精彩评论