HRM Sensor Measurement Return Type Issue

Original Created Apr 14, 2016 | Regeneration Apr 22, 2026

According to the Tizen native application sensor API documentation (https://developer.tizen.org/development/guides/native-application/system/sensor), the HRM (Heart Rate Monitor) sensor measurement values should return as int type. However, when implementing the following code:

dlog_print(DLOG_INFO, TAG, "%d", event->values[0]);

The output values are not correct. Interestingly, when changing the format specifier to float type:

dlog_print(DLOG_INFO, TAG, "%f", event->values[0]);

The values are displayed correctly within the expected range (between Min and Max). This suggests that the HRM sensor documentation should be updated to specify float instead of int for the return type.

Problem Understanding

The issue occurs when trying to read HRM sensor values using the documented int type format specifier (%d), which produces incorrect readings. The values only display correctly when using a float type format specifier (%f).

Solution Methods

  1. Use float type format specifier (%f) when printing HRM sensor values
  2. Update your code to handle the values as floating-point numbers
  3. Be aware that this discrepancy exists in the current documentation

Code Examples

// Correct way to print HRM sensor values
dlog_print(DLOG_INFO, TAG, "Heart Rate: %f", event->values[0]);

// Alternative way to store the value
float heart_rate = event->values[0];
dlog_print(DLOG_INFO, TAG, "Heart Rate: %.1f", heart_rate);

Additional Tips

  • This behavior has been confirmed on both emulator and physical devices (like Gear S2)
  • While waiting for official documentation updates, always use float type for HRM sensor values
  • Consider checking for sensor availability and proper initialization before reading values

Customize your cookie preferences

You can enable or disable non-essential cookies. Essential cookies are always on to ensure the site works properly and to keep you signed in.

Necessary

These cookies are necessary for the website to function properly and cannot be switched off. They help with things like logging in and setting your privacy preferences.

Always on

Analytics

These cookies help us improve the site by tracking which pages are most popular and how visitors move around the site.

Enable analytics cookies
Public Forum Public Forum
Employees only. Please sign in with your company account.