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 24 25 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import board
import adafruit_bmp3xx
# I2C setup
i2c = board.I2C() # uses board.SCL and board.SDA
bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)
# SPI setup
# from digitalio import DigitalInOut, Direction
# spi = board.SPI()
# cs = DigitalInOut(board.D5)
# bmp = adafruit_bmp3xx.BMP3XX_SPI(spi, cs)
bmp.pressure_oversampling = 8
bmp.temperature_oversampling = 2
while True:
print(
"Pressure: {:6.4f} Temperature: {:5.2f}".format(bmp.pressure, bmp.temperature)
)
time.sleep(1)
|