File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 55
66import board
77
8- from adafruit_bmp5xx import BMP5XX_I2C
8+ from adafruit_bmp5xx import BMP5XX
99
1010SEALEVELPRESSURE_HPA = 1013.25
1111
1212# I2C setup
1313i2c = 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
1818bmp .sea_level_pressure = SEALEVELPRESSURE_HPA
1919
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments