adafruit_bme680

CircuitPython library for BME680 temperature, pressure and humidity sensor.

  • Author(s): Limor Fried

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_bme680.Adafruit_BME680(*, refresh_rate=10)[source]

Driver from BME680 air quality sensor

Parameters:refresh_rate (int) – Maximum number of readings per second. Faster property reads will be from the previous reading.
altitude

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

filter_size

The filter size for the built in IIR filter

gas

The gas resistance in ohms

humidity

The relative humidity in RH %

humidity_oversample

The oversampling for humidity sensor

pressure

The barometric pressure in hectoPascals

pressure_oversample

The oversampling for pressure sensor

relative_humidity

The relative humidity in RH %

sea_level_pressure = None

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

temperature

The compensated temperature in degrees Celsius.

temperature_oversample

The oversampling for temperature sensor

class adafruit_bme680.Adafruit_BME680_I2C(i2c, address=119, debug=False, *, refresh_rate=10)[source]

Driver for I2C connected BME680.

Parameters:
  • i2c (I2C) – The I2C bus the BME680 is connected to.
  • address (int) – I2C device address. Defaults to 0x77
  • debug (bool) – Print debug statements when True. Defaults to False
  • refresh_rate (int) – Maximum number of readings per second. Faster property reads will be from the previous reading.

Quickstart: Importing and using the BME680

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

import board
import adafruit_bme680

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
bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c)

You need to setup the pressure at sea level

bme680.sea_level_pressure = 1013.25

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

temperature = bme680.temperature
gas = bme680.gas
relative_humidity = bme680.relative_humidity
pressure = bme680.pressure
altitude = bme680.altitude
class adafruit_bme680.Adafruit_BME680_SPI(spi, cs, baudrate=100000, debug=False, *, refresh_rate=10)[source]

Driver for SPI connected BME680.

Parameters:
  • spi (SPI) – SPI device
  • cs (DigitalInOut) – Chip Select
  • debug (bool) – Print debug statements when True. Defaults to False
  • baudrate (int) – Clock rate, default is 100000
  • refresh_rate (int) – Maximum number of readings per second. Faster property reads will be from the previous reading.

Quickstart: Importing and using the BME680

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

import board
from digitalio import DigitalInOut, Direction
import adafruit_bme680

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

cs = digitalio.DigitalInOut(board.D10)
spi = board.SPI()
bme680 = adafruit_bme680.Adafruit_BME680_SPI(spi, cs)

You need to setup the pressure at sea level

bme680.sea_level_pressure = 1013.25

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

temperature = bme680.temperature
gas = bme680.gas
relative_humidity = bme680.relative_humidity
pressure = bme680.pressure
altitude = bme680.altitude