Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMP388 Compensation Calculations?

    BMP388 Compensation Calculations?

    Occasional Visitor

    We are using the BMP388 and have a board with it (and 5 other sensors) on it.  I can read and write to the device, and can successfully read the product ID (00) -- I have found the 1.1.0 API code release in Gethub, and have  integrated it with our exising code.  But I have several questions.

       1) No where in the code or datasheet does it say what units the compensated pressure data is returned in. The data sheet gives the sensor's range and accuracy in hPa, so I assumed that is what the API would return from the compensate_pressure() function -- is that correct?  In the BMP-series-pressure-sensor-design-guide there is example code with a printf() statement that prints "P:  %.2f" supplying "bmp3_comp_data.pressure / 100" - so that indicates it is in Pa, not hPa?  Can you confirm?  That example code is not included in the API package so the only way to find this is to hunt around on the web and your site and finally find that one line buried in the example?

    2)  There is no example (sample inputs with expected outputs) for any of the calculations -- and the values read out of the device are unusable without running it through the compensation formulas, and there is no way to validate if the output is correct, making debugging virtually impossible.  Can you supply example input/expected results for the Temp and Humidity register reads, with example triming register values and the outputs of the compensated values.  (and including intermediate results would be exceedingly valuable).

    3) If you get through 1) and 2) and the results don't match your reference platform (if you have one) or your local weather report within some small range, there is no way to validate your results or know if there is a subtle bug in the code or if there is just an offset in the BMP3xx measurement results. 

    Thanks, Ken


    4 REPLIES 4


    Hi Ken, thank you for your interest in Bosch Sensortec pressure sensors. We are here to help.


    1) In the design guide, it is mentionned that the sample code is to be found in the COINES installation folder, C:/COINES under Windows by default. It also includes a link on where to download this software, so you don't have to "hunt around on the web" to find it. I will ask the Sensor API team to add the units to the documentation for that function.

    2) We have a small spreadsheet that we use internally. See attached. In general if you are using the provided API, calculation errors should not be a concern.

    3) I think answers 1 and 2 should answer your concerns. To truly validate the output, as with any sensor, the only way is to compare the value with a reference unit with equal or higher precision.


    I have the same kinfd of issues. I use a BMP388 and a BME280. The BME280 returns correct values (compared to what the closest meteo station reports). On the other hand the BMP388 reports a false pressure. I should read something around 1015 mb, but I read 1050 mb. I expect I did a mistake with the compensation algorithm and wanted to check. Unfortunately the link to the XLS file reports HTTP error 404 !!!! 

    When I read the constants from the device it returns the follwing values :

    T1 : 27603

    T2 : 18754

    T3 : 246

    P1 : -476

    P2 : -2805

    P3 : 35

    P4 : 0

    P5 : 26148

    P6 : 31324

    P7 : 243

    P8 : 246

    P9 : 16258

    P10 : 10

    P11 : 196

    I tried with the double and integer compensation routines I get the same results. As an example if I ge the following raw values :

    Temperature : 7095664

    Pressure : 10479274

    I finally ahve the following compensated values :

    Temperature :18.90

    Pressure : 1047.92

    The tempeature is fine but the pressure is roughly 42 hpa to high.

    Any ideas ?

    Thanks for your support.


    Hi Alain,

    This is far outside the expected accuracy of the sensor. Going from Software to Hardware, make sure that:

    1. Compensation formula is properly applied (see spreadsheet attached, don't understand why the error 404 on the previous post)
    2. Conversion from register value to integer value is good (see updated spreadsheet attached, with register value)
    3. Register value matches the bus activity (confirm with logic analyzer or oscilloscope that the values in your MCU memory match the decoded protocol from the bus)

    If all above looks okay, then the sensor is actually sending bad data, which indicates hardware failure. Confirm the soldering process follows the Handling, Soldering and Mounting instructions.




    Do you have a similar spreadsheet for the BMP390?

    Your Temp parameters worked great - I was able to get that working fine.

    But, have the pressure parameters changed from BMP380 to BMP390?

    Thanks for supplying the sample calculation!


    Todd Anderson (A new user of the BMP390)