This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Questions on the temperature sensor tutorial (temp conversion and decimal numbers)

Hi all, i followed the tutorial "devzone.nordicsemi.com/.../" and did the challanges, however there is a detail i don't understand (totally newbie here!): the value of temperature that i read on the master control panel (phone app) is in hexadecimal and Fahrenheit (this is a supposion, it's right?), i tried to implement the conversion in Celsius by subtracting 32 and dividing 1.8, but what i read on the master control panel is " (0x) 00-00-51-07 ". Can you explain me why, and how to get the correct Celsius value and receive it in decimal (so a conversion from hex to decimal i guess?) on my control panel? Thanks in advance!

Parents
  • Hi

    The result of the sd_temp_get() function is the nRF5 die temperature in 0.25 degrees celsius as documented here. So to get the real temperature you would have to divide the value by 4. Then you can convert it to fahrenheit by multiplying the temperature by 1.8 and finally add 32.

    Bluetooth SIG has also defined a Temperature Measurement Characteristic with a standard way of representing the temperature. However, to make it simple and to show how to use vendor specific UUIDs I chose to do it differently and leave it up to the user to handle the conversion and representation.

    I should probably have made this clearer in the tutorial and I will try to get it updated.

  • No worries. Unfortunately the MCP for PC cannot show you the decimal value. It will only show you the hex string. What you can do is to look at the ble_app_hts example in the SDK (hts = Health Thermometer Service). In this example you will see how to represent a temperature value in compliance with the Bluetooth SIG defined temperature measurement characteristic. When you have a temperature characteristic configured correctly you can use MCP for Android or iPhone to see the decimal values. Just enable "Parse known characteristics" in the settings menu and MCP will format the numbers for you. Note that MCP for phones only parses the values for known Bluetooth SIG defined characteristics. So it won't, e.g., parse the custom values we use in the tutorial.

Reply
  • No worries. Unfortunately the MCP for PC cannot show you the decimal value. It will only show you the hex string. What you can do is to look at the ble_app_hts example in the SDK (hts = Health Thermometer Service). In this example you will see how to represent a temperature value in compliance with the Bluetooth SIG defined temperature measurement characteristic. When you have a temperature characteristic configured correctly you can use MCP for Android or iPhone to see the decimal values. Just enable "Parse known characteristics" in the settings menu and MCP will format the numbers for you. Note that MCP for phones only parses the values for known Bluetooth SIG defined characteristics. So it won't, e.g., parse the custom values we use in the tutorial.

Children
No Data
Related