Compass Accuracy Dilemma

I need to create a compass for my application.

From reading the documentation, there seem to be two reasonable ways to do this:

  • Sensor.TYPE_ORIENTATION method: this is an easy way to do this. The problem is that this is not accurate. When I compare my reading with Snaptic Compass, it is about 10-15 years old, which is unacceptable for my purposes.
  • Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_MAGNETIC_FIELD and getRotationMatrix () in combination with the remapCoordinateSystem () and getOrientation () methods: the documentation says that this is "usually more accurate". The problem is that regardless of the delay that I register with the listener, the compass goes crazy even when the device is on a fixed surface.

Any suggestions to resolve this issue are welcome.

+5
source share
2 answers

It seems that mob1lejunkie already understood this, but just for future reference, let me mention that the problem here is magnetic declination (the difference between magnetic north and true north). You can try the NOAA online model to see what the difference is in your part of the world.

Android GeomagneticField, , . , , , , Sensor.TYPE_ORIENTATION, GeomagneticField.getDeclination().

+8

All Articles