Sensor
Tizen provides functions for receiving and managing sensor data.
The main features of the Sensor API include:
Note |
---|
Not all devices support all sensor types. For more information, see System Information. |
Sensor Handle
A device can have various physical sensors. Tizen supports the following sensor types:
- Accelerometer Sensor
- Gravity Sensor
- Linear Accelerometer Sensor
- Magnetic Sensor
- Rotation Vector Sensor
- Orientation Sensor
- Gyroscope Sensor
- Light Sensor
- Proximity Sensor
- Pressure Sensor
- Ultraviolet Sensor
- Temperature Sensor
- Humidity Sensor
- HRM Sensor
- HRM LED Green Sensor
- HRM LED IR Sensor
- HRM LED Red Sensor
The Sensor API enables your application to receive data from the device's internal sensors. The application can receive the sensor data only when the data is modified.
Note |
---|
Not all sensors are available on all devices. |
The Sensor API finds sensors, and monitors their availability. Key sensor features provided by the Sensor API include getting and setting the following:
- Sensor name
- Sensor vendor
- Sensor type
- Resolution
- Sensing interval
- Measurement range
Accelerometer Sensor
The accelerometer sensor measures changes in velocity. It can also be used to determine orientation. The accelerometer sensor measures the device's accelerometer vector in 3 axes relative to its body frame.
Note |
---|
An acceleration shift of 1g always exists due to gravity. You must compensate for the gravitational pull of the Earth to detect device movement by subtracting the gravity offset. If the device is at rest, or the device is falling and has reached terminal velocity, the sensor data reads 1g (the gravity offset) and tells you the direction of gravity. |
The accelerometer sensor provides 3 components of acceleration (X, Y, and Z), as the following figure illustrates.
Figure: Accelerometer sensor vector and axes
The accelerometer sensor outputs 4 values: 3 Cartesian axis values and a timestamp. The accelerometer sensor measures and returns axes values in "m/s2" (meters per second squared). When a device is accelerated in the ±X, ±Y, or ±Z direction, the corresponding output increases (+) or decreases (-).
The following table lists the measurement data that the accelerometer sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: X | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
values[1]: Y | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
values[2]: Z | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
The following table provides information about the accelerometer sensor output for a device at rest.
Position | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|
Diagram | ||||||
values[0]: X | 0g | 1g | 0g | -1g | 0g | 0g |
values[1]: Y | 1g | 0g | -1g | 0g | 0g | 0g |
values[2]: Z | 0g | 0g | 0g | 0g | 1g | -1g |
Axis up (down) | Y | X | -Y | -X | Z | -Z |
X-polarity | 0 | + | 0 | - | 0 | 0 |
Y-polarity | + | 0 | - | 0 | 0 | 0 |
Z-polarity | 0 | 0 | 0 | 0 | + | - |
Gravity Sensor
The gravity sensor is originated from the 3-axis acceleration sensor. It measures the vector components of gravity when the device is at rest or moving slowly. The gravity sensor can be used, for example, with game controls using tilting motion.
The gravity sensor provides 3 components of acceleration (X, Y, and Z), as the following figure illustrates.
Figure: Gravity sensor vector and axes
Gravity is a unit vector (scalar = 1). The gravity sensor outputs 4 values: 3 Cartesian axis values and a timestamp. The gravity sensor measures and returns axes values in "m/s2" (meters per second squared). When a device is accelerated in the ±X, ±Y, or ±Z direction, the corresponding output increases (+) or decreases (-).
Accelerometer changes generated by gravity are sensed in opposite directions.
The following table lists the measurement data that the gravity sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: X | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
values[1]: Y | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
values[2]: Z | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
Linear Accelerometer Sensor
The linear accelerometer sensor measures user-driven changes in velocity without considering the gravity value. It measures the device's accelerometer vector in 3 axes relative to its body frame. The linear accelerometer sensor is used to detect the dynamic movement of the device and analyze the user's motion profile.
The linear accelerometer sensor provides 3 components of acceleration (X, Y, and Z), as the following figure illustrates.
Figure: User-acceleration sensor vector and axes
The linear accelerometer sensor outputs 4 values: 3 Cartesian axis values and a timestamp. The linear accelerometer sensor measures and returns axes values in "m/s2" (meters per second squared). When a device is accelerated in the ±X, ±Y, or ±Z direction, the corresponding output increases (+) or decreases (-). The accelerometer output is shown in the same direction as the user-driven force.
Accelerometer changes generated by user-driven force are sensed in opposite directions.
The following table lists the measurement data that the linear accelerometer sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: X | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
values[1]: Y | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
values[2]: Z | float | Min. value = -19.6 Max. value = 19.6 |
m/s2 |
Magnetic Sensor
The magnetic sensor is a 3-axis electronic compass (sometimes referred to as a "magnetometer"). It can also be used in determining orientation. The magnetic sensor measures magnetic field strength and fluctuations, and splits the measurement into X, Y, and Z components. Note that the following factors can have an impact on the readings:
- The weather or the season of the year
- Your location on the planet
- Nearby, strong magnetic fields, such as magnets or electric coils
The following table lists the measurement data that the magnetic sensor provides.
Measurement | Type | Unit |
---|---|---|
Timestamp | long | Milliseconds |
values[0]: X | float | μT (micro Tesla) |
values[1]: Y | float | μT (micro Tesla) |
values[2]: Z | float | μT (micro Tesla) |
The magnetic sensor uses the body of the device as a fixed frame of reference. It also uses the 3-axis Cartesian space coordinate system, as the following figure illustrates.
Figure: Magnetic field vector and axes
Rotation Vector Sensor
The rotation vector sensor represents the orientation of the device as a combination of an angle and an axis, in which the device has rotated through a specific angle around an axis (x, y, or z).
The following table lists the measurement data that the rotation vector sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
Accuracy | sensor_data_accuracy_e | - | int |
values[0]: X | float | Min. value = -1 Max. value = 1 |
- |
values[1]: Y | float | Min. value = -1 Max. value = 1 |
- |
values[2]: Z | float | Min. value = -1 Max. value = 1 |
- |
values[3]: W | float | Min. value = -1 Max. value = 1 |
- |
Orientation Sensor
The orientation sensor combines the 3-axis accelerometer sensor and 3-axis magnetic sensor to determine the following angular positions:
- Azimuth
- Pitch
- Roll
The following table lists the measurement data that the orientation sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: Azimuth | float | Min. value = 0 Max. value = 360 |
Degrees (°) |
values[1]: Pitch | float | Min. value = -180 Max. value = 180 |
Degrees (°) |
values[2]: Roll | float | Min. value = -90 Max. value = 90 |
Degrees (°) |
The angular positions are measured using a fixed frame reference (XE, YE, ZE).
Figure: Angular positions and the fixed frame reference
Gyroscope Sensor
The gyroscope sensor detects angular velocity, which is calculated using the measurement data retrieved from a 3-axis gyroscope.
Figure: Gyroscope sensor vector and axes
The following table lists the measurement data that the gyroscope sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: X | float | Min. value = -573.0 Max. value = 573.0 |
Degrees/s (°/s) |
values[1]: Y | float | Min. value = -573.0 Max. value = 573.0 |
Degrees/s (°/s) |
values[2]: Z | float | Min. value = -573.0 Max. value = 573.0 |
Degrees/s (°/s) |
Light Sensor
The light sensor detects the brightness of ambient light. It can be used to measure the brightness level.
Use the light sensor to control the brightness of the screen. For example, if you are in a dark environment, the light sensor detects the brightness of the environment and increases the device screen backlight brightness level. In a brighter environment, the backlight brightness level is lowered to save battery power.
The following table lists the measurement data that the light sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: Level | float | Min. value = 0 Max. value = 45875 |
Lux |
Proximity Sensor
The proximity sensor detects the presence of nearby objects. It can be used to measure the distance between nearby objects and the device.
Use the proximity sensor to lock or unlock the device screen. For example, when the device user holds the device to their ear, the proximity sensor detects the user as an object, and automatically locks the device screen. When the user moves the device away from their ear to input data, the proximity sensor determines that there are no nearby objects, and unlocks the screen.
The following table lists the measurement data that the proximity sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: proximity | float | - | - |
Pressure Sensor
The pressure sensor measures pressure, typically the pressure of gases or liquids. Pressure is an expression of the force required to stop a fluid from expanding, and it is usually stated in terms of force per unit area. A pressure sensor usually acts as a transducer, generating a signal as a function of the pressure imposed. For the purposes of Tizen, the signal is electrical.
Measurement values are related to the sensor type.
The following table lists the measurement data that the pressure sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: pressure | float | Min. value = 260 Max. value = 1260 |
hPa |
Ultraviolet Sensor
The ultraviolet sensor measures the ultraviolet index.
The following table lists the measurement data that the ultraviolet sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: uv index | float | Min. value = 0 Max. value = 15 |
uv index |
Temperature Sensor
The temperature sensor measures the temperature, just like a thermometer.
The following table lists the measurement data that the temperature sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: temperature | float | Min. value = -30 Max. value = 100 |
℃ |
Humidity Sensor
The humidity sensor measures humidity.
The following table lists the measurement data that the humidity sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: humidity | float | 100 | % |
HRM Sensor
The HRM sensor measures the heart rate in beats per minute.
The following table lists the measurement data that the HRM sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: beats per minute | int | Min. value = 0 Max. value = 220 |
- |
HRM LED Green Sensor
The HRM LED green sensor measures the amount of green light that is reflected from a blood vessel.
The following table lists the measurement data that the HRM LED green sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: HRM green light | int | Min. value = 0 Max. value = 1081216 |
- |
HRM LED IR Sensor
The HRM LED IR sensor measures the amount of infrared light that is reflected from a blood vessel.
The following table lists the measurement data that the HRM LED IR sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: HRM IR light | int | Min. value = 0 Max. value = 1081216 |
- |
HRM LED Red Sensor
The HRM LED red sensor measures the amount of red light that is reflected from a blood vessel.
The following table lists the measurement data that the HRM LED red sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | long | - | Milliseconds |
values[0]: HRM red light | int | Min. value = 0 Max. value = 1081216 |
- |
Sensor Listener
The Sensor API detects sensors and monitors their availability. The key sensor listening features provided by the Sensor API include:
- Adding and removing sensor listeners
- Checking available sensors
- Getting sensor data
When running your application on the Emulator, you can use the Event Injector view to provide sensor data for the application.
You can add or remove sensor listeners at any time.
Listeners poll sensors for data and deliver the data to applications at predefined intervals. Applications can add multiple sensor listeners for the same sensor type, but the polling interval must be the same for each sensor listener and within the allowed interval range.