Package com.diozero.devices
Class BME68x
- java.lang.Object
-
- com.diozero.devices.BME68x
-
- All Implemented Interfaces:
DeviceInterface
,BarometerInterface
,HygrometerInterface
,SensorInterface
,ThermometerInterface
,AutoCloseable
public class BME68x extends Object implements BarometerInterface, ThermometerInterface, HygrometerInterface
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BME68x.Data
static class
BME68x.HeaterConfig
static class
BME68x.HeaterProfile
Gas heater profile.static class
BME68x.IirFilterCoefficient
Infinite Impulse Response (IIR) filter.static class
BME68x.ODR
Operating (Output?) Data Rate (ODR) - standby time.static class
BME68x.OperatingMode
Operating mode.static class
BME68x.OversamplingMultiplier
Oversampling multiplier.
-
Field Summary
Fields Modifier and Type Field Description static int
ALT_DEVICE_ADDRESS
static int
DEVICE_ADDRESS
static int
MAX_HUMIDITY_PERCENT
static int
MAX_PRESSURE_HPA
static int
MAX_TEMPERATURE_CELSIUS
static int
MIN_HUMIDITY_PERCENT
static int
MIN_PRESSURE_HPA
static int
MIN_TEMPERATURE_CELSIUS
static int
NUM_FIELDS
static int
VARIANT_ID_BM680
static int
VARIANT_ID_BM688
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
calculateMeasureDuration(BME68x.OperatingMode targetOperatingMode)
Calculate the duration in microseconds to take to take TPHG readings using the currently configured humidity, temperature and pressure oversampling modes.static int
calculateMeasureDuration(BME68x.OversamplingMultiplier humidityOversampling, BME68x.OversamplingMultiplier temperatureOversampling, BME68x.OversamplingMultiplier pressureOversampling, BME68x.OperatingMode targetOperatingMode)
Calculate the duration in microseconds to take to take TPHG readings using the specified humidity, temperature and pressure oversampling modes.void
close()
Close the driver and the underlying device.byte
getChipId()
Get the chip id.float
getGasResistance()
BME68x.HeaterConfig
getHeaterConfiguration()
Get the gas configuration of the sensor.BME68x.OversamplingMultiplier
getHumidityOversample()
Get humidity oversampling modeBME68x.IirFilterCoefficient
getIirFilterConfig()
Get the IIR filter configurationBME68x.ODR
getOdr()
BME68x.OperatingMode
getOperatingMode()
Get the operating mode.float
getPressure()
Get the pressure in kPaBME68x.OversamplingMultiplier
getPressureOversample()
Get pressure oversampling modefloat
getRelativeHumidity()
Get the relative humidity in percent.BME68x.Data[]
getSensorData()
Read the pressure, temperature and humidity and gas data from the sensor, compensates the data and store it in the bme68x_data structure instance passed by the user.BME68x.Data[]
getSensorData(BME68x.OperatingMode operatingMode)
Read the pressure, temperature and humidity and gas data from the sensor, compensates the data and store it in the bme68x_data structure instance passed by the user.float
getTemperature()
Get temperature in degrees celsiusBME68x.OversamplingMultiplier
getTemperatureOversample()
Get temperature oversampling modebyte
getUniqueId()
Get the chip's identifier.byte
getVariantId()
Get the chip variant id.void
initialise()
Initialise the device.void
lowGasSelfTestCheck()
Self-test of low gas variant of BME68X (i.e.void
setConfiguration(BME68x.OversamplingMultiplier humidityOversampling, BME68x.OversamplingMultiplier temperatureOversampling, BME68x.OversamplingMultiplier pressureOversampling, BME68x.IirFilterCoefficient filter, BME68x.ODR odr)
Set the oversampling, filter and odr configuration.void
setHeaterConfiguration(BME68x.OperatingMode targetOperatingMode, BME68x.HeaterConfig heaterConfig)
void
setOperatingMode(BME68x.OperatingMode mode)
Set the operating mode.void
softReset()
Initiate a soft reset.
-
-
-
Field Detail
-
VARIANT_ID_BM680
public static final int VARIANT_ID_BM680
- See Also:
- Constant Field Values
-
VARIANT_ID_BM688
public static final int VARIANT_ID_BM688
- See Also:
- Constant Field Values
-
MIN_TEMPERATURE_CELSIUS
public static int MIN_TEMPERATURE_CELSIUS
-
MAX_TEMPERATURE_CELSIUS
public static int MAX_TEMPERATURE_CELSIUS
-
MIN_PRESSURE_HPA
public static int MIN_PRESSURE_HPA
-
MAX_PRESSURE_HPA
public static int MAX_PRESSURE_HPA
-
MIN_HUMIDITY_PERCENT
public static int MIN_HUMIDITY_PERCENT
-
MAX_HUMIDITY_PERCENT
public static int MAX_HUMIDITY_PERCENT
-
DEVICE_ADDRESS
public static final int DEVICE_ADDRESS
- See Also:
- Constant Field Values
-
ALT_DEVICE_ADDRESS
public static final int ALT_DEVICE_ADDRESS
- See Also:
- Constant Field Values
-
NUM_FIELDS
public static final int NUM_FIELDS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BME68x
public BME68x()
-
BME68x
public BME68x(int controller)
Create a new BME680 sensor driver connected on the given bus.- Parameters:
controller
- I2C bus the sensor is connected to.
-
BME68x
public BME68x(int controller, int address)
Create a new BME680 sensor driver connected on the given bus and address.- Parameters:
controller
- I2C bus the sensor is connected to.address
- I2C address of the sensor.
-
-
Method Detail
-
close
public void close()
Close the driver and the underlying device.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
initialise
public void initialise()
Initialise the device. bme68x_init
-
softReset
public void softReset()
Initiate a soft reset. bme68x_soft_reset
-
getChipId
public byte getChipId()
Get the chip id. read_chip_id- Returns:
- chip identifier
-
getVariantId
public byte getVariantId()
Get the chip variant id. read_variant_id- Returns:
- chip variant identifier
-
getUniqueId
public byte getUniqueId()
Get the chip's identifier. Note not documented.- Returns:
- chip unique id
-
getOperatingMode
public BME68x.OperatingMode getOperatingMode()
Get the operating mode. bme68x_get_op_mode- Returns:
- Current operating mode
-
setOperatingMode
public void setOperatingMode(BME68x.OperatingMode mode)
Set the operating mode. bme68x_set_op_mode- Parameters:
mode
- Target operating mode
-
setConfiguration
public void setConfiguration(BME68x.OversamplingMultiplier humidityOversampling, BME68x.OversamplingMultiplier temperatureOversampling, BME68x.OversamplingMultiplier pressureOversampling, BME68x.IirFilterCoefficient filter, BME68x.ODR odr)
Set the oversampling, filter and odr configuration. bme68x_set_conf- Parameters:
humidityOversampling
- Humidity oversampling modetemperatureOversampling
- Temperature oversampling modepressureOversampling
- Pressure oversampling modefilter
- IIR Filter coefficientodr
- Standby time between sequential mode measurement profiles (BME688 only).
-
getHumidityOversample
public BME68x.OversamplingMultiplier getHumidityOversample()
Get humidity oversampling mode- Returns:
- Current humidity oversampling mode
-
getTemperatureOversample
public BME68x.OversamplingMultiplier getTemperatureOversample()
Get temperature oversampling mode- Returns:
- Current temperature oversampling mode
-
getPressureOversample
public BME68x.OversamplingMultiplier getPressureOversample()
Get pressure oversampling mode- Returns:
- Current pressure oversampling mode
-
getIirFilterConfig
public BME68x.IirFilterCoefficient getIirFilterConfig()
Get the IIR filter configuration- Returns:
- IIR filter configuration
-
getOdr
public BME68x.ODR getOdr()
-
calculateMeasureDuration
public int calculateMeasureDuration(BME68x.OperatingMode targetOperatingMode)
Calculate the duration in microseconds to take to take TPHG readings using the currently configured humidity, temperature and pressure oversampling modes. Can be used to get the remaining duration that can be used for heating. bme68x_get_meas_dur- Parameters:
targetOperatingMode
- Operating mode- Returns:
- remaining duration in microseconds
-
calculateMeasureDuration
public static int calculateMeasureDuration(BME68x.OversamplingMultiplier humidityOversampling, BME68x.OversamplingMultiplier temperatureOversampling, BME68x.OversamplingMultiplier pressureOversampling, BME68x.OperatingMode targetOperatingMode)
Calculate the duration in microseconds to take to take TPHG readings using the specified humidity, temperature and pressure oversampling modes. Can be used to get the remaining duration that can be used for heating. bme68x_get_meas_dur- Parameters:
humidityOversampling
- Humidity oversampling modetemperatureOversampling
- Temperature oversampling modepressureOversampling
- Pressure oversampling modetargetOperatingMode
- Operating mode- Returns:
- remaining duration in microseconds
-
getSensorData
public BME68x.Data[] getSensorData()
Read the pressure, temperature and humidity and gas data from the sensor, compensates the data and store it in the bme68x_data structure instance passed by the user. bme68x_get_data- Returns:
- Sensor data
-
getSensorData
public BME68x.Data[] getSensorData(BME68x.OperatingMode operatingMode)
Read the pressure, temperature and humidity and gas data from the sensor, compensates the data and store it in the bme68x_data structure instance passed by the user. bme68x_get_data- Parameters:
operatingMode
- Device operating mode- Returns:
- Sensor data
-
getTemperature
public float getTemperature()
Description copied from interface:ThermometerInterface
Get temperature in degrees celsius- Specified by:
getTemperature
in interfaceThermometerInterface
- Returns:
- Temperature (deg C)
-
getPressure
public float getPressure()
Description copied from interface:BarometerInterface
Get the pressure in kPa- Specified by:
getPressure
in interfaceBarometerInterface
- Returns:
- pressure in kPa
-
getRelativeHumidity
public float getRelativeHumidity()
Description copied from interface:HygrometerInterface
Get the relative humidity in percent.- Specified by:
getRelativeHumidity
in interfaceHygrometerInterface
- Returns:
- The relative humidity in percent.
-
getGasResistance
public float getGasResistance()
-
getHeaterConfiguration
public BME68x.HeaterConfig getHeaterConfiguration()
Get the gas configuration of the sensor. Note not fully working hence package-private. bme68x_get_heatr_conf- Returns:
- the heater configuration
-
setHeaterConfiguration
public void setHeaterConfiguration(BME68x.OperatingMode targetOperatingMode, BME68x.HeaterConfig heaterConfig)
-
lowGasSelfTestCheck
public void lowGasSelfTestCheck()
Self-test of low gas variant of BME68X (i.e. the BME680) bme68x_low_gas_selftest_check
-
-