File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,11 @@ Ensure your device works with this simple test.
66.. literalinclude :: ../examples/bmp5xx_simpletest.py
77 :caption: examples/bmp5xx_simpletest.py
88 :linenos:
9+
10+ .. literalinclude :: ../examples/bmp5xx_spi_simpletest.py
11+ :caption: examples/bmp5xx_spi_simpletest.py
12+ :linenos:
13+
14+ .. literalinclude :: ../examples/bmp5xx_spi_multi_device.py
15+ :caption: examples/bmp5xx_spi_multi_device.py
16+ :linenos:
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: MIT
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 ()
15+
16+ # first sensor setup
17+ cs1 = DigitalInOut (board .D10 )
18+ cs1 .direction = Direction .OUTPUT
19+ bmp1 = BMP5XX (spi = spi , cs = cs1 )
20+
21+ # second sensor setup, different CS pin, same SPI bus
22+ cs2 = DigitalInOut (board .D11 )
23+ cs2 .direction = Direction .OUTPUT
24+ bmp2 = BMP5XX (spi = spi , cs = cs2 )
25+
26+ bmp1 .sea_level_pressure = SEALEVELPRESSURE_HPA
27+ bmp2 .sea_level_pressure = SEALEVELPRESSURE_HPA
28+
29+ while True :
30+ if bmp1 .data_ready :
31+ print (
32+ f"BMP1 temp F: { bmp1 .temperature * (9 / 5 ) + 32 } "
33+ f"pressure: { bmp1 .pressure } hPa "
34+ f"Approx altitude: { bmp1 .altitude } m"
35+ )
36+
37+ if bmp2 .data_ready :
38+ print (
39+ f"BMP2 temp F: { bmp2 .temperature * (9 / 5 ) + 32 } "
40+ f"pressure: { bmp2 .pressure } hPa "
41+ f"Approx altitude: { bmp2 .altitude } m"
42+ )
43+ print ("-----" )
44+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments