SoFunction
Updated on 2025-04-09

11 types of sensors introduced by Android operating system

Android is a free and open source operating system based on Linux, mainly used on mobile devices such as smartphones and tablets, and is led and developed by Google and the Open Mobile Alliance. Next, through this article, I will introduce to you the 11 types of sensors introduced by the Android operating system.

In the Android 2.3 gingerbread system, Google provides 11 sensor supply layers for use.

#define SENSOR_TYPE_ACCELEROMETER 1 //Acceleration
#define SENSOR_TYPE_MAGNETIC_FIELD 2 //Magnetic force
#define SENSOR_TYPE_ORIENTATION 3 // Orientation
#define SENSOR_TYPE_GYROSCOPE 4 //Gyro
#define SENSOR_TYPE_LIGHT 5 //Light sensing
#define SENSOR_TYPE_PRESSURE 6 //Pressure
#define SENSOR_TYPE_TEMPERATURE 7 //Temperature
#define SENSOR_TYPE_PROXIMITY 8 //Close
#define SENSOR_TYPE_GRAVITY 9 //Gramma
#define SENSOR_TYPE_LINEAR_ACCELERATION 10//Linear acceleration
#define SENSOR_TYPE_ROTATION_VECTOR 11//Rotation vector

Let's look at these eleven sensors in turn

1 Acceleration sensor

The acceleration sensor is also called G-sensor, which returns the acceleration value of the three axes x, y and z axes.

This value contains the influence of gravity and is in m/s^2.

Place the phone flat on the desktop, the x-axis default is 0, the y-axis default is 0, and the z-axis default is 9.81.

Place your phone face down on the desktop with the z-axis of -9.81.

Tilt the phone to the left with the x-axis being positive.

Tilt the phone to the right with the x-axis negative value.

Tilt the phone upwards, with the y-axis negative.

Tilt the phone downward, with the y-axis being positive.

Acceleration sensors may be the most mature mems product, and there are many types of acceleration sensors on the market.

Common acceleration sensors used in mobile phones include BOSCH (Bosch) BMA series, AMK's 897X series, ST's LIS3X series, etc.

These sensors generally provide an acceleration measurement range of ±2G to ±16G, and are connected to the MCU using an I2C or SPI interface, and have a data accuracy of less than 16bit.

2 Magnetic sensor

The magnetic sensor is simply called M-sensor, which returns the ambient magnetic field data of the x, y and z axes.

The unit of this value is micro-Tesla, expressed in uT.

The unit can also be Gauss, 1Tesla=10000Gauss.

There is generally no independent magnetic sensor on the hardware, and the magnetic data is provided by the electronic compass sensor (E-compass).

The electronic compass sensor also provides the direction sensor data below.

3 Direction Sensor

The direction sensor is simply called O-sensor, which returns the angle data of the three axes, and the unit of the direction data is angle.

In order to obtain accurate angle data, E-compass needs to obtain the data of G-sensor.

After calculation, O-sensor data is produced, otherwise only horizontal angles can be obtained.

The direction sensor provides three data, namely azimuth, pitch and roll.

azimuth: Azimuth: Azimuth, the angle between the magnetic north pole and the Y axis when returning to horizontal, ranging from 0° to 360°.

0°=North, 90°=East, 180°=South, 270°=West.

pitch: The angle between the x-axis and the horizontal plane, ranging from -180° to 180°.

When the z-axis rotates to the y-axis, the angle is positive.

roll: The angle between the y-axis and the horizontal plane, which ranges from -90° to 90° due to historical reasons.

When the x-axis moves to the z-axis, the angle is positive.

The electronic compass needs to be calibrated before obtaining the correct data, and the 8-word calibration method is usually used.

The 8-word calibration method requires users to use the equipment that needs calibration to make 8-word shaking in the air.

In principle, try to make the normal direction of the device point to all 8 quadrants of the space as much as possible.

The electronic compass chips used in mobile phones include AKM's 897X series, ST's LSM series, Yamaha, etc.

Since the G-sensor data needs to be read and M-sensor and O-sensor data are calculated,

Therefore, manufacturers generally provide a backend daemon to complete the work, and the electronic compass algorithm is generally the company's private property rights.

4 Gyroscope sensor

The gyroscope sensor is called Gyro-sensor, which returns the angular acceleration data of the three axes x, y and z axes.

The unit of angular acceleration is radians/second.

According to the actual test of Nexus S mobile phone:

Rotate horizontally and counterclockwise, and the Z-axis is positive.

Rotate horizontally counterclockwise, and the z-axis is negative.

Rotate left, the y-axis is negative.

Rotate to the right, and the y-axis is positive.

Rotate upwards, the x-axis is negative.

Rotate downward, the x-axis is positive.

ST's L3G series gyroscope sensors are quite popular, and this sensor is used in iPhone4 and Google's Nexus S.

5 Light sensing sensor

The light sensing sensor detects the light intensity in real time. The unit of light intensity is lux, and its physical meaning is the luminous flux that is illuminated on a unit area.

The light sensing sensor is mainly used for the LCD automatic brightness function of the Android system.

The brightness of the LCD can be adjusted in real time according to the sampled light intensity value.

6 Pressure sensor

The pressure sensor returns the current pressure in the unit of hectopapascal (hPa).

7 Temperature sensor

The temperature sensor returns to the current temperature.

8 Proximity sensor

The proximity sensor detects the distance between an object and a mobile phone, in centimeters.

Some proximity sensors can only return to the far and near states.

Therefore, the proximity sensor returns the maximum distance to the far state and the maximum distance to the near state.

The proximity sensor can be used to automatically turn off the LCD screen when answering a call to save power.

Some chips integrate both proximity sensors and light sensors.

The following three sensors are the newly proposed sensor types by Android 2, and it is not clear which applications are used.

9 Gravity Sensor

Gravity sensor is referred to as GV-sensor for short and outputs gravity data.

On Earth, the gravity value is 9.8 and is in m/s^2.

The coordinate system is the same as the acceleration sensor.

When the device is reset, the output of the gravity sensor is the same as the acceleration sensor.

10 Linear Acceleration Sensor

Linear acceleration sensor is referred to as LA-sensor for short.

Linear acceleration sensors are data obtained by the acceleration sensor minus the impact of gravity.

The unit is m/s^2, and the coordinate system is the same as the acceleration sensor.

The calculation formulas for acceleration sensors, gravity sensors and linear acceleration sensors are as follows:

Acceleration = Gravity + Linear Acceleration

11 Rotating vector sensor

The rotary vector sensor is referred to as RV-sensor for short.

The rotation vector represents the direction of the device and is a data obtained by mixing the coordinate axis and angle.

RV-sensor outputs three data:

x*sin(theta/2)
y*sin(theta/2)
z*sin(theta/2)

sin(theta/2) is the order of magnitude of RV.

The direction of RV is the same as the direction of axis rotation.

The three values ​​of RV, and form a quadruple with cos(theta/2).

The data of RV has no units and uses the same coordinate system as the acceleration.

For example:

sensors_event_t.data[0] = x*sin(theta/2)
sensors_event_t.data[1] = y*sin(theta/2)
sensors_event_t.data[2] = z*sin(theta/2)
sensors_event_t.data[3] = cos(theta/2)

The numerical values ​​of GV, LA and RV cannot be directly given without physical sensors, and G-sensor, O-sensor and Gyro-sensor need to be calculated by algorithms.

Algorithms are generally private property rights of sensor companies.

The above are 11 types of sensors introduced by the Android operating system that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!