Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Is there a mismatch between GATT Specification Supplement and nRF Mesh for Android app for Generic Sensor Property IDs?

Hi,

I've been working on an implementation of BLE Mesh's Generic Sensor model using nRF5 SDK for Mesh v5.0.0. The sensor I'm working with is a temperature and humidity sensor thus I decided to use the Precise Present Ambient Temperature and Present Ambient Relative Humidity Property IDs for this sensor.

As per Bluetooth SIG's GATT Specification Supplement v5, the representation of scalar values is determined by the formula R = C * M * 10^d * 2^b.

Also, the coefficients of Precise Present Ambient Temperature is M = 1, d = -2, b = 0, represented as a signed 16bit integer.

However, this doesn't make any sense to me. The raw value from the sensor, C, is of double-precision and under all circumstances, would be rounded to zero when calculated with such coefficients. For example, int16_t r = 25.0 * 1 * pow(10, -2) * pow(2, 0) will result in r = 0.25 in double but r = 0 in int16. 

Then, I modified the coefficient d to be equal to 0 and I get 0.25 in the nRF Mesh for Android app. Modifying further, d = 2 results in a success:

It makes sense to me that precision values are multiplied by orders of magnitude to fit into an integer, but I do not get why the GATT Specification Supplement is telling us to divide by orders of magnitude. There is probably some detail I have overlooked while poring over the SDK and Bluetooth SIG's documents. Can you tell me what's with the mismatch here?

PS. Same thing applies for Present Ambient Relative Humidity.

Parents
  • Hello Arif,

    Thank you for contacting DevZone at NordicSemi.

    Your query is regarding implementation of temperature and humidity sensors as per BLE Mesh Sensor Model.

    Yes, as per GATT Specification, the represented value of a scalar is determined using the formula

    R = C * M * 10^d * 2^b

    consider M=1, d=-2, b=0 (as mentioned for the temperature), we get:

    R = C / 100

    where R is the "represented value" and C is the "raw value".

    Let us understand it this way: The value coming from the sensor is to be represented as raw value/data to be sent to the client / other device.

    So, this equation is converting (or decoding) the raw/transmitted values into the temperature (represented value).

    However, for the server side (from where you want to send the data to the client / mobile app), we need to encode the temperature. Therefore, we can say that:

    C = R * 100

    Therefore, from the server side, temperature of 0.25 degree Celsius will be transmitted as 25, and the temperature of 1.35 will be transmitted as 135.

    That is why you are getting results when you change the value of d from -2 to 2, and thus for your case, it becomes like: R = C * 100, where you get C from the sensor and transmitting R.

    Does this make sense? Let me know. If you still have query, then please send some code snippet (and preferably complete minimal project) including your modification and the method to reproduce error / results.

    Regards,
    Naeem

  • I see, so I have do the reverse of what I see in the specification. Thank you very much for your answer!

Reply Children
No Data
Related