pimoroni / bme680-python

Python library for the BME680 gas, temperature, humidity and pressure sensor.
https://shop.pimoroni.com/products/bme680
MIT License
260 stars 93 forks source link

Altitude and sea level pressure #44

Open TheOzarkWizard opened 3 years ago

TheOzarkWizard commented 3 years ago

Im needing altitude and sea level pressure parameters. Is there something Im missing?

smurfix commented 3 years ago

It's simple enough to convert one to the other. Check Wikipedia for the formula.

themeadery commented 6 months ago

I use this code in my project. Seems to work well

# Station altitude in meters
sta_alt = 276.0

# Station pressure to MSL Pressure conversion function
# Formula source: https://gist.github.com/cubapp/23dd4e91814a995b8ff06f406679abcf
def sta_press_to_mslp(sta_press, temp_c):
    mslp = sta_press + ((sta_press * 9.80665 * sta_alt)/(287 * (273 + temp_c + (sta_alt/400))))
    logging.info(f"{mslp:.2f} hPa MSL")
    return mslp