1. Download our Official Android App: Forums for Android!

how to calculate the distance between two mobiles using bluetoth!!!

Discussion in 'Android Apps & Games' started by sheckoo90, Jun 3, 2011.

  1. sheckoo90

    sheckoo90 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Jun 3, 2011

    Jun 3, 2011
    1
    0
    5
    hello developers how are u /??
    am trying to calculate the distance between two android devices !!! using bluetoth....
    i have an idea ! but i don`t know if it can be done ...
    am thinking to send a request to the other device that using the same app
    and this device reply immediately ! then i will have the time of this operation ... but i need to know ! the speed of bluetoth ray .. do i can calculate the distance and i also know that it`s changes between devices ! because ! the bluetoth hardware ??

    any one can tell me how to do this???? using bluetoth !! between two mobiles using the same app.."my app"
     

    Advertisement

  2. wayrad

    wayrad Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,177
    Joined:
    May 12, 2010

    May 12, 2010
    1,177
    149
    163
    Female
    Long Island
    Erm...you do know that radio waves travel at the speed of light, right? There is no way you're going to be able to detect any differences in transmission time, using a cell phone, over the short distances involved in Bluetooth.
     
  3. A.Nonymous

    A.Nonymous Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    7,059
    Joined:
    Jun 7, 2010

    Jun 7, 2010
    7,059
    967
    213
    I just like it that the OP referred to it as a "bluetooth ray". That made me smile. :)

    Theoretically you could do this. In reality you can't because you have no idea how long it's going to take just for the other phone to respond to the ping. You also don't know how long it's going to take your phone to pick up that ping response once it's sent. At best you're going to get a rough estimate. Besides, the range for BT is about 15-20 feet isn't it? Can't you just estimate from eyeballing the other device?
     
  4. wayrad

    wayrad Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,177
    Joined:
    May 12, 2010

    May 12, 2010
    1,177
    149
    163
    Female
    Long Island
    I think we'd need slightly more accurate clocks than we have now, too...;)

    It's sort of like timing a speeding bullet by posting a guy with a megaphone down by the target.:D And giving the shooter an hourglass.
     
  5. A.Nonymous

    A.Nonymous Android Expert
    Rank:
    None
    Points:
    213
    Posts:
    7,059
    Joined:
    Jun 7, 2010

    Jun 7, 2010
    7,059
    967
    213
    I would think that you might be able to program a clock to constantly sync with an atomic clock somewhere and be accurate enough. From a purely technical standpoint, I think it MIGHT be possible. You would basically have to re-purpose both devices specifically for this task though. Practically, it's not realistic at all.
     
  6. Harry2

    Harry2 Android Expert
    Rank:
    None
    Points:
    323
    Posts:
    5,181
    Joined:
    Jun 3, 2010

    Jun 3, 2010
    5,181
    1,341
    323
    Black Forest
  7. wayrad

    wayrad Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,177
    Joined:
    May 12, 2010

    May 12, 2010
    1,177
    149
    163
    Female
    Long Island
    I think a cesium clock would be sufficiently precise (it would vibrate almost 9 times in the time required for a radio wave to travel 1 foot in a vacuum, if I'm calculating it right), but the sync would be the problem, and the phone end of things as you say. You would be syncing with the same old (relatively) imprecise phone clock, right? (Edited to add: Oops, I see you said "constantly" sync. That would be some 9 billion syncs per second to keep up with the clock. Not sure my DInc is up to that. ;))

    I'm pretty sure this could be done in a controlled laboratory setting with some fairly sophisticated equipment, but a cell phone is hopelessly inadequate for the job, and in a real-world situation there are going to be a lot of confounding factors (like the fact that radio waves are emitted in all directions, and bounce).
     
  8. janpetras

    janpetras Well-Known Member
    Rank:
    None
    Points:
    58
    Posts:
    146
    Joined:
    May 24, 2011

    May 24, 2011
    146
    10
    58
    ~/jan/
    I'll give you an easier way: distance yourself from your other device until the connection stops, that way, you'll know you went further than 10 meters.

    Problem solved.
     
  9. wayrad

    wayrad Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,177
    Joined:
    May 12, 2010

    May 12, 2010
    1,177
    149
    163
    Female
    Long Island
    Or else that there was a wall in the way. ;)


    P.S. Wasn't there an app that was supposed to measure distances by triangulation, using the camera and accelerometer? I seem to remember the reviews were not enthusiastic.
     
  10. basalt

    basalt Well-Known Member
    Rank:
    None
    Points:
    36
    Posts:
    108
    Joined:
    Mar 17, 2011

    Mar 17, 2011
    108
    2
    36
    Electron microscopist
    UK
    There is another way; if you assume that bluetooth is instant - ie over that distance the signal is recieved pretty much as soon as it's sent - you can use that to synchronise the two phones. Send an audible tone at the same time as the bluetooth sync signal and use the difference in time between the two to work out distance.

    If you want to really show off you could factor in altitude from the GPS and air pressure from a weather app to make it more accurate.

    Why you'd need to do it is beyond me
     
  11. RazzMaTazz

    RazzMaTazz Android Expert
    Rank:
    None
    Points:
    173
    Posts:
    1,391
    Joined:
    Jan 28, 2011

    Jan 28, 2011
    1,391
    497
    173
    Both devices would have to be syncrhonized to a VERY accurate (think Cesium) clock, and the sending device would have to precisely timestamp it's response, not from the time that it received the request or from the time that it processed the request, but from the time that the response hit the antenna. Then the receiving devic would have to do the calculation based on when the response hit its antenna, not from the time that the interrupt request received and/or processed. That just ain't gonna happen on a 1GHz cell phone. And it definitely ain't gonna happen as a generic app that works any Android phone.
     
  12. basalt

    basalt Well-Known Member
    Rank:
    None
    Points:
    36
    Posts:
    108
    Joined:
    Mar 17, 2011

    Mar 17, 2011
    108
    2
    36
    Electron microscopist
    UK
    As long as you know the two signals are sent at exactly the same time you don't need any time information from the first phone - kind of like counting after lightning but yes processing delays on the reciever would bugger it up and over 10meters it's probably too close.

    You could also display two white dots on the phone screen and measure the distance in pixels between them with the camera, as long as you know the model of phone you ought to be able to work out distance.
     

Share This Page

Loading...