07-13-2019 02:18 AM - edited 07-13-2019 02:21 AM
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.
Solved! Go to Solution.
07-16-2019 06:40 PM
To be clear, a temperature during the production line higher than 40 may be acceptable depending on end customer requirements. This is as stated by Community Moderator, o_o, and the Bosch BMP38x Self-Test application note (page 7). Consider that the sensor temperature may be significantly higher than ambient due to heat generated by electronics, especially during testing when electronics may be deliberately stressed.
You are also incorrect to state that the reason for bug3 is the printf line. There is no is issue with this line. The cause of bug 3 is unknown and the issue can no longer be replicated. I have already suggested that the bug report is ignored.