Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import board
6import adafruit_bmp3xx
7
8# I2C setup
9i2c = board.I2C() # uses board.SCL and board.SDA
10# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
11bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)
12
13# SPI setup
14# from digitalio import DigitalInOut, Direction
15# spi = board.SPI()
16# cs = DigitalInOut(board.D5)
17# bmp = adafruit_bmp3xx.BMP3XX_SPI(spi, cs)
18
19bmp.pressure_oversampling = 8
20bmp.temperature_oversampling = 2
21
22while True:
23 print(
24 "Pressure: {:6.4f} Temperature: {:5.2f}".format(bmp.pressure, bmp.temperature)
25 )
26 time.sleep(1)