bme680-python
bme680-python copied to clipboard
Altitude and sea level pressure
Im needing altitude and sea level pressure parameters. Is there something Im missing?
It's simple enough to convert one to the other. Check Wikipedia for the formula.
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