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

#include <Adafruit_BME680.h>

Public Member Functions

 Adafruit_BME680 (int8_t cspin=-1)
 Instantiates sensor with Hardware SPI or I2C. 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)
 Initializes the sensor. More...
 
float readTemperature (void)
 Performs a reading and returns the ambient temperature. More...
 
float readPressure (void)
 Performs a reading and returns the barometric pressure. More...
 
float readHumidity (void)
 Performs a reading and returns the relative humidity. More...
 
uint32_t readGas (void)
 Calculates the resistance of the MOX gas sensor. More...
 
float readAltitude (float seaLevel)
 Calculates the altitude (in meters). 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 (void)
 Performs a full reading of all 4 sensors in the BME680. More...
 

Public Attributes

float temperature
 Temperature (Celsius) assigned after calling performReading()
 
float pressure
 Pressure (Pascals) assigned after calling performReading()
 
float humidity
 Humidity (RH %) assigned after calling performReading()
 
float gas_resistance
 Gas resistor (ohms) assigned after calling performReading()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Adafruit_BME680() [1/2]

Adafruit_BME680::Adafruit_BME680 ( int8_t  cspin = -1)

Instantiates sensor with Hardware SPI or I2C.

Parameters
cspinSPI chip select. If not passed in, I2C will be used

◆ Adafruit_BME680() [2/2]

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)

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
Returns
True on sensor initialization 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

◆ 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

◆ readGas()

uint32_t Adafruit_BME680::readGas ( void  )

Calculates the resistance of the MOX gas sensor.

Returns
Resistance in Ohms

◆ readHumidity()

float Adafruit_BME680::readHumidity ( void  )

Performs a reading and returns the relative humidity.

Returns
Relative humidity as floating point

◆ readPressure()

float Adafruit_BME680::readPressure ( void  )

Performs a reading and returns the barometric pressure.

Returns
Barometic pressure in Pascals

◆ readTemperature()

float Adafruit_BME680::readTemperature ( void  )

Performs a reading and returns the ambient temperature.

Returns
Temperature in degrees Centigrade

◆ 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

◆ 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

◆ setPressureOversampling()

bool Adafruit_BME680::setPressureOversampling ( uint8_t  os)

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

◆ 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

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