Android Question How to get compass working with GPS

Discussion in 'Android Questions' started by Scantech, Aug 13, 2019 at 1:29 AM.

  1. Scantech

    Scantech Well-Known Member Licensed User

    I am using Location1.Bearing to read the value and it is always 0. Tested with Samsung S6. Is there a way to get the compass direction?
     
  2. Scantech

    Scantech Well-Known Member Licensed User

    The signal was weak. I was indoor.
     
    emexes likes this.
  3. emexes

    emexes Well-Known Member Licensed User

    Plus you usually have to move a bit. GPS tells you which direction you are moving, not which direction you are facing. Usually it becomes valid when the GPS speed becomes valid too.

    If you need to know which direction you are facing, ie, the orientation of the phone, then the magnetometers will get you most of the way there, just don't go staking your life on the readings. I assume Android will translate the magnetic flux readings into a NSEW bearing, but I'd be (pleasantly) surprised if it took into account the magnetic declination of true/geographic vs magnetic north, which varies depending on where you are. Nearby ferrous objects (eg, car bodies, concrete steel reinforcement) and electromagnetic fields don't help.
     
    Scantech and José J. Aguilar like this.
  4. emexes

    emexes Well-Known Member Licensed User

    Once you do have a reasonably good directional fix, you could use the gyroscopes to keep ahold of that... except that gyroscopes don't seem to be common on Android phones. Phones that support VR should have them, Samsung seems to be good in that regard.
     
  5. emexes

    emexes Well-Known Member Licensed User

    upload_2019-8-13_20-34-1.png

    although I still suspect that BearingValid and SpeedValid follow each other closely, because they would both be derived by Doppler techniques, rather than the time-of-flight ranging used for calculating position.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Doppler is not related. It calculates the speed and bearing based on the changes in the position.

    X = V * T
     
  7. emexes

    emexes Well-Known Member Licensed User

    https://racelogic.support/01VBOX_Automotive/01General_Information/Knowledge_Base/How_Does_GPS_Work?

    There is a common misconception that speed measured via GPS is done so as a function of position against time. If this were the case, GPS velocity would be just about unusable, because GPS position relies on precise measurements of the distance from the receiver to the satellite, and therefore suffers from numerous effects - such as atmospheric interference - which delays the signal.

    Fortunately, velocity isn't measured like this: instead, the Doppler shift in the signals coming from the satellites is captured and this leads to an incredibly accurate measurement of speed.
     
    Last edited: Aug 13, 2019 at 12:23 PM
    inakigarm, klaus and Erel like this.
  8. Erel

    Erel Administrator Staff Member Licensed User

    Indeed :)

    I assumed that you were referring to the old Doppler based navigation systems that were available before GPS.

    I've learned something today.
     
  9. emexes

    emexes Well-Known Member Licensed User

    Well, that makes me a winner (I think) because I learned two things today:

    1/ Arduino ticks are indeed 1000 ms (at least, as measured on my ESP32's here) whereas I was pretty sure they were 1024 ms thanks to "decimal" system clock frequencies and binary division timers.

    2/ B4R stacks (still getting my head around those)
     
    Erel likes this.
  10. Erel

    Erel Administrator Staff Member Licensed User

  11. emexes

    emexes Well-Known Member Licensed User

    lol... and I'm going to quit while I'm ahead ;-)

    In my defence, the source of the list was not clear. But it would have bamboozled me even if it was, so: yep, it's a big day for education here.
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice