Skip to content

Commit d52f6a8

Browse files
committed
fix simpletest. add SPI example
1 parent 5ea5bec commit d52f6a8

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

examples/bmp5xx_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
import board
77

8-
from adafruit_bmp5xx import BMP5XX_I2C
8+
from adafruit_bmp5xx import BMP5XX
99

1010
SEALEVELPRESSURE_HPA = 1013.25
1111

1212
# I2C setup
1313
i2c = board.I2C() # uses board.SCL and board.SDA
1414
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
1515

16-
bmp = BMP5XX_I2C(i2c)
16+
bmp = BMP5XX(i2c)
1717

1818
bmp.sea_level_pressure = SEALEVELPRESSURE_HPA
1919

examples/bmp5xx_spi_simpletest.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
import time
5+
6+
import board
7+
from digitalio import DigitalInOut, Direction
8+
9+
from adafruit_bmp5xx import BMP5XX
10+
11+
SEALEVELPRESSURE_HPA = 1013.25
12+
13+
# SPI setup
14+
spi = board.SPI() # uses board.SCL and board.SDA
15+
spi = board.SPI()
16+
cs = DigitalInOut(board.D10)
17+
cs.direction = Direction.OUTPUT
18+
bmp = BMP5XX(spi=spi, cs=cs)
19+
20+
21+
bmp.sea_level_pressure = SEALEVELPRESSURE_HPA
22+
23+
while True:
24+
if bmp.data_ready:
25+
print(
26+
f"temp F: {bmp.temperature * (9 / 5) + 32} "
27+
f"pressure: {bmp.pressure} hPa "
28+
f"Approx altitude: {bmp.altitude} m"
29+
)
30+
time.sleep(1)

0 commit comments

Comments
 (0)