BME280 pressure and altitude

This is both a question and a curiosity due to my ignorance on the matter.
As a lot of people around the world I'm using this sensor to get the local atmospheric pressure. With 'local' I mean a value that I can compare with what is published on the meteorological sites; if I am correct, they give a pressure referred to the sea level.
I'm not really interested in the altitude, but I am curious about this value for how it is calculated.

Question:
Few information about my testing:
according to Wikipedia I live at about 310m above the sea (+/- 5m). Close (20km) to my living place there is an airport (BG airport) which is at 238m.
My BME280 tipically gives a pressure varying from 970 to 990 hPa (without using the SEALEVELPRESSURE_HPA = 1013.25) while the airport gives values in the range of 1000..1030 hPA.

From a site (Interface BME280 Temperature, Humidity & Pressure Sensor with Arduino) I read:
" ...to get an accurate absolute altitude measurement, the SEA_LEVEL_PRESSURE constant is provided in the example code below, which you should update with the current sea level pressure at your location."

I do not know how to get the sea level pressure at my location. I'm confused since the value I get from the airport is referred to the sea level, but they are at 238m so they had applied a conversion value (that I do not know) while I am at 310m, so which calculation should I do? Please pardon me if the question is stupid, but I'm lost with these numbers.

And now the curiosity:
From the same site I read:
"Note that the BME280 cannot directly measure altitude but can estimate it using pressure readings. Because the BME280 is very good at measuring pressure, it can calculate relative altitude accurately"

Which is the independent variable in this calculation?
When the pressure changes due to athmosferic events how can the sensor maintain the correct (and fixed) altitude?

The assumed sea level pressure.

When the pressure changes due to athmosferic events how can the sensor maintain the correct (and fixed) altitude?

It can't. The sensor has to be recalibrated when necessary. If you know your altitude, the equivalent sea level pressure can be calculated, and updated for use in later estimates of the current altitude.

The formula for the equivalent sea level pressure is given here: https://www.easycalculation.com/engineering/marine/sea-level-pressure-calculator.php

Nothing.
The both, current sea level pressure and altitude, is dependent each from the other. To calculate the altitude of the unknown place, you must to know actual sea level pressure and vice versa.

In the altitude calculation formula, you need the sea level pressure. Use the weather station closest to you. With the current air pressure they measure, and what you measure, you should be able to get your actual altitude based on what it reads, or if you plug your altitude in the formulas get your sea level pressure. I recall the BME280 library has all those formulas built in.

Of course you have to keep updating your sea level pressure or you can't have a reliable altitude measurement.

Hi @orionis,

I monitor pressure and altitude using a BME280 as part of an outside environment monitor.

I obtained the SeaLevelPressure from a (free) API / account I have with OpenWeather where you can set a location where to collet the data from.

I then use the following code to obtain an altitude from -

        // Calculates the altitude (in meters) from the specified atmospheric
        // pressure (in hPa), and sea-level pressure (in hPa).
        altitude = 44330.0 * (1.0 - pow(pressure / slpressure, 0.1903));

/*
  //  Altitude notes -

  // Equation taken from BMP180 datasheet (page 16):
  //  http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf

  // Note that using the equation from wikipedia can give bad results
  // at high altitude. See this thread for more information:
  //  http://forums.adafruit.com/viewtopic.php?f=22&t=58064
*/

HTH?

1 Like

Hi Profile - robrs - Arduino Forum, your is a valid answer, thanks.
I got my local pressure from OpenWeather: it says I currently have 1011 hPA (is it at sea level, right?)
Now please explain your equation: what are those '44330.0' and '0.1903' in your formula?

P.S. what does it mean that 'HTH?' at the end? (I'm not too familiar with english acronyms)

Those are from the equation in the link (post #2), or barometric formula.

HTH = hope that helps

Capture

1 Like

I see! Not that I understand the formula, a little too much for me, but I can possibly study it.

HTH: thanks for the meaning...and it could help