简体   繁体   中英

How to read temperature from Nokia Health Api?

When reading the temperature from the Nokia health API, I am getting the following readings. However, these are not correct. In the Nokia app, the readings in Celsius are as follows:

35C { value: 26918, type: 12, unit: -3 }

35.6C { value: 23569, type: 12, unit: -3 }

36.7C { value: 27398, type: 12, unit: -3 }

From what I could gather from the docs :

value is the value of the measure. This needs to be used in conjunction with the unit parameter to get the correct value.

type indicates the measure type. In this case, 12 means temperature

unit is the exponential multiplier which needs to be multiplied with the value field to get the actual value in SI units.

Formula:

actualValue = value * (10 ^ unit)

Breaking down one of your examples:

{ value: 26918, type: 12, unit: -3 }

Here type is 12 so it's temperature (consequently, we can assume the units to be Kelvin if the API returns in SI units)

so, actualValue = 26918 * (10 ^ -3) which is 26.918K

The docs don't explicitly mention what the temperature units are. I have assumed it to be Kelvin because that is the SI unit of temperature. Excerpt from docs:

Value

Value for the measure in SI units (kilogram, meters, etc.). Value should be multiplied by 10 to the power of "unit" (see below) to get the real value.

Unit

Power of ten the "value" parameter should be multiplied to to get the real value. Eg : value = 20 and unit=-1 means the value really is 2.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM