adafruit_bmp280

CircuitPython driver from BMP280 Temperature and Barometric Pressure sensor

  • Author(s): ladyada

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_bmp280.Adafruit_BMP280[source]

Base BMP280 object. Use Adafruit_BMP280_I2C or Adafruit_BMP280_SPI instead of this. This checks the BMP280 was found, reads the coefficients and enables the sensor for continuous reads

Note

The operational range of the BMP280 is 300-1100 hPa. Pressure measurements outside this range may not be as accurate.

property altitude: float

The altitude based on the sea level pressure (sea_level_pressure) - which you must enter ahead of time)

property iir_filter: int

Controls the time constant of the IIR filter Allowed values are set in the IIR_FILTER enum class

property measurement_time_max: float

Maximum time in milliseconds required to complete a measurement in normal mode

property measurement_time_typical: float

Typical time in milliseconds required to complete a measurement in normal mode

property mode: int

Operation mode Allowed values are set in the MODE enum class

property overscan_pressure: int

Pressure Oversampling Allowed values are set in the OVERSCAN enum class

property overscan_temperature: int

Temperature Oversampling Allowed values are set in the OVERSCAN enum class

property pressure: float | None

The compensated pressure in hectoPascals. returns None if pressure measurement is disabled

sea_level_pressure

Pressure in hectoPascals at sea level. Used to calibrate altitude.

property standby_period: int

Control the inactive period when in Normal mode Allowed standby periods are set the STANDBY enum class

property temperature: float

The compensated temperature in degrees Celsius.

class adafruit_bmp280.Adafruit_BMP280_I2C(i2c: I2C, address: int = 119)[source]

Driver for I2C connected BMP280.

Parameters:
  • i2c (I2C) – The I2C bus the BMP280 is connected to.

  • address (int) – I2C device address. Defaults to 0x77. but another address can be passed in as an argument

Quickstart: Importing and using the BMP280

Here is an example of using the BMP280_I2C class. First you will need to import the libraries to use the sensor

import board
import adafruit_bmp280

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA
bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)

You need to setup the pressure at sea level

bmp280.sea_level_pressure = 1013.25

Now you have access to the temperature, pressure and altitude attributes

temperature = bmp280.temperature
pressure = bmp280.pressure
altitude = bmp280.altitude
class adafruit_bmp280.Adafruit_BMP280_SPI(spi: SPI, cs: DigitalInOut, baudrate=100000)[source]

Driver for SPI connected BMP280.

Parameters:
  • spi (SPI) – SPI device

  • cs (DigitalInOut) – Chip Select

  • baudrate (int) – Clock rate, default is 100000. Can be changed with baudrate()

Quickstart: Importing and using the BMP280

Here is an example of using the BMP280_SPI class. First you will need to import the libraries to use the sensor

import board
from digitalio import DigitalInOut, Direction
import adafruit_bmp280

Once this is done you can define your board.SPI object and define your sensor object

cs = digitalio.DigitalInOut(board.D10)
spi = board.SPI()
bme280 = adafruit_bmp280.Adafruit_bmp280_SPI(spi, cs)

You need to setup the pressure at sea level

bmp280.sea_level_pressure = 1013.25

Now you have access to the temperature, pressure and altitude attributes

temperature = bmp280.temperature
pressure = bmp280.pressure
altitude = bmp280.altitude