File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ import time
2
+
3
+ import board
4
+ import busio
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 .sea_level_pressure = 1013.25
18
+ #refer to the BMP280 datasheet to understand what these do
19
+ bme280 .mode = adafruit_bme280 .MODE .NORMAL
20
+ bme280 .standby_period = adafruit_bme280 .STANDBY .TC_500
21
+ bme280 .iir_filter = adafruit_bme280 .IIR_FILTER .X_16
22
+ bme_280 .overscan_pressure = adafruit_bme280 .OVERSCAN .X_16
23
+ bme_280 .overscan_humidity = adafruit_bme280 .OVERSCAN .X_1
24
+ bme_280 .overscan_temperature = adafruit_bme280 .OVERSCAN .X_2
25
+ #The sensor will need a moment to gather inital readings
26
+ sleep (1 )
27
+
28
+ while True :
29
+ print ("\n Temperature: %0.1f C" % bme280 .temperature )
30
+ print ("Humidity: %0.1f %%" % bme280 .humidity )
31
+ print ("Pressure: %0.1f hPa" % bme280 .pressure )
32
+ print ("Altitude = %0.2f meters" % bme280 .altitude )
33
+ time .sleep (2 )
You can’t perform that action at this time.
0 commit comments