3.2.5. sht3xd — SHT3x-D Humidity and Temperature Sensor

../../../_images/sensirion-humidity-sensors-sht3x-a6271.png

The Sensirion SHT3x-D is a series of digital of Humidity and Temperature Sensors. This driver supports the SHT30-D, SHT31-D, and SHT35-D using an I2C interface. The analog SHT3x-A, such as SHT30-A and SHT31-A are not supported.

The SHT3x-D sensors supports I2C speed of up to 1MHz.

Current limitations of this driver:

  • Only supports basic functionality and high repeatability mode.
  • Does not perform check CRC of sensor result.

Datasheet: Datasheet SHT3x-DIS

Source code: src/drivers/sensors/sht3xd.h, src/drivers/sensors/sht3xd.c


Defines

SHT3X_DIS_I2C_ADDR_A

SHT3x-DIS default I2C address.

SHT3X_DIS_I2C_ADDR_B

SHT3x-DIS alternate I2C address.

MEASUREMENT_DURATION_HIGH_MS

Max measurement time for high repeatability.

Functions

int sht3xd_module_init(void)

Initialize the driver module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int sht3xd_init(struct sht3xd_driver_t *self_p, struct i2c_driver_t *i2c_p, int i2c_addr)

Initialize driver object. The driver object will be used for a single sensor.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to be initialize.
  • i2c_p: The I2C driver pointer.
  • i2c_addr: The address of the SHT3x-D. Probably SHT3X_DIS_I2C_ADDR_A.

int sht3xd_start(struct sht3xd_driver_t *self_p)

Start the driver.

This verify the sensor is present.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int sht3xd_get_temp_humid(struct sht3xd_driver_t *self_p, float *temp_p, float *humid_p)

Get measurements and return it from the SHD3x-DIS chip.

This is a “high level” function which will block for the time it takes the sensor to perform the measurement.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • temp_p: Tempererature in Celsius, or NULL.
  • humid_p: Relative Humidity, or NULL.

int sht3xd_get_serial(struct sht3xd_driver_t *self_p, uint32_t *serial_p)

Get the serial number from the SHD3x-D.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • serial_p: Serial number of the SHT3x-D sensor.

struct sht3xd_driver_t
#include <sht3xd.h>

Public Members

struct i2c_driver_t *i2c_p
int i2c_addr
uint32_t serial