Adafruit BME680 Library
|
#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=BME68X_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 | setODR (uint8_t odr) |
Setter for Output Data Rate. 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... | |
uint32_t | 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 |
Adafruit_BME680 Class for both I2C and SPI usage. Wraps the Bosch library for Arduino usage
Adafruit_BME680::Adafruit_BME680 | ( | TwoWire * | theWire = &Wire | ) |
Instantiates sensor with i2c.
*theWire | optional Wire object |
Adafruit_BME680::Adafruit_BME680 | ( | int8_t | cspin, |
SPIClass * | theSPI = &SPI |
||
) |
Instantiates sensor with Hardware SPI.
cspin | SPI chip select. |
theSPI | optional SPI object |
Adafruit_BME680::Adafruit_BME680 | ( | int8_t | cspin, |
int8_t | mosipin, | ||
int8_t | misopin, | ||
int8_t | sckpin | ||
) |
Instantiates sensor with Software (bit-bang) SPI.
cspin | SPI chip select |
mosipin | SPI MOSI (Data from microcontroller to sensor) |
misopin | SPI MISO (Data to microcontroller from sensor) |
sckpin | SPI Clock |
bool Adafruit_BME680::begin | ( | uint8_t | addr = BME68X_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.
addr | Optional parameter for the I2C address of BME680. Default is 0x77 |
initSettings | Optional parameter for initializing the sensor settings. Default is true. |
float Adafruit_BME680::readTemperature | ( | void | ) |
Performs a reading and returns the ambient temperature.
float Adafruit_BME680::readPressure | ( | void | ) |
Performs a reading and returns the barometric pressure.
float Adafruit_BME680::readHumidity | ( | void | ) |
Performs a reading and returns the relative humidity.
uint32_t Adafruit_BME680::readGas | ( | void | ) |
Calculates the resistance of the MOX gas sensor.
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).
seaLevel | Sea-level pressure in hPa |
bool Adafruit_BME680::setTemperatureOversampling | ( | uint8_t | oversample | ) |
Setter for Temperature oversampling.
oversample | Oversampling setting, can be BME68X_OS_NONE (turn off Temperature reading), BME68X_OS_1X, BME68X_OS_2X, BME68X_OS_4X, BME68X_OS_8X or BME68X_OS_16X |
bool Adafruit_BME680::setPressureOversampling | ( | uint8_t | oversample | ) |
Setter for Pressure oversampling.
oversample | Oversampling setting, can be BME68X_OS_NONE (turn off Pressure reading), BME68X_OS_1X, BME68X_OS_2X, BME68X_OS_4X, BME68X_OS_8X or BME68X_OS_16X |
bool Adafruit_BME680::setHumidityOversampling | ( | uint8_t | oversample | ) |
Setter for Humidity oversampling.
oversample | Oversampling setting, can be BME68X_OS_NONE (turn off Humidity reading), BME68X_OS_1X, BME68X_OS_2X, BME68X_OS_4X, BME68X_OS_8X or BME68X_OS_16X |
bool Adafruit_BME680::setIIRFilterSize | ( | uint8_t | filtersize | ) |
Setter for IIR filter.
filtersize | Size of the filter (in samples). Can be BME68X_FILTER_SIZE_0 (no filtering), BME68X_FILTER_SIZE_1, BME68X_FILTER_SIZE_3, BME68X_FILTER_SIZE_7, BME68X_FILTER_SIZE_15, BME68X_FILTER_SIZE_31, BME68X_FILTER_SIZE_63, BME68X_FILTER_SIZE_127 |
bool Adafruit_BME680::setGasHeater | ( | uint16_t | heaterTemp, |
uint16_t | heaterTime | ||
) |
Enable and configure gas reading + heater.
heaterTemp | Desired temperature in degrees Centigrade |
heaterTime | Time to keep heater on in milliseconds |
bool Adafruit_BME680::setODR | ( | uint8_t | odr | ) |
Setter for Output Data Rate.
odr | Output data rate setting, can be BME68X_ODR_NONE, BME68X_ODR_0_59_MS, BME68X_ODR_10_MS, BME68X_ODR_20_MS, BME68X_ODR_62_5_MS, BME68X_ODR_125_MS, BME68X_ODR_250_MS, BME68X_ODR_500_MS, BME68X_ODR_1000_MS |
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.
uint32_t Adafruit_BME680::beginReading | ( | void | ) |
Begin an asynchronous reading.
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().
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.
|
static |
Value returned by remainingReadingMillis indicating no asynchronous reading has been initiated by beginReading.
|
static |
Value returned by remainingReadingMillis indicating asynchronous reading is complete and calling endReading will not block.
float Adafruit_BME680::temperature |
Temperature (Celsius) assigned after calling performReading() or endReading()
uint32_t Adafruit_BME680::pressure |
Pressure (Pascals) assigned after calling performReading() or endReading()
float Adafruit_BME680::humidity |
Humidity (RH %) assigned after calling performReading() or endReading()
uint32_t Adafruit_BME680::gas_resistance |
Gas resistor (ohms) assigned after calling performReading() or endReading()