android eleven sensors

Let's take a look at these eleven sensors in turn

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

1 acceleration sensor The

acceleration sensor is also called G-sensor , returns the acceleration values ​​of the x, y, and z axes.

This value includes the effect of gravity, in m/s^2.

Lay the phone flat on the desktop, the x-axis defaults to 0, the y-axis defaults to 0, and the z-axis defaults to 9.81.

Place the phone face down on the table with a z-axis of -9.81.

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

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

Tilt the phone up with a negative y-axis.

Tilt the phone down with a positive y-axis.



The accelerometer is probably the most mature mems product, and there are many types of accelerometers on the market.

Commonly used acceleration sensors 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 I2C or SPI interfaces, and the data accuracy is less than 16bit.



2 Magnetic sensor The

magnetic sensor is referred to as M-sensor for short, and returns the environmental magnetic field data of the x, y, and z axes.

The unit of this 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 the orientation sensor data below.



3 Orientation sensor

Orientation sensor is referred to as O-sensor, which returns the angle data of three axes, and the unit of orientation data is angle.

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

produce O-sensor data after calculation, otherwise, only the angle in the horizontal direction can be obtained.

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

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 is turned on the y-axis, the angle is positive.

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

The angle is a positive value when the x-axis is moved along the z-axis.



The electronic compass needs to be calibrated before obtaining correct data, usually using the figure-of-eight calibration method.

The figure-8 calibration method requires the user to use the device to be calibrated to do figure-8 shaking in the air. In

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



Electronic compass chips used in mobile phones include AKM's 897X series, ST's LSM series, and Yamaha's and so on.

Since it is necessary to read G-sensor data and calculate M-sensor and O-sensor data,

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



4 gyroscope sensor

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

The unit of angular acceleration is radians/second.

According to the actual measurement of the Nexus S mobile phone:

the horizontal rotation is counterclockwise, and the Z axis is positive.

Rotate horizontally counter-clockwise, the z-axis is negative.

Rotate to the left, the y-axis is negative.

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

Rotate up, the x-axis is negative.

Rotate down, the x-axis is positive.



The gyroscope sensor of ST's L3G series is more popular, which is used in iphone4 and google's nexus s.



5 Light Sensing Sensor The

light sensing sensor detects the real-time light intensity, the unit of light intensity is lux, and its physical meaning is the luminous flux irradiated 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 hectopascal (hPa).



7 Temperature sensor The

temperature sensor returns the current temperature.



8 Proximity sensor The

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

Some proximity sensors can only return far and near states,

so a proximity sensor returns a far state for a maximum distance and a near state for less than the maximum distance.

Proximity sensors can be used to automatically turn off the LCD screen when answering a call to save power.

Some chips integrate both proximity sensor and light sensor functions.





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

9 Gravity sensor

Gravity sensor, referred to as GV-sensor, outputs gravity data.

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

The coordinate system is the same as the accelerometer.

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.

Linear accelerometers are data obtained by subtracting the influence of gravity from an accelerometer.

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

The calculation formula of acceleration sensor, gravity sensor and linear acceleration sensor is as follows:

acceleration = gravity + linear acceleration



11 Rotation vector sensor

Rotation vector sensor is referred to as RV-sensor.

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

The 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 the RV is the same as the direction of the shaft rotation.

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

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

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 values ​​of GV, LA, and RV can be given directly without physical sensors, and

they need to be calculated by G-sensor, O-sensor and Gyro-sensor through an algorithm.

Algorithms are generally the private property of sensor companies.

From: http://www.oschina.net/question/163910_28354

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326565772&siteId=291194637