Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import time
import board
import busio
import adafruit_bmp3xx
# I2C setup
i2c = busio.I2C(board.SCL, board.SDA)
bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)
# SPI setup
# from digitalio import DigitalInOut, Direction
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
# cs = DigitalInOut(board.D5)
# bmp = adafruit_bmp3xx.BMP3XX_SPI(spi, cs)
bmp.pressure_oversampling = 8
bmp.temperature_oversampling = 2
while True:
print(
"Pressure: {:6.1f} Temperature: {:5.2f}".format(bmp.pressure, bmp.temperature)
)
time.sleep(1)
|