Update. I am working on the maths in my script and that might be the problem.
No worries, if you need to follow up on this one we’ll try and help out.
You haven’t specified which brand of this sensor you are using. For example DFRobot, AdaFruit. Some companies provide better documentation than others, but in the main, you can normally use companyA’s documentation for companyB’s board, especially when writing code for the sensor.
AdaFruit have good documentation and code examples for Arduino C++ and circuit python/micro python for this sensor.
It is a Gravity BMP388 and I have been trying with various Python code. I have a BMP180 sensor as well and it produces excellent (at least Mean Sea Level Pressure) results with Adafruit_BMP library.
Using DFRobot code produces spurious results at best. I looked at the DFRobot bmp388.py and it has all the right information directly from the Bosch fact sheet so you would assume it should give the best results.
Here are the results:
Adafruit bmp3xx library
Pressure: 952.5 Temperature: 12.88 Altitude: 518.39
Pressure: 95238.80 Temperature: 12.8 Altitude: 519.51
Pressure: 95624.77 Temperature: 13.23 (NOTE major difference in pressure so its code appears wrong)
For altitude, you enter your known altitude which in my case is 578 m.
seaLevel : 102407.56 Pa (NOTE mean sea level pressure is 1020.4 so the output is wrong too)
calibrate Altitude : 572.46 m
Pressure: 95103.00 Temperature: 12.80 Altitude: 531.12
Calculated MSLP = 1019.13 hPa which is close enough given I am a few kilometres from the bureau observation at Canberra airport.
Calculating MSLP requires the known altitude and in all cases, the BMP388 is wrong. Where it is almost right in DFRobot, I have entered that.
Pretty annoying for a “precision” sensor.
I decided to settle on using the adafruit_bmp3xx library and it all looks pretty good. The BMP388 seems to be better at reading the pressure than the BMP180 but it is only marginal when using the Adafruit python libraries for both sensors. Considering it is a Gravity product, why DFRobot is so wrong is not a good sign. I haven’t tried c/c++ code yet so perhaps that might make a difference.
Sounds like you’re running into a bit of a metrology issue. A sensor is only as good as its calibration data.
It’s important to note that precise just means extremely repeatable. The accuracy comes from the calibration, and one known good data point isn’t enough. Even if the adafruit library spits out a value closer to what you’re expecting at your location, doesn’t mean it’s going to be more accurate at a different pressure.
None of those sensor readings seem wrong to me and there are a few different mean sea level definitions, so it’s possible you (and the libraries) are using a different ones, particularly depending on the nationality of the person that wrote the code.
Check out the wiki article: https://en.m.wikipedia.org/wiki/Sea_level
It probably doesn’t matter too much which ones you use, as long as you’re consistent. If you’re happy with the adafruit library you should stick with that.