Modifications

Sauter à la navigation Sauter à la recherche
871 octets ajoutés ,  26 février 2022 à 23:49
Ligne 208 : Ligne 208 :     
<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(1)
    +
# 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}}
29 917

modifications

Menu de navigation