Ligne 91 : |
Ligne 91 : |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
| + | # Read the sensor values: |
| + | # (temperature_celcius, pressure_hpa, humidity_percent) |
| + | # Humidity only applies to BME280 only, not BMP280. |
| + | # |
| from machine import I2C | | from machine import I2C |
| # BME280 aslo work for BMP280 | | # BME280 aslo work for BMP280 |
Ligne 104 : |
Ligne 108 : |
| | | |
| Which produce the following results: | | Which produce the following results: |
− | | + | <nowiki>(22.28, 1017.68, 0.0) |
− | <syntaxhighlight lang="bash"> | |
− | (22.28, 1017.68, 0.0) | |
| (22.27, 1017.66, 0.0) | | (22.27, 1017.66, 0.0) |
| (21.87, 1017.67, 0.0) | | (21.87, 1017.67, 0.0) |
Ligne 112 : |
Ligne 114 : |
| (21.83, 1017.68, 0.0) | | (21.83, 1017.68, 0.0) |
| (21.81, 1017.68, 0.0) | | (21.81, 1017.68, 0.0) |
− | (21.81, 1017.68, 0.0) | + | (21.81, 1017.68, 0.0)</nowiki> |
− | </syntaxhighlight> | |
| | | |
| By activating the Plotter, the value can even be made visible as a graph. However, to see a proper graph evolution, the best is to replace the {{fname|sleep(1)}} to {{fname|sleep( 60*30 )}} (30 min). | | By activating the Plotter, the value can even be made visible as a graph. However, to see a proper graph evolution, the best is to replace the {{fname|sleep(1)}} to {{fname|sleep( 60*30 )}} (30 min). |
Ligne 149 : |
Ligne 150 : |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
| + | # Read Local pressure then |
| + | # Calculate corresponding Altitude |
| + | # |
| from machine import I2C | | from machine import I2C |
| # BME280 aslo work for BMP280 | | # BME280 aslo work for BMP280 |
Ligne 178 : |
Ligne 182 : |
| By example, today the pressure is 1002.00 hPa at the Belgian's sea level. | | By example, today the pressure is 1002.00 hPa at the Belgian's sea level. |
| | | |
− | <font color="red">this value is critical if you want to evaluate the altitude of the sensor.</font>. It is also important to know the current altitude if you plan to calculate the "correction" for the normalized SLP pressure. | + | <font color="red">this value is critical if you want to evaluate the altitude of the sensor</font>. |
− | | |
− | So I have fixed the baseline as follow before reading the altitude:
| |
| | | |
− | Serial.print(bme.readAltitude(1002.00));
| + | It is also important to know the current altitude if you plan to calculate the "correction" for the normalized SLP pressure. |
− | Serial.println(" m");
| |
| | | |
| + | {{underline|Remark:}}<br /> |
| It is quite easy to know the current sea level pressure by using an Internet Weather Broadcast like [http://www.meteobelgique.be/observations/temps-reel/stations-meteo.html this link to meteobelgique.be] | | It is quite easy to know the current sea level pressure by using an Internet Weather Broadcast like [http://www.meteobelgique.be/observations/temps-reel/stations-meteo.html this link to meteobelgique.be] |
| | | |
Ligne 206 : |
Ligne 208 : |
| {{underline|First:}} You must know your altitude (121m in my case, see here before How I did calculate it). | | {{underline|First:}} You must know your altitude (121m in my case, see here before How I did calculate it). |
| | | |
− | {{underline|Then:}} Read the pressure and apply a correction factor. | + | {{underline|Then:}} Read the pressure and apply the SLP correction factor. |
− | | |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
| + | # Read Local pressure |
| + | # Calculate corresponding SLP pressure |
| + | # (SLP: sea level pressure) |
| + | # |
| + | from machine import I2C |
| + | # BME280 aslo work for BMP280 |
| + | from bme280 import BME280, BMP280_I2CADDR |
| + | from time import sleep |
| + | i2c = I2C(0) |
| | | |
| + | # Sensor altitude (in meter) required to |
| + | # calculate SLP (See Level Pressure) |
| + | altitude = 120.1 |
| + | bmp = BME280( i2c=i2c, address=BMP280_I2CADDR ) |
| + | while True: |
| + | # returns a tuple with (temperature, pressure_hPa, humidity) |
| + | p = bmp.raw_values[1] |
| + | p_sea = p + (altitude/8.3) |
| + | print( "Plocal: %6.1f hPa, Psea: %6.1f hPa" % (p,p_sea) ) |
| + | sleep(1) |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
| + | which returns: |
| | | |
| + | <nowiki>Plocal: 1017.4 hPa, Psea: 1031.8 hPa |
| + | Plocal: 1017.4 hPa, Psea: 1031.9 hPa |
| + | Plocal: 1017.3 hPa, Psea: 1031.8 hPa |
| + | Plocal: 1017.4 hPa, Psea: 1031.8 hPa |
| + | Plocal: 1017.4 hPa, Psea: 1031.9 hPa |
| + | Plocal: 1017.4 hPa, Psea: 1031.9 hPa |
| + | Plocal: 1017.4 hPa, Psea: 1031.8 hPa</nowiki> |
| | | |
| {{ENG-CANSAT-PICO-TRAILER}} | | {{ENG-CANSAT-PICO-TRAILER}} |