Sensor Topic (4) - Learn about other sensors


Introduction to this section:

As mentioned at the end of the previous section, since the author has not played much with the sensor part, this section will simply list the remaining commonly used ones. The sensor is introduced once, as a popular science, and we will study it slowly after using it~

1. Magnetic field sensor(Magnetic field sensor)

Function: This sensor is mainly used for Read the magnetic field changes near the mobile phone

The values ​​collected by the sensor: There are three, namely: the magnetic field values ​​​​in the directions on the X, Y, and Z axes

Value unit: T, Micro Tesla

Sensor acquisition: Sensor.TYPE_MAGNETIC_FIELD


2 .Proximity sensor

Function: Used to sense the distance between the mobile phone and the human body. It is most commonly used when talking on the mobile phone and when the face is close to the screen. The screen will turn off, and when the face is a certain distance away from the screen, the screen will light up again. This can avoid accidental touching of the face during the process. Hang up button, causing the call to be interrupted~We can use this sensor to make some interactive apps~

The value of the sensor The value collected: There is one, between the object and the device Distance

Value unit: cm, centimeter

Sensor acquisition: Sensor.TYPE_PROXIMITY

Others:

  • ①There may be two types of distance sensors, one can directly give the distance, and the other can give closeness or distance! It just returns two values, 0.0 or the maximum value! We can judge by comparing the resolution and the maximum value to see if they are equal! If they are equal, it means the latter; if they are not equal, it means the former!

  • ②Call the sensor.getResolution() method to get the resolution, and call getMaximumRange() to get the maximum value!


3. Light sensor

Function: Used to read the photometric value, that is, the light intensity

Sensor value collected value: There is one, brightness value

Value unit: lux, 1 lumen per square meter of area, which is 1 lux (lux), the maximum value is: 120000.0f, Android The light intensity is divided into different levels. You can check the SensorManager class by yourself~

Sensor acquisition: Sensor.TYPE_LIGHT


4 .Pressure sensor

Function: Used to measure atmospheric pressure, often used to measure altitude

The value of the sensor is the value collected: There is one, atmospheric pressure value

Value unit : hPa, hectopascal

Sensor acquisition : Sensor.TYPE_PRESSURE


5. Temperature sensor(Temperature sensor)

Function: Measure the temperature inside the mobile phone or the external environment

Sensor value collected value : There is one, temperature value

Value unit : ℃, degrees Celsius

Sensor acquisition: Sensor.TYPE_TEMPERATURE(inside the phone)/TYPE_AMBIENT_TEMPERATURE(outside the phone)


6. Sensor simulation Tool - SensorSimulator

As the title says, when our real machine does not have a certain sensor, but needs to be developed ~ For specific usage, please see the following article: Sensor simulation tool on Android devices: SensorSimulator


Summary of this section:

Okay, this section should be the most useless section in the basic introductory series. I didn’t want to write it originally. But let’s write it down, It’s good to know the above things ~ It’s still the same sentence, I will use it in the future and study it in depth ~ Thank you