Important Cookie Information

This website uses absolutely necessary cookies. If you consent to the use of convenience cookies, please click “Yes, I agree.” By clicking on “Privacy Settings.” you can change this setting at any time and withdraw your given consent. Icon down see more You can find detailled information in our Privacy Policy Icon forward-right
Icon up see less

Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMP38x API self-test issues

    Established Member

    BMP38x API self-test issues

    BMP38x self-test v1.1.3 appears to suffer from multiple bugs.

    Bug 1 - Inappropriate plausible temperature range

    The maximum plausible temperature is defined as 40 degC on line 54 of bmp38x_selftest.c.  The BMP388 datasheet specifies an operating temperature up to 85 degC.  In practise, operating temperatures will often exceed 40 degC due to warm climates and/or heat generated by electronics.

    Bug 2 - Scaling errors for BMP3_DOUBLE_PRECISION_COMPENSATION

    If using BMP3_DOUBLE_PRECISION_COMPENSATION then the self-test will always fail with BMP3_IMPLAUSIBLE_PRESSURE due to scaling errors. This is because the API will provide measurements in units of degC and 100*hPa but the API defines the plausible ranges in units of 100*degC and 100*100*hPa (scaled once in definition and then again within if statement).  I suggest the issue is fixed by defining different plausible limits when BMP3_DOUBLE_PRECISION_COMPENSATION is defined.

    Bug 3 - Corrupted variables when not using BMP3_DOUBLE_PRECISION_COMPENSATION

    This issue can be demonstrated by printing the measurement values inside the internal function, analyze_sensor_data, on line 185 of bmp38x_selftest.c as shown below.

     

    static int8_t analyze_sensor_data(const struct bmp3_data *sens_data)
    {
        int8_t rslt = BMP3_SENSOR_OK;
        
    // **************** START OF DEBUG CODE ****************
    #ifdef BMP3_DOUBLE_PRECISION_COMPENSATION
        printf("t=%f, p=%f\r\n", sens_data->temperature, sens_data->pressure);
    #else
        printf("t=%ld, p=%lu\r\n", (long int)sens_data->temperature, (long unsigned int)sens_data->pressure);
    #endif
    // **************** END OF DEBUG CODE ****************
    
        if ((sens_data->temperature < BMP3_MIN_TEMPERATURE) || (sens_data->temperature > BMP3_MAX_TEMPERATURE))
        {
            rslt = BMP3_IMPLAUSIBLE_TEMPERATURE;
        }
        if (rslt == BMP3_SENSOR_OK)
        {
            if ((sens_data->pressure / 100 < BMP3_MIN_PRESSURE) || (sens_data->pressure / 100 > BMP3_MAX_PRESSURE))
            {
                rslt = BMP3_IMPLAUSIBLE_PRESSURE;
            }
        }
    
        return rslt;
    }

     

    If using BMP3_DOUBLE_PRECISION_COMPENSATION then the above modification will result in the following typical output:

    t=58.103809, p=101310.782827

    If not using BMP3_DOUBLE_PRECISION_COMPENSATION then the above modification will result in the following typical output:

    t=1, p=5752

    It appears that the pressure value is the temperature measurement (100*degC), and the temperature value is always 1.  This corruption only occurs within the function, analyze_sensor_data. There are no issues with values obtained using the function, bmp3_get_sensor_data.

    5 REPLIES 5
    Community Moderator
    Community Moderator

    Re: BMP38x API self-test issues

    Hi sebmadgwick,

     

    Thank you for your feedback, I shall report these issues immediately.

     

    Regarding bug#1 :  This "plausible" temperature and pressure range and is to be modified by the end customer depending on the specific range for the test facility. For example, a customer in Denver would expect the pressure to be much lower due to altitude.

    bug #2 an #3 will be investigated.

    Established Member

    Re: BMP38x API self-test issues

    Thank you for the quick response.

    A preferable solution to bug#2 is to calculate local variables with the correct scaling as shown below. This requires fewer lines of code, avoids mixing types, and avoids duplicate definitions of the plausible limits.

    static int8_t analyze_sensor_data(const struct bmp3_data *sens_data)
    {
        int8_t rslt = BMP3_SENSOR_OK;
        
    #ifdef BMP3_DOUBLE_PRECISION_COMPENSATION    
        int16_t temperature = sens_data->temperature * 100.0;
        uint32_t pressure = sens_data->pressure * 100.0;
    #else
        int16_t temperature = sens_data->temperature;
        uint32_t pressure = sens_data->pressure;
    #endif 
        
        if ((temperature < BMP3_MIN_TEMPERATURE) || (temperature > BMP3_MAX_TEMPERATURE))
        {
            rslt = BMP3_IMPLAUSIBLE_TEMPERATURE;
        }
        if (rslt == BMP3_SENSOR_OK)
        {
            if ((pressure / 100 < BMP3_MIN_PRESSURE) || (pressure / 100 > BMP3_MAX_PRESSURE))
            {
                rslt = BMP3_IMPLAUSIBLE_PRESSURE;
            }
        }
    
        return rslt;
    }

     

    Highlighted
    Established Member

    Re: BMP38x API self-test issues

    Please ignore bug#3.  I am no longer able to replace this issue for reasons unknown.

    Self test now works correctly but the above fix (for bug#2) is required if using BMP3_DOUBLE_PRECISION_COMPENSATION.

    Community Moderator

    Re: BMP38x API self-test issues

    Bug 1---In the datasheet, the temperature mentioned from -40 to 85 is the operating temperature range for the sensor. During the selftest, the temperature will not exceed 40 as in the API because temperature during the production line higher than 40 is not acceptable.

    Bug 2--- Thanks for feedback,the API unit definition error will send back to internal team for analysis.

    Bug 3--- As mentioned in the question, the no issues with values obtained using the function, bmp3_get_sensor_data which means the sensor data from sensor API is correct. Therefore, it is not possible to have this error during the selftest. Because the selftest just get data from the sensor API, then analysis it. Only the reason for this issue is from the debug code printf("t=%ld, p=%lu\r\n", (long int)sens_data->temperature, (long unsigned int)sens_data->pressure);

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist