File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,8 @@ def pressure(self):
114
114
115
115
@property
116
116
def altitude (self ):
117
- """calculate the altitude based on the sea level pressure (seaLevelPa ) - which you must enter ahead of time)"""
118
- p = self .pressure / 100.0 # in Si units for Pascal
117
+ """calculate the altitude based on the sea level pressure (seaLevelhPa ) - which you must enter ahead of time)"""
118
+ p = self .pressure # in Si units for hPascal
119
119
return 44330 * (1.0 - math .pow (p / self .seaLevelhPa , 0.1903 ));
120
120
121
121
def _read_coefficients (self ):
Original file line number Diff line number Diff line change 1
1
import board
2
+ import digitalio
2
3
import busio
3
4
import time
4
5
from adafruit_bmp280 import adafruit_bmp280
5
6
6
- i2c = busio .I2C (board .SCL , board .SDA , frequency = 100000 )
7
-
8
- while not i2c .try_lock (): pass
9
- print ("I2C addresses found:" , [hex (i ) for i in i2c .scan ()])
10
- i2c .unlock ()
11
-
12
- # Create library object on our I2C port
7
+ # Create library object using our Bus I2C port
8
+ i2c = busio .I2C (board .SCL , board .SDA )
13
9
bmp280 = adafruit_bmp280 .Adafruit_BMP280_I2C (i2c )
14
10
11
+ # OR create library object using our Bus SPI port
12
+ #spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
13
+ #bmp_cs = digitalio.DigitalInOut(board.D10)
14
+ #bmp280 = adafruit_bmp280.Adafruit_BMP280_SPI(spi, bmp_cs)
15
+
16
+ # change this to match the location's pressure (hPa) at sea level
17
+ bmp280 .seaLevelhPa = 1013.25
18
+
15
19
while True :
16
20
print ("\n Temperature: %0.1f C" % bmp280 .temperature )
17
21
print ("Pressure: %0.1f hPa" % bmp280 .pressure )
You can’t perform that action at this time.
0 commit comments