Modifications

Sauter à la navigation Sauter à la recherche
555 octets supprimés ,  26 février 2022 à 23:57
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
 
from bme280 import BME280, BMP280_I2CADDR
 
from bme280 import BME280, BMP280_I2CADDR
 
from time import sleep
 
from time import sleep
i2c = I2C(1)
+
i2c = I2C(0)
 
bmp = BME280( i2c=i2c, address=BMP280_I2CADDR )
 
bmp = BME280( i2c=i2c, address=BMP280_I2CADDR )
 
while True:
 
while True:
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
 
from bme280 import BME280, BMP280_I2CADDR
 
from bme280 import BME280, BMP280_I2CADDR
 
from time import sleep
 
from time import sleep
i2c = I2C(1)
+
i2c = I2C(0)
    
baseline = 1032.0 # day's pressure at sea level
 
baseline = 1032.0 # day's pressure at sea level
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:
+
It is also important to know the current altitude if you plan to calculate the "correction" for the normalized SLP pressure.
 
  −
Serial.print(bme.readAltitude(1002.00));
  −
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 197 : Ligne 199 :  
Once the baseline value corrected, you will have the correct altitude.
 
Once the baseline value corrected, you will have the correct altitude.
   −
=== The pressure is not correct atmosphérique semble incorrecte! ===
+
=== The athmospheric pressure is not correct! ===
 
My sensor returned a pressure of 98909 pascal (so 989.09 hPa) whereas the reference weather station does mentino 1002 hPa!
 
My sensor returned a pressure of 98909 pascal (so 989.09 hPa) whereas the reference weather station does mentino 1002 hPa!
   −
The sensor value is right, it just not apply the correction to indicates the Normalized SLP pressure (equivalent pressure at the sea level). The reference {{underline|reference}} weather station does applies this correction for yo (so they displays normalized SLP).
+
The sensor value is right, it just not apply the correction to return the Normalized SLP pressure (equivalent pressure at the sea level). The reference {{underline|reference}} weather station does applies SLP correction for you (so they displays normalized SLP).
   −
Let's do the correction on the value...
+
Let's do the SLP correction on the sensor's value...
   −
{{underline|First:}} read the preceding point, from it we know :
+
{{underline|First:}} You must know your altitude (121m in my case, see here before How I did calculate it).
* that we have to set the baseline to the current pressure at day's sea level pressure (baseline=100200)
  −
* once done, we can use the sensor to calculate the current altitude of the sensor (in our case, it is 104 m)
  −
* the pressure decrease of 1hPa every time we increase the altitude of 8.3m .
     −
{{underline|Next, on the reference Weather station:}}
+
{{underline|Then:}} Read the pressure and apply the SLP correction factor.
   −
The weather station does normalize the atmospheric pressure calculate local pressure at the Sea Level altitude (called SLP for "Sea Level Pressure" also named "PNM" for ''Pression Niveau Mer'').
+
<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)
   −
This means that reference weather station applies the correction (compensating) to the read value.
+
# Sensor altitude (in meter) required to
 
+
# calculate SLP (See Level Pressure)
For the reference station next to house, its height is 120m. so the correction adds the air column of 120m height over the sensor value to get the normalized SLP pressure. So the correction is evaluated to (120 / 8.3) hPa = 14.45 hPa.
+
altitude = 120.1
 
+
bmp = BME280( i2c=i2c, address=BMP280_I2CADDR )
{{underline|Let's apply the same principle to our BMP280 readings:}}
+
while True:
 
+
    # returns a tuple with (temperature, pressure_hPa, humidity)
In our case, we know that the altitude of the BMP280 sensor is 104m. Remind, the pressure is reduced of 1hPa every time our altitude increase of 8.3m.
+
    p = bmp.raw_values[1]
 
+
    p_sea = p + (altitude/8.3)
For 104m, the air column until the sea level correspond to 104 / 8.3 = 12.53 hPa additional pressure.
+
    print( "Plocal: %6.1f hPa, Psea: %6.1f hPa" % (p,p_sea) )
 
+
    sleep(1)  
As the sensor give the 989.09 hPavalue, the correction to have the Normalized SLP is 989.09 + 12.53 = 1001.62 hPa. Great! it is almost the same value than reference weather station next to home (to remind, it communicates 1002 hPa).
+
</syntaxhighlight>
   −
{{ambox|text=Please note that the today's pressure is 1002 hPa and our normalized pressure is also 1002 hPa. This is rare situation and means that the air will not flow in any way between our location and the sea.}}
+
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}}
29 917

modifications

Menu de navigation