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[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.

altitude

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

humidity

The relative humidity in RH % returns None if humidity measurement is disabled

mode

Operation mode Allowed values are the constants MODE_*

pressure

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

relative_humidity

The relative humidity in RH % returns None if humidity measurement is disabled

sea_level_pressure = None

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

temperature

The compensated temperature in degrees Celsius.

class adafruit_bme280.basic.Adafruit_BME280_I2C(i2c, address=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, cs, baudrate=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

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

adafruit_bme280.basic.MODE_NORMAL

Other Registers

adafruit_bme280.basic.OVERSCAN_X16

mode values

adafruit_bme280.basic.STANDBY_TC_125

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[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.

iir_filter

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

measurement_time_max

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

measurement_time_typical

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

overscan_humidity

Humidity Oversampling Allowed values are the constants OVERSCAN_*

overscan_pressure

Pressure Oversampling Allowed values are the constants OVERSCAN_*

overscan_temperature

Temperature Oversampling Allowed values are the constants OVERSCAN_*

standby_period

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

class adafruit_bme280.advanced.Adafruit_BME280_I2C(i2c, address=<sphinx.ext.autodoc.importer._MockObject object>)[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, cs, baudrate=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