|
nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Abstraction around BME280 temperature/humidity/pressure sensor. More...
#include <nrfcxx/sensor/bme280.hpp>
Data Structures | |
| struct | observations_type |
| Structure used to return sampled values. More... | |
Public Member Functions | |
| bme280 (notifier_type notify, nrfcxx::periph::SPI &spi, int csn_psel) | |
| Construct an instance that controls through the SPI interface. More... | |
| bme280 (notifier_type notify, nrfcxx::periph::TWI &twi, bool addr_sec=false) | |
| Construct an instance that controls through the I2C interface. More... | |
| int | initialize () |
| Initialize the BME280. More... | |
| int | sample () |
| Request a new sample from the device. More... | |
| int | fetch (observations_type &obs) |
| Retrieve the results from the most recent observation. More... | |
| const observations_type & | observations () const |
| Retrieve the most recent observations calculated through the LPM infrastructure. | |
Public Member Functions inherited from nrfcxx::lpm::lpsm_capable | |
| virtual int | lpsm_start () |
| Validate and prepare to initiate an LPM collection. More... | |
| virtual int | lpsm_sample () |
| Ask the LPM infrastructure to initiate a new sample. More... | |
| lpm::state_machine::process_flags_type | lpsm_process () |
| Make progress on an LPM collection. More... | |
| int | lpsm_stop () |
| int | lpsm_reset () |
| int | lpsm_process_rc () const |
| Get the internal result code from the last invocation of lpsm_process_(). More... | |
| const lpm::state_machine & | machine () const |
| Gain read-only access to the LPM machine state. | |
Static Public Attributes | |
| static constexpr unsigned int | SAMPLE_DELAY_utt = clock::uptime::from_ms(10) |
| Lower bound for wait after sample() before get_sensor_data(). More... | |
| static constexpr uint16_t | INVALID_TEMPHUMID = 30000 |
| Value used for invalid temperature and humidity observations. | |
| static constexpr unsigned int | INVALID_PRESSURE = 0x00C00000 |
| Value used for invalid pressure observations. More... | |
Additional Inherited Members | |
Protected Types inherited from nrfcxx::lpm::lpsm_capable | |
| using | state_type = state_machine::state_type |
| using | process_flags_type = state_machine::process_flags_type |
Protected Member Functions inherited from nrfcxx::lpm::lpsm_capable | |
| lpsm_capable (notifier_type notify) | |
| Create a state machine that records state and supports delayed transitions. More... | |
| virtual int | lpsm_process_ (int &delay, process_flags_type &pf) |
| Override to implement machine-specific operations of lpsm_process(). More... | |
| virtual void | lpsm_reset_ () |
| Override to reset state that is held outside the machine. | |
Protected Attributes inherited from nrfcxx::lpm::lpsm_capable | |
| state_machine | machine_ |
Abstraction around BME280 temperature/humidity/pressure sensor.
Interface to the Bosch Sensortec BME280 sensor, wrapping the vendor-supplied library.
This uses forced (one-shot) sampling only, hard-coded with the parameters recommended for weather monitoring.
lpm::lpsm_capable::lpsm_process() for this sensor returns the following flags in addition to the diagnostic flags:
| nrfcxx::sensor::bme280::bme280 | ( | notifier_type | notify, |
| nrfcxx::periph::SPI & | spi, | ||
| int | csn_psel | ||
| ) |
Construct an instance that controls through the SPI interface.
| notify | the notifier to inform the application of LPM processing needs. |
| spi | reference to the SPI peripheral to use. |
| csn_psel | GPIO pin selector (index) identifying the GPIo connected to the BME280 CSn signal. |
| nrfcxx::sensor::bme280::bme280 | ( | notifier_type | notify, |
| nrfcxx::periph::TWI & | twi, | ||
| bool | addr_sec = false |
||
| ) |
Construct an instance that controls through the I2C interface.
| notify | the notifier to inform the application of LPM processing needs. |
| twi | reference to the TWI peripheral to use. |
| addr_sec | false to use the primary I2C address, true to use the secondary I2C address. |
| int nrfcxx::sensor::bme280::fetch | ( | observations_type & | obs | ) |
Retrieve the results from the most recent observation.
| int nrfcxx::sensor::bme280::initialize | ( | ) |
Initialize the BME280.
Issue this only once for each instance. This confirms communication with the device and configures the sample options.
|
inline |
Request a new sample from the device.
|
staticconstexpr |
Value used for invalid pressure observations.
This is sized to fit in a 24-bit unsigned integer, with a maximum representable value of 1258.2911 hPa.
|
staticconstexpr |
Lower bound for wait after sample() before get_sensor_data().
This value is designed for the weather monitoring configuration hard-coded into the implementation. Nominal maximum 9.3 ms.
1.8.16