M5Unit-ENV 1.2.0 git rev:d576302
Loading...
Searching...
No Matches
m5::unit::UnitBME688 Class Reference

BME688 unit. More...

#include <unit_BME688.hpp>

Inheritance diagram for m5::unit::UnitBME688:

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitBME688 (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
void setAambientTemperature (const int8_t temp)
 Sets the ambient temperature.
 
bool readCalibration (bme688::bme68xCalibration &c)
 Read calibration.
 
bool writeCalibration (const bme688::bme68xCalibration &c)
 write calibration
 
uint32_t calculateMeasurementInterval (const bme688::Mode mode, const bme688::bme68xConf &s)
 Calculation of measurement intervals without heater.
 
bool readUniqueID (uint32_t &id)
 Read unique ID.
 
bool softReset ()
 Software reset.
 
bool selfTest ()
 Self-test.
 
bool writeMode (const bme688::Mode m)
 Write operation mode.
 
bool readMode (bme688::Mode &m)
 Read operation mode.
 
Configuration for begin
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
Properties
bme688::Mode mode () const
 Current mode.
 
const bme688::bme68xCalibrationcalibration () const
 Gets the Calibration.
 
const bme688::bme68xConftphSetting () const
 Gets the TPH setting.
 
const bme688::bme68xHeatrConfheaterSetting () const
 Gets the heater setiing.
 
int8_t ambientTemperature () const
 Gets the ambient temperature.
 
Measurement data by periodic
float iaq () const
 Oldest measured IAQ.
 
float temperature () const
 Oldest measured temperature (Celsius)
 
float pressure () const
 Oldest measured pressure (Pa)
 
float humidity () const
 Oldest measured humidity (%)
 
float gas () const
 Oldest measured gas (Ohm)
 
TPH(Temperature,Pressure,Humidity)
bool readTPHSetting (bme688::bme68xConf &s)
 Read TPH setting.
 
bool readOversamplingTemperature (bme688::Oversampling &os)
 Read temperature oversampling.
 
bool readOversamplingPressure (bme688::Oversampling &os)
 Read pressure oversampling.
 
bool readIIRFilter (bme688::Filter &f)
 Read IIRFilter.
 
bool readOversamplingHumidity (bme688::Oversampling &os)
 Read humidity oversampling.
 
bool writeTPHSetting (const bme688::bme68xConf &s)
 Write TPH setting.
 
bool writeOversampling (const bme688::Oversampling t, const bme688::Oversampling p, const bme688::Oversampling h)
 Wite oversamplings.
 
bool writeOversamplingTemperature (const bme688::Oversampling os)
 Write temperature oversampling.
 
bool writeOversamplingPressure (const bme688::Oversampling os)
 Write pressure oversampling.
 
bool writeOversamplingHumidity (const bme688::Oversampling os)
 Write humidity oversampling.
 
bool writeIIRFilter (const bme688::Filter f)
 Write IIRFilter.
 
Heater
bool readHeaterSetting (bme688::bme68xHeatrConf &hs)
 Read heater setting.
 
bool writeHeaterSetting (const bme688::Mode mode, const bme688::bme68xHeatrConf &hs)
 Write heater setting.
 
Periodic measurement
bool startPeriodicMeasurement (const bme688::Mode m)
 Start periodic measurement without BSEC2.
 
bool startPeriodicMeasurement (const uint32_t subscribe_bits, const bme688::bsec2::SampleRate sr=bme688::bsec2::SampleRate::LowPower)
 Start periodic measurement using BSEC2.
 
bool startPeriodicMeasurement (const bsec_virtual_sensor_t *ss, const size_t len, const bme688::bsec2::SampleRate sr=bme688::bsec2::SampleRate::LowPower)
 Start periodic measurement using BSEC2.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
Single shot measurement
bool measureSingleShot (bme688::bme68xData &data)
 Take a single measurement.
 
Bosch BSEC2 wrapper
Warning
Not available for NanoC6
float bsec2GetTemperatureOffset () const
 Gets the temperature offset(Celsius)
 
void bsec2SetTemperatureOffset (const float offset)
 Set the temperature offset(Celsius)
 
const bsec_version_t & bsec2Version () const
 Gets the BSEC2 library version.
 
bool bsec2SetConfig (const uint8_t *cfg, const size_t sz=BSEC_MAX_PROPERTY_BLOB_SIZE)
 Update algorithm configuration parameters Update bsec2 configuration settings.
 
bool bsec2GetConfig (uint8_t *cfg, uint32_t &actualSize)
 Retrieve the current library configuration.
 
bool bsec2SetState (const uint8_t *state)
 Restore the internal state.
 
bool bsec2GetState (uint8_t *state, uint32_t &actualSize)
 Retrieve the current internal library state.
 
bool bsec2UpdateSubscription (const uint32_t sensorBits, const bme688::bsec2::SampleRate sr)
 Subscribe to library virtual sensors outputs.
 
bool bsec2UpdateSubscription (const bsec_virtual_sensor_t *ss, const size_t len, const bme688::bsec2::SampleRate sr)
 Subscribe to library virtual sensors outputs.
 
bool bsec2IsSubscribed (const bsec_virtual_sensor_t id)
 is virtual sensor Subscribed?
 
uint32_t bsec2Subscription () const
 Gets the subscription bits.
 
bool bsec2Subscribe (const bsec_virtual_sensor_t id)
 Subscribe virtual sensor.
 
bool bsec2Unsubscribe (const bsec_virtual_sensor_t id)
 Unsubscribe virtual sensor.
 
bool bsec2UnsubscribeAll ()
 Unsubacribe currentt all sensors.
 

Protected Member Functions

bool start_periodic_measurement (const bme688::Mode m)
 
bool stop_periodic_measurement ()
 
bool start_periodic_measurement (const uint32_t subscribe_bits, const bme688::bsec2::SampleRate sr)
 
bool write_mode_forced ()
 
bool write_mode_parallel ()
 
bool fetch_data ()
 
void update_bme688 (const bool force)
 
bool read_measurement ()
 
bool process_data (bsecOutputs &outouts, const int64_t ns, const bme688::bme68xData &data)
 
void update_bsec2 (const bool force)
 
virtual bool in_periodic () const override
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitBME688, bme688::Data)
 

Static Protected Member Functions

static int8_t read_function (uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr)
 
static int8_t write_function (uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr)
 

Protected Attributes

bme688::Mode _mode {bme688::Mode::Sleep}
 
bme688::bme68xData _raw_data [3] {}
 
uint8_t _num_of_data {}
 
bme688::bme68xDev _dev {}
 
bme688::bme68xConf _tphConf {}
 
bme688::bme68xHeatrConf _heaterConf {}
 
uint32_t _bsec2_subscription {}
 
bsec_version_t _bsec2_version {}
 
std::unique_ptr< uint8_t > _bsec2_work {}
 
bsec_bme_settings_t _bsec2_settings {}
 
bme688::Mode _bsec2_mode {}
 
bme688::bsec2::SampleRate _bsec2_sr {}
 
bsecOutputs _outputs {}
 
float _temperatureOffset {}
 
std::unique_ptr< m5::container::CircularBuffer< bme688::Data > > _data {}
 
bool _waiting {}
 
types::elapsed_time_t _can_measure_time {}
 
config_t _cfg {}
 

Detailed Description

BME688 unit.

Note
Using config/bme688/bme688_sel_33v_3s_4d/bsec_selectivity.txt for default configuration
If other settings are used, call bsec2SetConfig

Member Function Documentation

◆ bsec2GetConfig()

bool m5::unit::UnitBME688::bsec2GetConfig ( uint8_t * cfg,
uint32_t & actualSize )

Retrieve the current library configuration.

Parameters
[out]cfgBuffer to hold the serialized config blob
[out]actualSizeActual size of the returned serialized configuration blob
Returns
True if successful
Warning
cfg size must be greater than or equal to BSEC_MAX_PROPERTY_BLOB_SIZE

◆ bsec2GetState()

bool m5::unit::UnitBME688::bsec2GetState ( uint8_t * state,
uint32_t & actualSize )

Retrieve the current internal library state.

Parameters
[out]stateBuffer to hold the serialized state blob
[out]actualSizeActual size of the returned serialized blob
Returns
True if successful
Warning
cfg size must be greater than or equal to BSEC_MAX_STATE_BLOB_SIZE

◆ bsec2IsSubscribed()

bool m5::unit::UnitBME688::bsec2IsSubscribed ( const bsec_virtual_sensor_t id)
inline

is virtual sensor Subscribed?

Parameters
idvirtual sensor (output)
Returns
True if subscribed

◆ bsec2SetConfig()

bool m5::unit::UnitBME688::bsec2SetConfig ( const uint8_t * cfg,
const size_t sz = BSEC_MAX_PROPERTY_BLOB_SIZE )

Update algorithm configuration parameters Update bsec2 configuration settings.

Parameters
cfgSettings serialized to a binary blob
szsize of cfg
Returns
True if successful
Note
See also BSEC2 src/config/bme688 for configuration data

◆ bsec2SetState()

bool m5::unit::UnitBME688::bsec2SetState ( const uint8_t * state)

Restore the internal state.

Parameters
statepointer of the state array
Returns
True if successful

◆ bsec2SetTemperatureOffset()

void m5::unit::UnitBME688::bsec2SetTemperatureOffset ( const float offset)
inline

Set the temperature offset(Celsius)

Parameters
offsetoffset value

◆ bsec2Subscribe()

bool m5::unit::UnitBME688::bsec2Subscribe ( const bsec_virtual_sensor_t id)

Subscribe virtual sensor.

Parameters
idvirtual sensor (output)
Returns
True if successful
Note
SampleRate uses the value that is currently set or has been set in the past

◆ bsec2Subscription()

uint32_t m5::unit::UnitBME688::bsec2Subscription ( ) const
inline

Gets the subscription bits.

Returns
Subscribed sensor id bits
Note
If BSEC_OUTPUT_IAQ is subscribed, then bit 2 (means 1U << BSEC_OUTPUT_IAQ) is 1

◆ bsec2Unsubscribe()

bool m5::unit::UnitBME688::bsec2Unsubscribe ( const bsec_virtual_sensor_t id)

Unsubscribe virtual sensor.

Parameters
idvirtual sensor (output)
Returns
True if successful

◆ bsec2UnsubscribeAll()

bool m5::unit::UnitBME688::bsec2UnsubscribeAll ( )

Unsubacribe currentt all sensors.

Returns
True if successful

◆ bsec2UpdateSubscription() [1/2]

bool m5::unit::UnitBME688::bsec2UpdateSubscription ( const bsec_virtual_sensor_t * ss,
const size_t len,
const bme688::bsec2::SampleRate sr )
inline

Subscribe to library virtual sensors outputs.

Parameters
ssArray of requested virtual sensor (output) configurations for the library
lenNumber of array elements
srSample rate
Returns
True if successful
Warning
Depending on the value specified for the sample rate, appropriate configuration settings may be required in advance.

◆ bsec2UpdateSubscription() [2/2]

bool m5::unit::UnitBME688::bsec2UpdateSubscription ( const uint32_t sensorBits,
const bme688::bsec2::SampleRate sr )

Subscribe to library virtual sensors outputs.

Parameters
sensorBitsRequested virtual sensor (output) configurations for the library
srSample rate
Returns
True if successful
Warning
Depending on the value specified for the sample rate, appropriate configuration settings may be required in advance.

◆ bsec2Version()

const bsec_version_t & m5::unit::UnitBME688::bsec2Version ( ) const
inline

Gets the BSEC2 library version.

Returns
reference of the version structure
Warning
Call after begin

◆ calculateMeasurementInterval()

uint32_t m5::unit::UnitBME688::calculateMeasurementInterval ( const bme688::Mode mode,
const bme688::bme68xConf & s )

Calculation of measurement intervals without heater.

Returns
interval time (Unit: us)

◆ iaq()

float m5::unit::UnitBME688::iaq ( ) const
inline

Oldest measured IAQ.

Warning
Exclude NanoC6

◆ measureSingleShot()

bool m5::unit::UnitBME688::measureSingleShot ( bme688::bme68xData & data)

Take a single measurement.

Parameters
[out]dataoutput value
Returns
True if successful
Precondition
Calibration,TPH and heater must already be set up
Note
Measure once by Force mode
Blocked until it can be measured.

◆ readCalibration()

bool m5::unit::UnitBME688::readCalibration ( bme688::bme68xCalibration & c)

Read calibration.

Parameters
[out]coutput value
Returns
True if successful

◆ readHeaterSetting()

bool m5::unit::UnitBME688::readHeaterSetting ( bme688::bme68xHeatrConf & hs)

Read heater setting.

Parameters
hsSetting
Returns
True if successful
Warning
Only heatr_dur_prof and heatr_temp_prof can be obtained

◆ readIIRFilter()

bool m5::unit::UnitBME688::readIIRFilter ( bme688::Filter & f)

Read IIRFilter.

Parameters
[out]foutput value
Returns
True if successful

◆ readMode()

bool m5::unit::UnitBME688::readMode ( bme688::Mode & m)

Read operation mode.

Parameters
[out]mMode
Returns
True if successful

◆ readOversamplingHumidity()

bool m5::unit::UnitBME688::readOversamplingHumidity ( bme688::Oversampling & os)

Read humidity oversampling.

Parameters
[out]osoutput value
Returns
True if successful

◆ readOversamplingPressure()

bool m5::unit::UnitBME688::readOversamplingPressure ( bme688::Oversampling & os)

Read pressure oversampling.

Parameters
[out]osoutput value
Returns
True if successful

◆ readOversamplingTemperature()

bool m5::unit::UnitBME688::readOversamplingTemperature ( bme688::Oversampling & os)

Read temperature oversampling.

Parameters
[out]osoutput value
Returns
True if successful

◆ readTPHSetting()

bool m5::unit::UnitBME688::readTPHSetting ( bme688::bme68xConf & s)

Read TPH setting.

Parameters
[out]soutput value
Returns
True if successful

◆ readUniqueID()

bool m5::unit::UnitBME688::readUniqueID ( uint32_t & id)

Read unique ID.

Parameters
[out]idoutput value
Returns
True if successful

◆ selfTest()

bool m5::unit::UnitBME688::selfTest ( )

Self-test.

Returns
True if successful

◆ softReset()

bool m5::unit::UnitBME688::softReset ( )

Software reset.

Returns
True if successful

◆ startPeriodicMeasurement() [1/3]

bool m5::unit::UnitBME688::startPeriodicMeasurement ( const bme688::Mode m)
inline

Start periodic measurement without BSEC2.

Parameters
mMode for measurement
Returns
True if successful
Precondition
Calibration,TPH and heater must already be set up
Warning
Measurement intervals are not constant in Parallel mode

◆ startPeriodicMeasurement() [2/3]

bool m5::unit::UnitBME688::startPeriodicMeasurement ( const bsec_virtual_sensor_t * ss,
const size_t len,
const bme688::bsec2::SampleRate sr = bme688::bsec2::SampleRate::LowPower )
inline

Start periodic measurement using BSEC2.

Parameters
ssArray of requested virtual sensor (output) configurations for the library
lenNumber of array elements
Returns
True if successful
Warning
Not available for NanoC6

◆ startPeriodicMeasurement() [3/3]

bool m5::unit::UnitBME688::startPeriodicMeasurement ( const uint32_t subscribe_bits,
const bme688::bsec2::SampleRate sr = bme688::bsec2::SampleRate::LowPower )
inline

Start periodic measurement using BSEC2.

Parameters
subscribe_bitsMeasurement type bits
Returns
True if successful
Warning
Not available for NanoC6

◆ stopPeriodicMeasurement()

bool m5::unit::UnitBME688::stopPeriodicMeasurement ( )
inline

Stop periodic measurement.

Returns
True if successful

◆ writeCalibration()

bool m5::unit::UnitBME688::writeCalibration ( const bme688::bme68xCalibration & c)

write calibration

Parameters
cCalibration parameter
Returns
True if successful

◆ writeHeaterSetting()

bool m5::unit::UnitBME688::writeHeaterSetting ( const bme688::Mode mode,
const bme688::bme68xHeatrConf & hs )

Write heater setting.

Parameters
modeExpected operation mode of the sensor
hsSetting
Returns
True if successful

◆ writeIIRFilter()

bool m5::unit::UnitBME688::writeIIRFilter ( const bme688::Filter f)

Write IIRFilter.

Parameters
[out]fenum value
Returns
True if successful

◆ writeMode()

bool m5::unit::UnitBME688::writeMode ( const bme688::Mode m)

Write operation mode.

Parameters
mMode
Returns
True if successful

◆ writeOversampling()

bool m5::unit::UnitBME688::writeOversampling ( const bme688::Oversampling t,
const bme688::Oversampling p,
const bme688::Oversampling h )

Wite oversamplings.

Parameters
toversampling for temperature
poversampling for pressure
hoversampling for humidity

◆ writeOversamplingHumidity()

bool m5::unit::UnitBME688::writeOversamplingHumidity ( const bme688::Oversampling os)

Write humidity oversampling.

Parameters
osenum value
Returns
True if successful

◆ writeOversamplingPressure()

bool m5::unit::UnitBME688::writeOversamplingPressure ( const bme688::Oversampling os)

Write pressure oversampling.

Parameters
osenum value
Returns
True if successful

◆ writeOversamplingTemperature()

bool m5::unit::UnitBME688::writeOversamplingTemperature ( const bme688::Oversampling os)

Write temperature oversampling.

Parameters
osenum value
Returns
True if successful

◆ writeTPHSetting()

bool m5::unit::UnitBME688::writeTPHSetting ( const bme688::bme68xConf & s)

Write TPH setting.

Parameters
sSetting
Returns
True if successful