Skip to content

Commit eee0955

Browse files
committed
Add Pico example and update gitignore
1 parent 922e58c commit eee0955

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
#
33
# SPDX-License-Identifier: Unlicense
44

5+
*.mpy
6+
.idea
57
__pycache__
68
_build
79
*.pyc
8-
*.mpy
910
.env
11+
.python-version
12+
build*/
1013
bundles
14+
*.DS_Store
15+
.eggs
16+
dist
17+
**/*.egg-info
18+
.vscode

examples/bme280_simpletest_pico.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
import time
5+
import board
6+
import busio
7+
import adafruit_bme280
8+
9+
# Create sensor object, using the board's default I2C bus.
10+
i2c = busio.I2C(board.GP1, board.GP0) # SCL, SDA
11+
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
12+
13+
# OR create sensor object, using the board's default SPI bus.
14+
# spi = busio.SPI(board.GP2, MISO=board.GP0, MOSI=board.GP3)
15+
# bme_cs = digitalio.DigitalInOut(board.GP1)
16+
# bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, bme_cs)
17+
18+
# change this to match the location's pressure (hPa) at sea level
19+
bme280.sea_level_pressure = 1013.25
20+
21+
while True:
22+
print("\nTemperature: %0.1f C" % bme280.temperature)
23+
print("Humidity: %0.1f %%" % bme280.relative_humidity)
24+
print("Pressure: %0.1f hPa" % bme280.pressure)
25+
print("Altitude = %0.2f meters" % bme280.altitude)
26+
time.sleep(2)

0 commit comments

Comments
 (0)