adafruit_bme280.basic

CircuitPython driver from BME280 Temperature, Humidity and Barometric Pressure sensor

  • Author(s): ladyada, Jose David M.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_bme280.basic.Adafruit_BME280(bus_implementation: I2C_Impl | SPI_Impl)[source]

Driver from BME280 Temperature, Humidity and Barometric Pressure sensor

Note

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

property altitude: float

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

property humidity: float

The relative humidity in RH %

property mode: int

Operation mode Allowed values are the constants MODE_*

property pressure: float

The compensated pressure in hectoPascals.

property relative_humidity: float

The relative humidity in RH %

sea_level_pressure

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

property temperature: float

The compensated temperature in degrees Celsius.

class adafruit_bme280.basic.Adafruit_BME280_I2C(i2c: I2C, address: int = 119)[source]

Driver for BME280 connected over I2C

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

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

Note

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

Quickstart: Importing and using the BME280

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

import board
from adafruit_bme280 import basic as adafruit_bme280

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
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

You need to setup the pressure at sea level

bme280.sea_level_pressure = 1013.25

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

temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude
class adafruit_bme280.basic.Adafruit_BME280_SPI(spi: SPI, cs: DigitalInOut, baudrate: int = 100000)[source]

Driver for BME280 connected over SPI

Parameters:
  • spi (SPI) – SPI device

  • cs (DigitalInOut) – Chip Select

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

Note

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

Quickstart: Importing and using the BME280

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

import board
from digitalio import DigitalInOut
from adafruit_bme280 import basic as adafruit_bme280

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_bme280.Adafruit_BME280_SPI(spi, cs)

You need to setup the pressure at sea level

bme280.sea_level_pressure = 1013.25

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

temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude
adafruit_bme280.basic.IIR_FILTER_DISABLE = 0

standby timeconstant values TC_X[_Y] where X=milliseconds and Y=tenths of a millisecond

adafruit_bme280.basic.MODE_NORMAL = 3

Other Registers

adafruit_bme280.basic.OVERSCAN_X16 = 5

mode values

adafruit_bme280.basic.STANDBY_TC_125 = 2

mode values

adafruit_bme280.advanced

CircuitPython driver from BME280 Temperature, Humidity and Barometric Pressure sensor

  • Author(s): ladyada, Jose David M.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_bme280.advanced.Adafruit_BME280_Advanced(proxy: I2C_Impl | SPI_Impl)[source]

Driver from BME280 Temperature, Humidity and Barometric Pressure sensor

Note

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

property iir_filter: int

Controls the time constant of the IIR filter Allowed values are the constants IIR_FILTER_*

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 overscan_humidity: int

Humidity Oversampling Allowed values are the constants OVERSCAN_*

property overscan_pressure: int

Pressure Oversampling Allowed values are the constants OVERSCAN_*

property overscan_temperature: int

Temperature Oversampling Allowed values are the constants OVERSCAN_*

property standby_period: int

Control the inactive period when in Normal mode Allowed standby periods are the constants STANDBY_TC_*

class adafruit_bme280.advanced.Adafruit_BME280_I2C(i2c: I2C, address: int = micropython.const)[source]

Driver for BME280 connected over I2C

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

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

Note

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

Quickstart: Importing and using the BME280

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

import board
import adafruit_bme280.advanced as adafruit_bme280

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
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

You need to setup the pressure at sea level

bme280.sea_level_pressure = 1013.25

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

temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude
class adafruit_bme280.advanced.Adafruit_BME280_SPI(spi: SPI, cs: DigitalInOut, baudrate: int = 100000)[source]

Driver for BME280 connected over SPI

Parameters:
  • spi (SPI) – SPI device

  • cs (DigitalInOut) – Chip Select

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

Note

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

Quickstart: Importing and using the BME280

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

import board
from digitalio import DigitalInOut
import adafruit_bme280.advanced as adafruit_bme280

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_bme280.Adafruit_BME280_SPI(spi, cs)

You need to setup the pressure at sea level

bme280.sea_level_pressure = 1013.25

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

temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude

Provides the protocol objects for I2C and SPI

class adafruit_bme280.protocol.I2C_Impl(i2c: I2C, address: int)[source]

Protocol implementation for the I2C bus.

read_register(register: int, length: int) bytearray[source]

Read from the device register.

write_register_byte(register: int, value: int) None[source]

Write to the device register

class adafruit_bme280.protocol.SPI_Impl(spi: SPI, cs: DigitalInOut, baudrate: int = 100000)[source]

Protocol implemenation for the SPI bus.

read_register(register: int, length: int) bytearray[source]

Read from the device register.

write_register_byte(register: int, value: int) None[source]

Write value to the device register.