I have recently purchased a BME680 for evaluation and noticed that there are some errors in the description of pressure measurement (section 3.3.2) on the datasheet. In the floating point part there are undefined variables var1_p, var2_p and var3_p which comparing with the actual api code should be simply var1, var2 and var3. There are also some worrying mathematical errors:- (1) In initialising var1, the constant 64000.0 is used in the floating calc and the same effective value 64000 used in the integer calc. This cannot be correct because the integer calc is scaled by a factor of 100. Surely, one of these constants is incorrectly scaled? (2) Again comparing the update to var1 (line 5 in each case), the floating point and the integer versions are not mathematically equivalent. (3) Both the above issues are replicated in the driver library.
It looks like the compensation formulae in the data sheet have been reverse engineered from the code. It would be helpful and much clearer if the formula were expressed mathematically for all the compensation calculations and leave the programmer to implement them appropriately. For example the temperature compensation appears to be a simple hyperbolic function: t_comp = (x - a)(b + (x-a)c)/d . Some of the manipulations documented are obscure and I suspect have been programmed to avoid register overflow. This makes it tricky to implement the formula in other languages such as java.
Solved! Go to Solution.
Thank-you for your comments and suggestions. The undefined variables have been reported internally. Unfortunately we can only share the compensation formulas as part of the Sensor API/datasheet as done today. If supported by your platform, we recommend using the floating point integration when possible, while the integer implementation offers an alternative on more restricted devices. In case you are any issue facing with your outputs using either implementation in the Sensor API please let us know.
Thanks for your inquiry.
We will investigate the conversion code in BME680 datasheet for the pressure sensor part to see if there is any mathematical mismatch regarding floating and integer calculations. We will then get back to you.
Regrading the calibration parameters for temperature sensor, pressure sensor and humidity, each BME680 has been factory calibrated and trimmed before shipping to the market. In order to get final compensated temperature, pressure and humidity results, we provide sample code in both datasheet and driver at https://github.com/BoschSensortec/BME680_driver. If users use different programming languages, then they can verify if the final compensated values match the environmental truth or not. The formula doesn't help too much to understand how the conversions work because they have been designed in the ASIC part of BME680.
Thank you for your helpful reply. I would like to withdraw item (1) in my observations - I am now satisfied the Integer and FP formula are consistent in this respect.
In relation to the original question, I have found inconsistency among API and Datasheet for the calculation of gas sensor heater resistance.
Page 21 of Datasheet shows floating point and integer calculations but they are not equivalent. var1 in integer calculation is (amb_temp*par_g3/10)<<8, but the floating point method calculates this part as (amb_temp*par_g3*10)<<8 (var1 in the floating point method is different from that in the integer method, so I have deduced this result by rearranging the entire floating point formulae).
Moreover, the integer calculation in API is var1=(amb_temp*par_g3)/1000)*256 (small modifications made for clarity) in line 1006 of bme680.c. The floating point calculation in API looks the same as that in Datasheet.
So, there are three variations in calculating var1 or its equivalent, each 100 times different from another. Could you tell me which is correct, and hopefully fix the incorrect formulae? Thank you.