Skip to content

Commit dc79349

Browse files
committed
demo
1 parent 51ffff9 commit dc79349

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

examples/main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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("\nTemperature: %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)

0 commit comments

Comments
 (0)