Simple test¶
Ensure your device works with this simple test.
examples/fake_bme280_simpletest.py¶
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3import time
4import board
5from fake_bme280 import basic as adafruit_bme280
6
7# Create sensor object, using the board's default I2C bus.
8i2c = board.I2C() # uses board.SCL and board.SDA
9# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
10bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
11
12# OR create sensor object, using the board's default SPI bus.
13# spi = board.SPI()
14# bme_cs = digitalio.DigitalInOut(board.D10)
15# bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, bme_cs)
16
17# change this to match the location's pressure (hPa) at sea level
18bme280.sea_level_pressure = 1013.25
19
20while True:
21 print("\nTemperature: %0.1f C" % bme280.temperature)
22 print("Humidity: %0.1f %%" % bme280.relative_humidity)
23 print("Pressure: %0.1f hPa" % bme280.pressure)
24 print("Altitude = %0.2f meters" % bme280.altitude)
25 time.sleep(2)