Description

⚙ Hardware Needed


📚 External Libraries Needed


(optional) Device-specific library

adafruit_bme280.py

📑 Code


import board
import busio
import digitalio
import adafruit_bme280

# Setup the SPI connection
cs = digitalio.DigitalInOut(board.xSDCS)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

# Setup the SPI device
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)

print("\\nTemperature: %0.1f C" % bme280.temperature)
print("Humidity: %0.1f %%" % bme280.humidity)
print("Pressure: %0.1f hPa" % bme280.pressure)

Details


SPI is a three-wire communication protocol. Read more here and here

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/263643e9-2108-42ae-9fb5-8a0b0e8f753f/Untitled.png

to learn more about configuring pins for different hardware functions, see: Pin Muxing