theCore C++ embedded framework
HTU21D humidity and temperature sensor
Collaboration diagram for HTU21D humidity and temperature sensor:

Data Structures

class  ecl::sensor::htu21d< i2c_dev >
 HTU21D sensor driver implementation. More...
 

Enumerations

enum  ecl::sensor::htu21d_resolution { ecl::sensor::htu21d_resolution::rm12_t14, ecl::sensor::htu21d_resolution::rm8_t12, ecl::sensor::htu21d_resolution::rm10_t13, ecl::sensor::htu21d_resolution::rm11_t11 }
 Defines resolution modes for HTU21D sensor. More...
 

Functions

static err ecl::sensor::htu21d< i2c_dev >::init ()
 Inits sensor and underlying I2C platform bus. More...
 
static err ecl::sensor::htu21d< i2c_dev >::soft_reset ()
 Performs soft reset of the sensor. More...
 
static err ecl::sensor::htu21d< i2c_dev >::try_xfer (uint8_t cmd, uint8_t *data, size_t data_size)
 Try set buffer for rx/tx and do_xfer several times if error occurred. More...
 
static err ecl::sensor::htu21d< i2c_dev >::get_sample_temperature (uint16_t &sample)
 Reads raw temperature sample from sensor. More...
 
static err ecl::sensor::htu21d< i2c_dev >::get_sample_humidity (uint16_t &sample)
 Reads raw relative humidity sample from sensor. More...
 
static err ecl::sensor::htu21d< i2c_dev >::get_temperature (int &temperature)
 Reads sample from sensor and converts to a physical value. More...
 
static err ecl::sensor::htu21d< i2c_dev >::get_humidity (int &humidity)
 Reads sample from sensor and converts to a physical value. More...
 
static err ecl::sensor::htu21d< i2c_dev >::set_resolution_mode (htu21d_resolution mode)
 Sets resolution mode for measuring Default mode (htu21d_resolution::rm12_t14) is entered after power on. More...
 
static err ecl::sensor::htu21d< i2c_dev >::get_resolution_mode (htu21d_resolution &mode)
 Returns current resolution mode. More...
 
static bool ecl::sensor::htu21d< i2c_dev >::is_battery_low ()
 Checks end of battery status (see RM for details) More...
 
static bool ecl::sensor::htu21d< i2c_dev >::is_heater_enabled ()
 Checks if on-chip heater is enabled. More...
 
static err ecl::sensor::htu21d< i2c_dev >::enable_heater ()
 Enables on-chip heater (see RM for details) More...
 
static err ecl::sensor::htu21d< i2c_dev >::disable_heater ()
 Disables on-chip heater (see RM for details) More...
 

Detailed Description

Enumeration Type Documentation

◆ htu21d_resolution

Defines resolution modes for HTU21D sensor.

Possible modes are (RM here - relative humidity): rm12_t14 - 12 bits for RM, 14 bits for temperature rm8_t12 - 8 bits for RM, 12 bits for temperature rm10_t13 - 10 bits for RM, 13 bits for temperature rm11_t11 - 11 bits for RM, 11 bits for temperature

Enumerator
rm12_t14 
rm8_t12 
rm10_t13 
rm11_t11 

Function Documentation

◆ init()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::init ( )
static

Inits sensor and underlying I2C platform bus.

Return values
Statusof operation.

◆ soft_reset()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::soft_reset ( )
static

Performs soft reset of the sensor.

Note
The soft reset takes around 15ms. User code should wait at least 15ms to finish reset procedure.
Return values
Statusof the operation.

◆ try_xfer()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::try_xfer ( uint8_t  cmd,
uint8_t *  data,
size_t  data_size 
)
static

Try set buffer for rx/tx and do_xfer several times if error occurred.

Return values
Statusof the operation
Here is the call graph for this function:

◆ get_sample_temperature()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::get_sample_temperature ( uint16_t &  sample)
static

Reads raw temperature sample from sensor.

Sample should be processed to receive physical value.

Parameters
[out]sampleVariable in which raw temp. sample will be written.
Return values
Statusof the operation.

◆ get_sample_humidity()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::get_sample_humidity ( uint16_t &  sample)
static

Reads raw relative humidity sample from sensor.

Sample should be processed to receive physical value.

Parameters
[out]sampleVariable in which raw RM sample will be written.
Return values
Statusof the operation.

◆ get_temperature()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::get_temperature ( int &  temperature)
static

Reads sample from sensor and converts to a physical value.

Parameters
[out]temperatureTemperature in (1000 * (temperature in C degree)) will be written in this parameter.
Return values
Statusof the operation.

◆ get_humidity()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::get_humidity ( int &  humidity)
static

Reads sample from sensor and converts to a physical value.

Parameters
[out]humidityRelative humidity in (1000 * (humidity in %)) will be written in this parameter.
Return values
Statusof the operation.

◆ set_resolution_mode()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::set_resolution_mode ( htu21d_resolution  mode)
static

Sets resolution mode for measuring Default mode (htu21d_resolution::rm12_t14) is entered after power on.

Parameters
[in]modeCan be value of type htu21d_resolution
Return values
Statusof the operation.

◆ get_resolution_mode()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::get_resolution_mode ( htu21d_resolution mode)
static

Returns current resolution mode.

Parameters
[out]modeThe value in which result will be written. Can be value of type htu21d_resolution
Return values
Statusof the operation.

◆ is_battery_low()

template<class i2c_dev >
bool ecl::sensor::htu21d< i2c_dev >::is_battery_low ( )
static

Checks end of battery status (see RM for details)

Return values
Trueif battery power > 2.5V, False otherwise.

◆ is_heater_enabled()

template<class i2c_dev >
bool ecl::sensor::htu21d< i2c_dev >::is_heater_enabled ( )
static

Checks if on-chip heater is enabled.

Return values
Trueif enabled, False otherwise.

◆ enable_heater()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::enable_heater ( )
static

Enables on-chip heater (see RM for details)

The heater is intended to be used for functionality diagnosis: relative humidity drops upon rising temperature. The heater consumes about 5.5mW and provides a temperature increase of about 0.5-1.5°C

Return values
Statusof the operation.

◆ disable_heater()

template<class i2c_dev >
err ecl::sensor::htu21d< i2c_dev >::disable_heater ( )
static

Disables on-chip heater (see RM for details)

Return values
Statusof the operation.