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):

Sensirion SHT4x (sl_sht4x.h):


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#

#define
RHT_UNIDRIVER_SHT4X_ID 0x00U

Placeholder for sl_rht_unidriver_get_device_id when the SHT4x path was selected (not a Sensirion register value; distinguishes from Si70xx IDs).

Functions#

sl_status_t
sl_rht_unidriver_init(sl_i2cspm_t *i2cspm)

Initialize the RHT sensor (Si70xx or SHT4x).

sl_status_t
sl_rht_unidriver_get_device_id(uint8_t *device_id)

Return the device ID cached during sl_rht_unidriver_init.

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.

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.

sl_status_t

Start a no hold measurement of relative humidity and temperature.

sl_status_t

Read Firmware Revision from an Si7006/13/20/21 sensor.

sl_status_t

Measure the analog voltage or thermistor temperature from the Si7013 sensor.

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.

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).

Parameters
TypeDirectionArgument NameDescription
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


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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
voidN/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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.