Does gravity sensor return right values if device is in motion? I thought that gravity sensor use accelerometer to recognize gravitation direction. Are these two sensors different piece of hardware?
Accelerometer sensors have the ability to alter obtained physical acceleration from motion or gravity into a voltage output. Accelerometers are widely used to measure inert acceleration due to gravity, the low-frequency module of the acceleration and the dynamic acceleration due to animal movement [36].
Strictly speaking, a g-sensor is an accelerometer. You might see some literature inaccurately refer to a g-sensor as a gyroscope; but when you dig deeper, you see that they're actually referring to an accelerometer after all.
Often an accelerometer can be used to measure the force of impact, or the vibration of a machine. These devices can help ensure your machinery is working correctly. Instead of measuring an absolute position, a velocity sensor uses a seismic device to measure changing positions over time.
A gravity sensor measures the direction and intensity of gravity. Using such data, you can check the relative direction of a device within a space. A linear accelerometer provides data on acceleration, excluding gravity.
The Gravity sensor is what Android calls a 'software sensor' and calculates its values using more than one hardware sensor.
The software Gravity sensor is only available if the device has a gyroscope. By combining accelerometer data with gyroscope data, the acceleration due to moving the device can be filtered out to leave the pure gravity signal. So yes, it will return the right value under motion.
Thus, the Gravity sensor gives a much better signal for device orientation than just the accelerometer on its own.
Combining sensor values is called sensor fusion and important for high quality measurement values.
The Android Documentation describes the Gravity Sensor.
Unfortunately, many Android devices lack a Gyroscope, and thus, will have no Gravity sensor either. This leaves you with a sub optimal signal from just the accelerometer alone, giving a lower quality user experience compared to Android devices with both sensors, and lower quality experience compared to iOS devices.
You can block installations on incompatible devices by using a Google Play requirement specification as follows:
<uses-feature android:name="android.hardware.sensor.gyroscope" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With