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

Decimal Conversion

Hi, I have just managed to successfully read ADC values and send as a service but they are in uint8 format. Is there an easy way to convert this to decimal within my adc handler? Thank you for any response.

Parents
  • Hi Kosidinma,

    I don't know if this answers your question or not, but I'll try. We make measurements from many different sensor types typically using an ADC to make the measurement. The "raw" ADC reading is what we store and report to our host SW. However we frequently need to display the measurement on an LCD as well so we have to convert it to a human readable value, typically floating point to achieve the needed precision. So we run the uint8/uint16 etc. value through a polynomial equation with floating point coefficients with the end result being a 32 bit floating point value which is then displayed on the LCD.

    You could do something similar and change your service to report a 4 byte value instead of a single byte. You may need to modify the size of the characteristic in your service to do that.

    John

  • Thanks for your contribution...so do you think its better converting on the master device instead of on the nrf51822 chip?? The master device is an android phone by the way.

Reply Children
No Data
Related