File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ import board
2
+ import digitalio
3
+ import busio
4
+ import time
5
+ import adafruit_bme280
6
+
7
+ # Create library object using our Bus I2C port
8
+ i2c = busio .I2C (board .SCL , board .SDA )
9
+ bme280 = adafruit_bme280 .Adafruit_BME280_I2C (i2c )
10
+
11
+ # OR create library object using our Bus SPI port
12
+ #spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
13
+ #bme_cs = digitalio.DigitalInOut(board.D10)
14
+ #bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, bme_cs)
15
+
16
+ # change this to match the location's pressure (hPa) at sea level
17
+ bme280 .seaLevelhPa = 1013.25
18
+
19
+ while True :
20
+ print ("\n Temperature: %0.1f C" % bme280 .temperature )
21
+ print ("Humidity: %0.1f %%" % bme280 .humidity )
22
+ print ("Pressure: %0.1f hPa" % bme280 .pressure )
23
+ print ("Altitude = %0.2f meters" % bme280 .altitude )
24
+ time .sleep (2 )
You can’t perform that action at this time.
0 commit comments