Skip to content

BMP280

Works with

Any CircuitPython board with I2C or SPI

What it does

The BMP280 measures barometric pressure and temperature. Pressure accuracy is ±1 hPa and temperature accuracy is ±1°C. Because atmospheric pressure changes with altitude, the sensor can also be used to estimate elevation above sea level — though this requires knowing the current sea-level pressure for your location to get accurate results. Common applications include weather stations, altitude logging, indoor navigation, and drone flight controllers.

Installing the library

Copy adafruit_bmp280.mpy from the Adafruit CircuitPython Bundle to your board's lib/ folder. Also copy adafruit_bus_device/ if it is not already present.

Quick start

import board
import busio
import adafruit_bmp280

i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)

# Set local sea-level pressure for accurate altitude calculation
sensor.sea_level_pressure = 1013.25  # hPa — adjust to your local value

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

Key things you can do

What you want How to do it
Read temperature (°C) sensor.temperature
Read pressure (hPa) sensor.pressure
Read estimated altitude (m) sensor.altitude
Improve altitude accuracy sensor.sea_level_pressure = 1013.25 (use local station pressure)
Use SPI instead of I2C adafruit_bmp280.Adafruit_BMP280_SPI(spi, cs)

Reading the official docs

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

The module exports both Adafruit_BMP280_I2C and Adafruit_BMP280_SPI — choose the one that matches your wiring. The sea_level_pressure attribute is documented on the base class; look for it in the API reference under the shared properties section.

Projects using this library