Ligne 144 : |
Ligne 144 : |
| | | |
| Here the steps to follow with the BMP280 to estimate the altitude of the house: | | Here the steps to follow with the BMP280 to estimate the altitude of the house: |
− | # Find the hPa (or mmbar) pressure at Sea Level on a WebSite | + | # Find the hPa pressure at Sea Level on a WebSite |
− | # Use that value as baseline (don't hesitate to multiply it by 100)
| + | # Use the BMP280 sensor to read the pressure. |
− | # Use the sensor and the BMP280 library to read the altitude. | + | # Calculate the height with the following code |
− | # Calculate the correction value (for the air's colonne) in hPa = height-in-meter / 8.3 | |
| | | |
− | When you have to "correction" value you don't have to care anymore about the baseline.
| + | <syntaxhighlight lang="python"> |
| + | from machine import I2C |
| + | # BME280 aslo work for BMP280 |
| + | from bme280 import BME280, BMP280_I2CADDR |
| + | from time import sleep |
| + | i2c = I2C(1) |
| + | |
| + | baseline = 1032.0 # day's pressure at sea level |
| + | bmp = BME280( i2c=i2c, address=BMP280_I2CADDR ) |
| + | while True: |
| + | # returns a tuple with (temperature, pressure_hPa, humidity) |
| + | p = bmp.raw_values[1] |
| + | altitude = (baseline - p)*8.3 |
| + | print( "Altitude: %f m" % altitude ) |
| + | sleep(1) |
| + | </syntaxhighlight> |
| | | |
− | Indeed, we can read the current pressure (without caring about the baseline) THEN we add the "correction" value --> Tadaaa! We have the SLP pressure (the same than displayed on Reference Weather Station).
| |
| | | |
| <nowiki># mean pressure at the sea level (not critical for SLP pressure) | | <nowiki># mean pressure at the sea level (not critical for SLP pressure) |
Ligne 158 : |
Ligne 171 : |
| p = bmp280.pressure + compensation</nowiki> | | p = bmp280.pressure + compensation</nowiki> |
| | | |
− | where {{fname|p}} would contains pressure normalized at sea level (so the SLP value).
| |
| | | |
− | The downside of the "mean pressure value" approach (101325 Pa) is that you cannot estimate the altitude with accuracy.
| |
− | However, by updating the baseline value every day with the "day's pressure" at sea level (see on Internet broadcast website) then the altitude calculation would be fairly precise.
| |
| | | |
| Just remind: | | Just remind: |