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

Float value nrfconnect mobile app

Hello Everyone,

I am new to nrf51822 (using S130). I made some custom service that accepts float numbers. This might be noob question: I want to send float values from nrfconnect android mobile app which accepts float value as Exponent and fraction. I followed this link: www.h-schmidt.net/.../IEEE754.html to get exponent and fraction but its not working.

Then I came across this link (github.com/.../32) which mentions that "BLE it is IEEE-11073 32-bit FLOAT standard used for sending Float values". Can anyone help me with how do I convert the float values? For example: If I want to send 0.402 and 0.09 from nrfconnect mobile app, what should be exponent and fraction.

Thanks,

Parents
  • Hi,

    When you write to a characteristic with the nRF-Connect android app, you have the option to select the data-type. Here you can select FLOAT 32, and this gives you the option to enter the exponent and fraction.

    The link to white paper for transcoding can be found here. Take a look at page 10 and page 11.

    Quote:

    Consider a temperature measurement of 36.4 degrees Celsius with precision of 0.1 degrees Celsius. The FLOAT-Type representation is a 32-bit value consisting of an exponent of an 8-bit signed integer followed by a mantissa of a 24-bit signed integer; here, the exponent is -1 (0xFF) and the mantissa is 364 (0x00016C). Therefore, the FLOAT-Type representation of 36.4 is 0xFF00016C.

  • Thank you for the reply, Sigurd. Referring the document mentioned in the Link, I calculated the exponent and mantissa for 0.405 as follows: 0.405= 405*10^-3 405=> 0x000195 -3=> 0xFD Therefore, the FLOAT-Type representation of 0.405 is 0xFD000195. Is this conversion correct? One more issue is in the nrf-Connect android app, if I select data-type as FLOAT 32, the app only allows to write numbers and doesn`t allows to write alphabets. How to write "FD" in the field of exponent? Am I missing something?

    Thanks

Reply
  • Thank you for the reply, Sigurd. Referring the document mentioned in the Link, I calculated the exponent and mantissa for 0.405 as follows: 0.405= 405*10^-3 405=> 0x000195 -3=> 0xFD Therefore, the FLOAT-Type representation of 0.405 is 0xFD000195. Is this conversion correct? One more issue is in the nrf-Connect android app, if I select data-type as FLOAT 32, the app only allows to write numbers and doesn`t allows to write alphabets. How to write "FD" in the field of exponent? Am I missing something?

    Thanks

Children
No Data
Related