Skip to content

BME280

Works with

Any CircuitPython board with I2C or SPI

What it does

The BME280 combines temperature, humidity, and barometric pressure measurement in a single package. Think of it as a BMP280 with humidity added. It is one of the most common all-in-one environmental sensors in maker projects because a single chip and a few lines of code give you three useful readings. Typical applications include weather stations, indoor climate monitors, and any data-logging project that benefits from capturing all three environmental variables together.

Installing the library

Copy the adafruit_bme280/ folder from the Adafruit CircuitPython Bundle to your board's lib/ folder. The library ships as a package rather than a single .mpy file. Also copy adafruit_bus_device/ if it is not already present.

Quick start

import board
import busio
from adafruit_bme280 import basic as adafruit_bme280

i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_bme280.Adafruit_BME280_I2C(i2c)

# Set local sea-level pressure for accurate altitude calculation
sensor.sea_level_pressure = 1013.25  # hPa

print(sensor.temperature)
print(sensor.humidity)
print(sensor.pressure)
print(sensor.altitude)

Key things you can do

What you want How to do it
Read temperature (°C) sensor.temperature
Read relative humidity (%) sensor.humidity
Read pressure (hPa) sensor.pressure
Read estimated altitude (m) sensor.altitude
Improve altitude accuracy sensor.sea_level_pressure = 1013.25 (use local station pressure)

Reading the official docs

https://docs.circuitpython.org/projects/bme280/en/latest/

Import from adafruit_bme280.basic for standard use. The docs also include an advanced module with oversampling and filter controls if you need finer tuning of noise versus response speed.

Projects using this library