boschsensortec / BMP5_SensorAPI

SensorAPI for the 6th Generation of barometric pressure sensors
https://www.bosch-sensortec.com/products/environmental-sensors/pressure-sensors/bmp581/
BSD 3-Clause "New" or "Revised" License
11 stars 6 forks source link

Temperature calculation might wrong #1

Closed gdf8gdn8 closed 1 year ago

gdf8gdn8 commented 2 years ago

Hi, Barometer temperature sensor range is from -40..85°C but the calculation is only for positive values.

  if (rslt == BMP5_OK)
    {
        raw_data_t = (int32_t)((uint32_t)(reg_data[2] << 16) | (uint16_t)(reg_data[1] << 8) | reg_data[0]);

#ifdef BMP5_USE_FIXED_POINT

        /* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data and followed by fixed point digit
         * precision in deg C
         */
        sensor_data->temperature =
            (int64_t)((raw_data_t / (int64_t)65536.0) * (power(10, BMP5_FIXED_POINT_DIGIT_PRECISION)));
#else

        /* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data in deg C */
        sensor_data->temperature = (float)(raw_data_t / 65536.0);
#endif
kegov commented 1 year ago

@gdf8gdn8 fixed in v1.1.1