RHT UniDriver - Temperature/Humidity Sensor#
Unified driver for Si70xx (BRD4002A) and SHT4x (BRD4002B) sensors.
Works transparently regardless of which supported sensor is connected.
For a known board and sensor, using the si70xx_driver or sht4x_driver component alone avoids linking both sensor stacks and reduces flash. Use this module when the product or example must run on either hardware without a separate build per board.
Only sl_rht_unidriver_init takes the I2C bus handle; it probes Si70xx then SHT4x on fixed board addresses and caches the bus plus selected part. All other functions use that cache only.
Note
The module keeps one static session. It is not re-entrant; call sl_rht_unidriver_init again to re-probe or switch boards.
Backend API mapping#
Silabs Si70xx (sl_si70xx.h):
sl_si70xx_init is not used; discovery uses sl_si70xx_present inside sl_rht_unidriver_init only (no user calibration path from the dedicated init).
sl_si70xx_present is internal to sl_rht_unidriver_init; silicon ID is exposed via sl_rht_unidriver_get_device_id.
sl_si70xx_measure_rh_and_temp maps to sl_rht_unidriver_measure_rh_and_temp
sl_si70xx_read_rh_and_temp maps to sl_rht_unidriver_read_rh_and_temp
sl_si70xx_start_no_hold_measure_rh_and_temp maps to sl_rht_unidriver_start_no_hold_measure_rh_and_temp
sl_si70xx_get_firmware_revision maps to sl_rht_unidriver_get_firmware_revision
sl_si7013_measure_analog_voltage maps to sl_rht_unidriver_measure_analog_voltage
Sensirion SHT4x (sl_sht4x.h):
sl_sht4x_init is not used; discovery uses sl_sht4x_present with the same retry delay as the dedicated init (48-bit serial not cached).
sl_sht4x_present is internal to sl_rht_unidriver_init.
sl_sht4x_measure_rh_and_temp maps to sl_rht_unidriver_measure_rh_and_temp
sl_rht_unidriver_read_rh_and_temp uses sl_sht4x_measure_rh_and_temp on SHT4x (sl_sht4x_read_rh_and_temp returns raw ADC codes only).
sl_sht4x_enable_low_power_mode maps to sl_rht_unidriver_enable_low_power_mode
RHT UniDriver example code#
#include "sl_i2cspm_instances.h"
#include "sl_rht_unidriver.h"
int main(void)
{
uint32_t rh_pct_x1000;
int32_t temp_mc;
...
sl_rht_unidriver_init(sl_i2cspm_sensor);
sl_rht_unidriver_measure_rh_and_temp(&rh_pct_x1000, &temp_mc);
...
}
Sensor identity#
Placeholder for sl_rht_unidriver_get_device_id when the SHT4x path was selected (not a Sensirion register value; distinguishes from Si70xx IDs).
Functions#
Initialize the RHT sensor (Si70xx or SHT4x).
Return the device ID cached during sl_rht_unidriver_init.
Measure relative humidity and temperature from an Si70xx or SHT4x sensor.
Read relative humidity and temperature from an Si70xx or SHT4x sensor.
Start a no hold measurement of relative humidity and temperature.
Read Firmware Revision from an Si7006/13/20/21 sensor.
Measure the analog voltage or thermistor temperature from the Si7013 sensor.
Select the SHT4x measurement command byte for low-precision vs high-precision mode.
Sensor identity Documentation#
Function Documentation#
sl_rht_unidriver_init#
sl_status_t sl_rht_unidriver_init (sl_i2cspm_t * i2cspm)
Initialize the RHT sensor (Si70xx or SHT4x).
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
Probes Si70xx at the on-board RHT address (same as typical Si7021 placement), then SHT4x at its fixed address, with retries matching the dedicated drivers. Neither sl_si70xx_init nor sl_sht4x_init is called. Note
Call sl_rht_unidriver_init before any other function in this module.
sl_rht_unidriver_get_device_id#
sl_status_t sl_rht_unidriver_get_device_id (uint8_t * device_id)
Return the device ID cached during sl_rht_unidriver_init.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t * | [out] | device_id | Si70xx: 0x06 (Si7006), 0x0D (Si7013), 0x14 (Si7020), 0x15 (Si7021). SHT4x: RHT_UNIDRIVER_SHT4X_ID. |
sl_rht_unidriver_measure_rh_and_temp#
sl_status_t sl_rht_unidriver_measure_rh_and_temp (uint32_t * rh_data, int32_t * t_data)
Measure relative humidity and temperature from an Si70xx or SHT4x sensor.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint32_t * | [out] | rh_data | The relative humidity in percent (multiplied by 1000). |
| int32_t * | [out] | t_data | The temperature in milliCelsius. |
sl_rht_unidriver_read_rh_and_temp#
sl_status_t sl_rht_unidriver_read_rh_and_temp (uint32_t * rh_data, int32_t * t_data)
Read relative humidity and temperature from an Si70xx or SHT4x sensor.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint32_t * | [out] | rh_data | The relative humidity in percent (multiplied by 1000). |
| int32_t * | [out] | t_data | The temperature in milliCelsius. |
For Si70xx devices this reads the result of a previously started no-hold measurement. For SHT4x devices this uses the same converted measurement as sl_sht4x_measure_rh_and_temp (not raw sl_sht4x_read_rh_and_temp).
sl_rht_unidriver_start_no_hold_measure_rh_and_temp#
sl_status_t sl_rht_unidriver_start_no_hold_measure_rh_and_temp (void )
Start a no hold measurement of relative humidity and temperature.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
This mode is supported by Si70xx devices only.
sl_rht_unidriver_get_firmware_revision#
sl_status_t sl_rht_unidriver_get_firmware_revision (uint8_t * fw_rev)
Read Firmware Revision from an Si7006/13/20/21 sensor.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t * | [out] | fw_rev | The internal firmware revision. 0xFF === 1.0 |
SHT4x does not support this; returns SL_STATUS_NOT_SUPPORTED when SHT4x is present.
sl_rht_unidriver_measure_analog_voltage#
sl_status_t sl_rht_unidriver_measure_analog_voltage (int32_t * v_data)
Measure the analog voltage or thermistor temperature from the Si7013 sensor.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| int32_t * | [out] | v_data | The data read from the sensor. |
Note
Analog voltage measurement only supported by Si7013.
sl_rht_unidriver_enable_low_power_mode#
sl_status_t sl_rht_unidriver_enable_low_power_mode (bool enable_low_power_mode, uint8_t * sht4x_cmd_measure)
Select the SHT4x measurement command byte for low-precision vs high-precision mode.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| bool | [in] | enable_low_power_mode | True for low-precision (lower power) mode command byte; false for high-precision. |
| uint8_t * | [out] | sht4x_cmd_measure | Receives the command byte to pass to measurement (same semantics as the SHT4x driver). Not written when the return value is not SL_STATUS_OK. |
Wraps sl_sht4x_enable_low_power_mode. Returns SL_STATUS_NOT_SUPPORTED when the cached sensor is Si70xx.