Sensor
Tizen provides functions for managing sensors and receiving sensor data.
The main features of the Sensor API include:
Note |
---|
All devices may not support all sensor types. For more information, see System Information. |
Sensor Handle
A device can have various physical and virtual sensors. Tizen supports the following sensor types:
- Accelerometer
- Gravity Sensor
- Linear Acceleration Sensor
- Magnetic Sensor
- Uncalibrated Magnetic Sensor
- Rotation Vector Sensor
- Gyroscope Rotation Vector Sensor
- Geomagnetic Rotation Vector Sensor
- Orientation Sensor
- Gyroscope
- Uncalibrated Gyroscope
- Light Sensor
- Proximity Sensor
- Pressure Sensor
- Ultraviolet Sensor
- Temperature Sensor
- Humidity Sensor
- Heart Rate Monitor Sensor
- Heart Rate Monitor LED Green Sensor
- Heart Rate Monitor LED IR Sensor
- Heart Rate Monitor 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 |
---|
All sensors may not be 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
The accelerometer measures changes in the velocity of a device. It is a combination of gravity and linear acceleration components. The accelerometer measures the device's accelerometer vector in 3 axes relative to its body frame.
An acceleration shift of 1g always exists on the axis aligned to Earth's gravity. If the device is at rest, the sensor data reads 1g (the gravity offset) on one of the device axis and tells you which device axis is aligned to the direction of gravity. A falling device which has reached terminal velocity ideally shows the accelerometer value of 0 on all axis. The change in the effect of Earth's gravity is observed on the 3 device axes by rotating the device along any of the 3 axes.
The linear acceleration components which correspond to the measure of the linear motion subjected on the device can be obtained by removing the gravity components from the accelerometer data.
The accelerometer provides 3 components of acceleration (X, Y, and Z), as the following figure illustrates.
Figure: Accelerometer vector and axes
The accelerometer 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 moved in the ±X, ±Y, or ±Z direction, the corresponding output increases (+) or decreases (-).
The following table lists the measurement data that the accelerometer provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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 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 a virtual sensor derived from the 3-axis acceleration sensor. The 3-axis gravity components provide a measure of the effect of Earth's gravity observed on the device reference axes. The gravity components measured on a device vary based on the change in the device orientation, and hence they provide a measure of the rotation subjected to the device.
Figure: Gravity sensor vector and axes
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 rotated in the ±X, ±Y, or ±Z direction, the corresponding output increases (+) or decreases (-).
The following table lists the measurement data that the gravity sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: X | float | Min. value = -9.8 Max. value = 9.8 |
m/s2 |
values[1]: Y | float | Min. value = -9.8 Max. value = 9.8 |
m/s2 |
values[2]: Z | float | Min. value = -9.8 Max. value = 9.8 |
m/s2 |
Linear Acceleration Sensor
The linear acceleration sensor is derived from the accelerometer by excluding the gravity value, and it measures the user-driven changes in the velocity. The linear acceleration sensor is used to detect the dynamic movement of the device and analyze the user's motion profile. The 3-axes linear acceleration components provide a measure of the combined linear motion subjected to the device in the euclidean space.
The linear acceleration sensor provides 3 components of acceleration (X, Y, and Z), as the following figure illustrates.
Figure: User-acceleration sensor vector and axes
The linear acceleration sensor outputs 4 values: 3 Cartesian axis values and a timestamp. The linear acceleration 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 acceleration output is shown in the same direction as the user-driven force.
The following table lists the measurement data that the linear acceleration sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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" or "geomagnetic sensor"). It can also be used in determining the azimuth component of the device orientation provided that the tilt of the device is already computed. The magnetic sensor measures the Earth's magnetic field strength and fluctuations, and splits the measurement into X, Y, and Z components.
The following factors can have an impact on the sensor readings:
- The weather or the season of the year
- Your location on the planet
- Nearby, strong magnetic fields, such as magnets, electric coils, or objects which contain a ferrite element
The following table lists the measurement data that the magnetic sensor provides.
Measurement | Type | Unit |
---|---|---|
Timestamp | unsigned long long | Nanoseconds |
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 3-axis Cartesian space coordinate system, as the following figure illustrates.
Figure: Magnetic field vector and axes
Uncalibrated Magnetic Sensor
The uncalibrated magnetic sensor is a 3-axis electronic compass (sometimes referred to as a "magnetometer" or "geomagnetic sensor"). It can also be used in determining the azimuth component of the device orientation provided that the tilt of the device is already computed. It measures the Earth's magnetic field strength and fluctuations, and splits the measurement into X, Y, and Z components. The uncalibrated magnetic sensor is similar in functionality to a magnetic sensor, but does not perform hard iron calibration. Factory calibration and temperature compensation are applied.
The following factors can have an impact on the sensor readings:
- The weather or the season of the year
- Your location on the planet
- Nearby, strong magnetic fields, such as magnets, electric coils, or objects which contain a ferrite element
The following table lists the measurement data that the uncalibrated magnetic sensor provides.
Measurement | Type | Unit |
---|---|---|
Timestamp | unsigned long long | Nanoseconds |
values[0]: X | float | μT (micro Tesla) |
values[1]: Y | float | μT (micro Tesla) |
values[2]: Z | float | μT (micro Tesla) |
values[3]: X-axis bias | float | μT (micro Tesla) |
values[4]: Y-axis bias | float | μT (micro Tesla) |
values[5]: Z-axis bias | float | μT (micro Tesla) |
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 rotation vector is the output of a software/hardware-based sensor fusion solution, which uses the accelerometer, gyroscope, and magnetic sensor as inputs to compute the orientation of the device.
The following table lists the measurement data that the rotation vector sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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 |
- |
Gyroscope Rotation Vector Sensor
The gyroscope rotation vector sensor is the output of a software/hardware-based sensor fusion solution which uses the accelerometer and gyroscope to compute the orientation of the device. In this sensor, the pitch and roll equivalent representations are free of drift while the azimuth equivalent component is allowed to drift due to the absence of the magnetic sensor. The gyroscope 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 gyroscope rotation vector sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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 |
- |
Geomagnetic Rotation Vector Sensor
The geomagnetic rotation vector sensor is the output of a software/hardware-based sensor fusion solution which uses the accelerometer and magnetic sensors to compute the orientation of the device. In this sensor, the computed orientation is free of any drift, but it is inaccurate compared to a sensor fusion solution using the gyroscope sensor. The geomagnetic 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 geomagnetic rotation vector sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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, 3-axis magnetic sensor, and 3-axis gyroscope to determine the orientation (rotation angles) of the device. The orientation is the output of a software/hardware-based sensor fusion solution which uses the accelerometer, magnetic sensor, and gyroscope. The orientation sensor output is an alternative representation to the rotation vector sensor output used to determine the rotation of the device, and it is calculated in terms of Euler angles:
- Azimuth
- Pitch
- Roll
The following table lists the measurement data that the orientation sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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
The gyroscope detects angular velocity or angular rates of a device. The 3D gyroscope data is considered to be very sensitive in detecting incremental rotation angles. The rotation angles obtained by integrating the angular rates over longer duration is inaccurate due to the build-up of drift.
Figure: Gyroscope vector and axes
The following table lists the measurement data that the gyroscope provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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) |
Uncalibrated Gyroscope
The uncalibrated gyroscope detects angular velocity or angular rates of a device. The 3D uncalibrated gyroscope sensor is considered to be very sensitive in detecting incremental rotation angles. The rotation angles obtained by integrating the angular rates over longer duration is inaccurate due to the build-up of drift. The uncalibrated gyroscope data also consists of drift compensation values for each axis, which can be used to subtract the drift from the detected angular rates. The values of drift for the 3 axes are obtained from the output of a software/hardware-based sensor fusion solution.
The following table lists the measurement data that the uncalibrated gyroscope provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
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) |
values[3]: Drift around the X axis | float | Min. value = -573.0 Max. value = 573.0 |
Degrees/s (°/s) |
values[4]: Drift around the Y axis | float | Min. value = -573.0 Max. value = 573.0 |
Degrees/s (°/s) |
values[5]: Drift around the Z axis | 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.
As an example use case, the light sensor can be used to control the brightness of the screen. In a dark environment, the light sensor detects the brightness of the environment and can be used to increase 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 | unsigned long long | - | Nanoseconds |
values[0]: Level | float | Min. value = 0 Max. value = 45875 |
Lux |
Proximity Sensor
The proximity sensor detects the presence of nearby objects in close proximity to the sensor. It can be used to measure the distance between nearby objects and the device.
As an example use case, the proximity sensor can be used to lock or unlock the device screen. 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 | unsigned long long | - | Nanoseconds |
values[0]: proximity | float | - | - |
Pressure Sensor
The pressure sensor measures the atmospheric pressure in the device's surrounding environment.
The following table lists the measurement data that the pressure sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: pressure | float | Min. value = 260 Max. value = 1260 |
hPa |
Ultraviolet Sensor
The ultraviolet (UV) sensor measures the ultraviolet index. The sensor detects and provides a measure of the UV rays being exposed to the device.
The following table lists the measurement data that the ultraviolet sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: uv index | float | Min. value = 0 Max. value = 15 |
uv index |
Temperature Sensor
The temperature sensor measures the ambient room temperature in the device's surrounding environment.
The following table lists the measurement data that the temperature sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: temperature | float | Min. value = -30 Max. value = 100 |
℃ |
Humidity Sensor
The humidity sensor measures the relative ambient air humidity in percentage.
The following table lists the measurement data that the humidity sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: humidity | float | 100 | % |
Heart Rate Monitor Sensor
The Heart Rate Monitor (HRM) sensor measures a person's heart rate in real time.
The following table lists the measurement data that the HRM sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: Beats per minute | int | Min. value = 0 Max. value = 240 |
- |
Heart Rate Monitor LED Green Sensor
The Heart Rate Monitor (HRM) LED green sensor measures the amount of green light that is reflected back from a person's blood vessel.
The following table lists the measurement data that the HRM LED green sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: HRM green light value | int | Min. value = 0 Max. value = 1081216 |
- |
Heart Rate Monitor LED IR Sensor
The Heart Rate Monitor (HRM) LED infrared (IR) sensor measures the amount of infrared light that is reflected back from a person's blood vessel.
The following table lists the measurement data that the HRM LED IR sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: HRM IR light value | int | Min. value = 0 Max. value = 1081216 |
- |
Heart Rate Monitor LED Red Sensor
The Heart Rate Monitor (HRM) LED red sensor measures the amount of red light that is reflected back from a person's blood vessel.
The following table lists the measurement data that the HRM LED red sensor provides.
Measurement | Type | Range | Unit |
---|---|---|---|
Timestamp | unsigned long long | - | Nanoseconds |
values[0]: HRM red light value | 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 an application on the Emulator, you can use the Event Injector view to provide sensor data for the application.
Sensor listeners can be added or removed at any time. Listeners receive registered sensor events and deliver the event data to applications at predefined intervals. The applications can add multiple sensor listeners for the same sensor type.