I have been using a Samsung Galaxy S3 to work on an app that uses the barometer estimate the user's altitude. I use SensorManager.getAltitude(p0, p), and set p0 equal to the sea-level pressure reported at the nearest airport. I set p equal to the value returned by the barometer.
Unfortunately, the altitude returned is systematically 20 meters or so higher than what it actually is. I'm certain that the barometer is returning pressure values that are too low, so SensorManager.getAltitude is returning a higher altitude. I've even driven to an airport from which I have gotten the sea-level pressures and laid my phone level with the runway, to prove this point.
When checking the accuracy of the barometer (with the accuracy field of the SensorEvent), it returns a value of zero, which means "the sensor cannot be trusted" or "calibration is needed" (https://developer.android.com/reference/android/hardware/SensorManager.html#SENSOR_STATUS_UNRELIABLE).
Specifically, my questions are:
Is this normal? I don't have another device with a barometer, so I can't check. How does the phone determine it's sensor "cannot be trusted"?
Is there any way to calibrate the sensor? Ideally, I could check the accuracy of a user's barometer, and then calibrate it (assuming I knew how much the barometric values were off by).