Adafruit BME680 Library
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Adafruit_BME680 Class Reference

#include <Adafruit_BME680.h>

Public Member Functions

 Adafruit_BME680 (TwoWire *theWire=&Wire)
 Instantiates sensor with i2c. More...
 
 Adafruit_BME680 (int8_t cspin, SPIClass *theSPI=&SPI)
 Instantiates sensor with Hardware SPI. More...
 
 Adafruit_BME680 (int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
 Instantiates sensor with Software (bit-bang) SPI. More...
 
bool begin (uint8_t addr=BME680_DEFAULT_ADDRESS, bool initSettings=true)
 Initializes the sensor Hardware ss initialized, verifies it is in the I2C or SPI bus, then reads calibration data in preparation for sensor reads. More...
 
float readTemperature ()
 Performs a reading and returns the ambient temperature. More...
 
float readPressure ()
 Performs a reading and returns the barometric pressure. More...
 
float readHumidity ()
 Performs a reading and returns the relative humidity. More...
 
uint32_t readGas ()
 Calculates the resistance of the MOX gas sensor. More...
 
float readAltitude (float seaLevel)
 Calculates the altitude (in meters). Reads the current atmostpheric pressure (in hPa) from the sensor and calculates via the provided sea-level pressure (in hPa). More...
 
bool setTemperatureOversampling (uint8_t os)
 Setter for Temperature oversampling. More...
 
bool setPressureOversampling (uint8_t os)
 Setter for Pressure oversampling. More...
 
bool setHumidityOversampling (uint8_t os)
 Setter for Humidity oversampling. More...
 
bool setIIRFilterSize (uint8_t fs)
 Setter for IIR filter. More...
 
bool setGasHeater (uint16_t heaterTemp, uint16_t heaterTime)
 Enable and configure gas reading + heater. More...
 
bool performReading ()
 Performs a full reading of all 4 sensors in the BME680. Assigns the internal Adafruit_BME680::temperature, Adafruit_BME680::pressure, Adafruit_BME680::humidity and Adafruit_BME680::gas_resistance member variables. More...
 
unsigned long beginReading ()
 Begin an asynchronous reading. More...
 
bool endReading ()
 End an asynchronous reading. If the asynchronous reading is still in progress, block until it ends. If no asynchronous reading has started, this is equivalent to performReading(). More...
 
int remainingReadingMillis ()
 Get remaining time for an asynchronous reading. If the asynchronous reading is still in progress, how many millis until its completion. If the asynchronous reading is completed, 0. If no asynchronous reading has started, -1 or Adafruit_BME680::reading_not_started. Does not block. More...
 

Public Attributes

float temperature
 
uint32_t pressure
 
float humidity
 
uint32_t gas_resistance
 

Static Public Attributes

static constexpr int reading_not_started = -1
 
static constexpr int reading_complete = 0
 

Detailed Description

Adafruit_BME680 Class for both I2C and SPI usage. Wraps the Bosch library for Arduino usage

Constructor & Destructor Documentation

◆ Adafruit_BME680() [1/3]

Adafruit_BME680::Adafruit_BME680 ( TwoWire *  theWire = &Wire)

Instantiates sensor with i2c.

Parameters
*theWireoptional Wire object

◆ Adafruit_BME680() [2/3]

Adafruit_BME680::Adafruit_BME680 ( int8_t  cspin,
SPIClass *  theSPI = &SPI 
)

Instantiates sensor with Hardware SPI.

Parameters
cspinSPI chip select.
theSPIoptional SPI object

◆ Adafruit_BME680() [3/3]

Adafruit_BME680::Adafruit_BME680 ( int8_t  cspin,
int8_t  mosipin,
int8_t  misopin,
int8_t  sckpin 
)

Instantiates sensor with Software (bit-bang) SPI.

Parameters
cspinSPI chip select
mosipinSPI MOSI (Data from microcontroller to sensor)
misopinSPI MISO (Data to microcontroller from sensor)
sckpinSPI Clock

Member Function Documentation

◆ begin()

bool Adafruit_BME680::begin ( uint8_t  addr = BME680_DEFAULT_ADDRESS,
bool  initSettings = true 
)

Initializes the sensor Hardware ss initialized, verifies it is in the I2C or SPI bus, then reads calibration data in preparation for sensor reads.

Parameters
addrOptional parameter for the I2C address of BME680. Default is 0x77
initSettingsOptional parameter for initializing the sensor settings. Default is true.
Returns
True on sensor initialization success. False on failure.

◆ readTemperature()

float Adafruit_BME680::readTemperature ( void  )

Performs a reading and returns the ambient temperature.

Returns
Temperature in degrees Centigrade

◆ readPressure()

float Adafruit_BME680::readPressure ( void  )

Performs a reading and returns the barometric pressure.

Returns
Barometic pressure in Pascals

◆ readHumidity()

float Adafruit_BME680::readHumidity ( void  )

Performs a reading and returns the relative humidity.

Returns
Relative humidity as floating point

◆ readGas()

uint32_t Adafruit_BME680::readGas ( void  )

Calculates the resistance of the MOX gas sensor.

Returns
Resistance in Ohms

◆ readAltitude()

float Adafruit_BME680::readAltitude ( float  seaLevel)

Calculates the altitude (in meters). Reads the current atmostpheric pressure (in hPa) from the sensor and calculates via the provided sea-level pressure (in hPa).

Parameters
seaLevelSea-level pressure in hPa
Returns
Altitude in meters

◆ setTemperatureOversampling()

bool Adafruit_BME680::setTemperatureOversampling ( uint8_t  oversample)

Setter for Temperature oversampling.

Parameters
oversampleOversampling setting, can be BME680_OS_NONE (turn off Temperature reading), BME680_OS_1X, BME680_OS_2X, BME680_OS_4X, BME680_OS_8X or BME680_OS_16X
Returns
True on success, False on failure

◆ setPressureOversampling()

bool Adafruit_BME680::setPressureOversampling ( uint8_t  oversample)

Setter for Pressure oversampling.

Parameters
oversampleOversampling setting, can be BME680_OS_NONE (turn off Pressure reading), BME680_OS_1X, BME680_OS_2X, BME680_OS_4X, BME680_OS_8X or BME680_OS_16X
Returns
True on success, False on failure

◆ setHumidityOversampling()

bool Adafruit_BME680::setHumidityOversampling ( uint8_t  oversample)

Setter for Humidity oversampling.

Parameters
oversampleOversampling setting, can be BME680_OS_NONE (turn off Humidity reading), BME680_OS_1X, BME680_OS_2X, BME680_OS_4X, BME680_OS_8X or BME680_OS_16X
Returns
True on success, False on failure

◆ setIIRFilterSize()

bool Adafruit_BME680::setIIRFilterSize ( uint8_t  filtersize)

Setter for IIR filter.

Parameters
filtersizeSize of the filter (in samples). Can be BME680_FILTER_SIZE_0 (no filtering), BME680_FILTER_SIZE_1, BME680_FILTER_SIZE_3, BME680_FILTER_SIZE_7, BME680_FILTER_SIZE_15, BME680_FILTER_SIZE_31, BME680_FILTER_SIZE_63, BME680_FILTER_SIZE_127
Returns
True on success, False on failure

◆ setGasHeater()

bool Adafruit_BME680::setGasHeater ( uint16_t  heaterTemp,
uint16_t  heaterTime 
)

Enable and configure gas reading + heater.

Parameters
heaterTempDesired temperature in degrees Centigrade
heaterTimeTime to keep heater on in milliseconds
Returns
True on success, False on failure

◆ performReading()

bool Adafruit_BME680::performReading ( void  )

Performs a full reading of all 4 sensors in the BME680. Assigns the internal Adafruit_BME680::temperature, Adafruit_BME680::pressure, Adafruit_BME680::humidity and Adafruit_BME680::gas_resistance member variables.

Returns
True on success, False on failure

◆ beginReading()

unsigned long Adafruit_BME680::beginReading ( void  )

Begin an asynchronous reading.

Returns
When the reading would be ready as absolute time in millis().

◆ endReading()

bool Adafruit_BME680::endReading ( void  )

End an asynchronous reading. If the asynchronous reading is still in progress, block until it ends. If no asynchronous reading has started, this is equivalent to performReading().

Returns
Whether success.

◆ remainingReadingMillis()

int Adafruit_BME680::remainingReadingMillis ( void  )

Get remaining time for an asynchronous reading. If the asynchronous reading is still in progress, how many millis until its completion. If the asynchronous reading is completed, 0. If no asynchronous reading has started, -1 or Adafruit_BME680::reading_not_started. Does not block.

Returns
Remaining millis until endReading will not block if invoked.

Member Data Documentation

◆ reading_not_started

constexpr int Adafruit_BME680::reading_not_started = -1
static

Value returned by remainingReadingMillis indicating no asynchronous reading has been initiated by beginReading.

◆ reading_complete

constexpr int Adafruit_BME680::reading_complete = 0
static

Value returned by remainingReadingMillis indicating asynchronous reading is complete and calling endReading will not block.

◆ temperature

float Adafruit_BME680::temperature

Temperature (Celsius) assigned after calling performReading() or endReading()

◆ pressure

uint32_t Adafruit_BME680::pressure

Pressure (Pascals) assigned after calling performReading() or endReading()

◆ humidity

float Adafruit_BME680::humidity

Humidity (RH %) assigned after calling performReading() or endReading()

◆ gas_resistance

uint32_t Adafruit_BME680::gas_resistance

Gas resistor (ohms) assigned after calling performReading() or endReading()


The documentation for this class was generated from the following files: