in the Android2.3gingerbread system, Google offers 11 layers of sensor supply.
#defineSENSOR_TYPE_ACCELEROMETER 1//acceleration #define Sensor_type_magnetic_field 2//magnetic Force # Definesensor_type_orientation 3//direction #define SENSOR_TYPE_GYROSCOPE 4//gyroscope #define Sensor_type_ Light 5//sensor #defineSENSOR_TYPE_PRESSURE 6//pressure #define SENSOR_TYPE_TEMPERATURE 7//Temperature 08 #define Sensor_type_proximity 8//close to #defineSENSOR_TYPE_GRAVITY 9//Gravity #define Sensor_type_ Linear_acceleration 10//linear acceleration one #defineSENSOR_TYPE_ROTATION_VECTOR 11//rotation vector
Let's look at these 11 sensors in turn.
1 Acceleration Sensor
The accelerometer is also called G-sensor, which returns the acceleration values for the X, y, and Z axes.
This value contains the effect of gravity, in units of m/s^2.
put your phone flat on the desktop, the x axis defaults to the 0,y axis default 0,z axis default 9.81.
Place your phone face down on the desktop with a z axis of-9.81.
tilt the phone to the left and the x -axis as positive.
tilt the phone to the right and negative x -axis.
tilt the phone upward and the y -axis is negative.
tilt the phone downward and the Y -axis is positive.
The accelerometer is probably the most sophisticated MEMS product, with a wide range of accelerometer sensors on the market.
the commonly used accelerometer in mobile phones isBosch's BMA series, AMK 897X series, St's LIS3X series, etc.
These sensors typically provide an acceleration measurement range from ±2g to ±16g with an I²C or SPI interface connected to the MCU with a data accuracy of less than 16bit.
2 Magnetic Sensors
The magnetic sensor is referred to as M-sensorand returns the environmental magnetic field data of the X, y, and Z axes.
the unit of the value is micro-Tesla (Micro-tesla), expressed in UT.
The unit can also be Gauss (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 direction sensor data for the following.
3 Direction Sensor
The Direction sensor is abbreviated as O-sensor, which returns the angle data of the three axes, and the unit of the direction data is the angle.
to get accurate angular data, e-compass needs to get g-sensor data,
The production o-sensor data is calculated, otherwise only the horizontal angle can be obtained.
The direction sensor provides three data, azimuth, pitch, and roll respectively.
Azimuth : Azimuth, returns the angle of the magnetic north and Y axes at a horizontal range of 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 toward the y axis, the angle is positive.
Roll : The angle between the y-axis and the horizontal plane, for historical reasons, the range is -90° to 90°.
When the x -axis moves toward the z-axis, the angle is positive.
The electronic compass needs to be calibrated before it can get the correct data, usually with a 8-word calibration method.
8 The Word calibration method requires the user to make 8-word shaking in the air using a device that needs to be calibrated.
in principle, as much as possible, the device normal direction points to all 8 quadrants of space .
the electronic compass chip used in the mobile phone has the AKM Company's 897X series, St company's LSM series as well as Yamaha company and so on.
because of the need to read G-sensor data and calculate m-sensor and o-sensor data,
so vendors will generally provide a background daemon to complete the work, electronic compass algorithm is generally the company's private property rights.
4 Gyro Sensor
The gyroscope sensor is called Gyro-sensorand returns the angular acceleration data for the X, y, and Z axes.
the unit of angular acceleration is radians/second.
Measured by Nexus S Mobile:
rotate horizontally counterclockwise and the Z axis is positive.
the horizontal counterclockwise rotation, the z axis is negative.
rotate to the left and negative on the y axis.
rotates to the right and the Y -axis is positive.
rotate up and the x axis is negative.
rotate downward and the x axis is positive.
ST The l3g series of gyroscope sensors are popular, iphone4 and Google's Nexuss use this kind of sensor.
5 Light Sensing sensor
The light sensor detects real-time light intensity, the unit of light is Lux, and its physical meaning is luminous flux on the unit area.
The light sensor is mainly used for the LCD auto-brightness function of Android system.
The brightness of the LCD can be adjusted in real time according to the light intensity sampled .
6 Pressure sensor
The pressure sensor returns the current pressure in the unit of Hectopascal(hPa).
7 Temperature Sensor
The temperature sensor returns the current temperature.
8 Proximity Sensor
The proximity sensor detects the distance between the object and the phone, in centimeters.
Some proximity sensors can only return far and near two states,
Therefore, the proximity sensor returns the maximum distance to the far state, which is less than the maximum distance to return to the near state.
proximity sensors can be used to automatically turn off the LCD screen when answering a phone to conserve power.
Some chips have integrated proximity sensors and light sensors for both functions.
The following three sensors are the new sensor types proposed by ANDROID2, and it is not yet clear which applications are available.
9 Gravity sensor
The gravity sensor is referredto as gv-sensor and outputs gravity data.
On Earth, the value of gravity is 9.8, and the unit is m/s^2.
The coordinate system is the same as the accelerometer sensor.
When the device is reset, the output of the gravity sensor is the same as the accelerometer sensor.
Ten Linear acceleration Sensor
linear Accelerometer is referredto as la-sensor.
The linear accelerometer is the data obtained by the acceleration sensor minus the gravity effect.
The unit is m/s^2and the coordinate system is the same as the accelerometer sensor.
The formula for acceleration sensors, gravity sensors and linear accelerometer is as follows:
acceleration = gravity + linear acceleration
One rotational vector Sensors
rotary vector sensor for short rv-sensor.
The rotation vector represents the direction of the device, which is a mix of axes and angles to calculate the data.
Rv-sensor output of three data:
X*sin (THETA/2)
Y*sin (THETA/2)
Z*sin (THETA/2)
sin (THETA/2) is the order of the RV.
RV is in the same direction as the Axis rotation.
RV three values, and the cos (THETA/2) form a four-tuple.
RV The data has no units, and the coordinate system used is the same as acceleration.
Example:
1sensors_event_t.data[0]= x*sin (THETA/2)2sensors_event_t.data[1] =y*sin (THETA/2)3 SENSORS_EVENT_T.DATA[2] =z*sin (THETA/2)4sensors_event_t.data[3]=cos (THETA/2)
GV , LA and RV values no physical sensors can be given directly,
G-sensor, O-sensor, and Gyro-sensor are required to becalculated by the algorithm.
The algorithm is usually the private property of the sensor company.
Reference:
1. Android Source Codehardware\libhardware\include\hardwaresensor.h
2. http://www.dzsc.com/data/html/2010-11-29/87454.html
How to use common sensors in Android 11