Abstraction around SHT21/HTU21D temperature/humidity sensor.
More...
#include <nrfcxx/sensor/sht21.hpp>
|
using | eic_type = uint8_t[8] |
| Storage for the Electronic Identification Code.
|
|
|
static bool | eic_is_sht21 (const eic_type &eic) |
| Return true iff the eic indicates a Sensirion SHT21 device.
|
|
static bool | eic_is_htu21d (const eic_type &eic) |
| Return true iff the eic indicates a Measurement Specialties HTU21D device.
|
|
|
int | lpsm_process_ (int &delay, process_flags_type &pf) override |
|
int | trigger_ (bool humidity) |
|
int | fetch_ (bool humidity) |
| Fetch the latest result as a raw value. More...
|
|
| 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.
|
|
Abstraction around SHT21/HTU21D temperature/humidity sensor.
Interface to the Sensirion SHT21 Digital Humidity Sensor or the Measurement Specialties HTU21D clone.
lpm::lpsm_capable::lpsm_process() for this sensor returns the following flags in addition to the diagnostic flags:
◆ configure()
int nrfcxx::sensor::sht21::configure |
( |
int |
config | ) |
|
Configure resolution and heater.
- Parameters
-
config | A nonnegative configuration byte comprising a resolution setting (e.g. CONFIG_RES_H12T14) and optionally CONFIG_HEATER, or a negative value to query the current configuration without changing it. |
- Returns
- The non-negative content of the configuration register prior to invoking this function, or a negative encoded error.
- Note
- CONFIG_OTPRn is unconditionally set in any non-negative
config
value.
◆ fetch_()
int nrfcxx::sensor::sht21::fetch_ |
( |
bool |
humidity | ) |
|
|
protected |
Fetch the latest result as a raw value.
NOT_READY indicates that the collection is still in progress.
The caller is responsible for ensuring that humidity
is consistent with the previous invocation of trigger_().
◆ humidity_pptt()
int nrfcxx::sensor::sht21::humidity_pptt |
( |
| ) |
|
|
inline |
Retrieve the last measurement as a humidity measurement.
- Returns
- the non-negative relative humidity in parts-per-ten-thousand, or a negative error code such as NOT_READY or an encoded TWI error or TWI::ERR_INVALID if the last measurement was not humidity.
◆ read_eic()
int nrfcxx::sensor::sht21::read_eic |
( |
eic_type & |
eic | ) |
|
Read the Electronic Identification Code from the device.
- Parameters
-
eic | Storage for the EIC, which is device-specific and can also be used to distinguish Sensirion SHT21 from HTU21D devices. |
◆ reset()
int nrfcxx::sensor::sht21::reset |
( |
| ) |
|
Send a soft-reset command to the SHT21.
If successful this is equivalent to a power-on reset except that the CONFIG_HEATER bit remains unaffected.
- Returns
- a non-negative value on success, or a negative encoded error.
◆ temperature_cK()
int nrfcxx::sensor::sht21::temperature_cK |
( |
| ) |
|
|
inline |
Retrieve the last measurement as a temperature measurement.
- Returns
- the non-negative temperature in hundredths of a degree Kelvin, or a negative error code such as NOT_READY or an encoded TWI error or TWI::ERR_INVALID if the last measurement was not temperature.
◆ trigger_humidity()
int nrfcxx::sensor::sht21::trigger_humidity |
( |
| ) |
|
|
inline |
Initiate a temperature measurement.
The time required for completion of the measurement is device- and resolution-specific, but may be as long as 29 ms.
- Returns
- Zero on success, or anegative encoded error.
◆ trigger_temperature()
int nrfcxx::sensor::sht21::trigger_temperature |
( |
| ) |
|
|
inline |
Initiate a temperature measurement.
The time required for completion of the measurement is device- and resolution-specific, but may be as long as 85 ms.
- Returns
- Zero on success, or a negative encoded error.
◆ INVALID_OBSERVATION
constexpr static int nrfcxx::sensor::sht21::INVALID_OBSERVATION = -30000 |
|
staticconstexpr |
Value for observations that are known to be invalid.
This fits in a 16-bit signed value and is outside the valid range for both temperature_cK() and humidity_pptt().
◆ SAMPLE12_DELAY_ms
constexpr static unsigned int nrfcxx::sensor::sht21::SAMPLE12_DELAY_ms = 22 |
|
staticconstexpr |
The maximum time required for a 12-bit measurement, in milliseconds.
This is for a SHT21; the HTU21D is about 25% faster.
◆ SAMPLE14_DELAY_ms
constexpr static unsigned int nrfcxx::sensor::sht21::SAMPLE14_DELAY_ms = 85 |
|
staticconstexpr |
The maximum time required for a 14-bit measurement, in milliseconds.
This is for a SHT21; the HTU21D is about 30% faster.
The documentation for this class was generated from the following file: