SHT10/SHT11/SHT15 Humidity and Temperature Sensor

Driver for Sensirion SHT10/SHT11/SHT15 Humidity and Temperature Sensor. More...

Detailed Description

Driver for Sensirion SHT10/SHT11/SHT15 Humidity and Temperature Sensor.

Files

file  sht1x.h
 SHT10/SHT11/SHT15 Device Driver.
 
file  sht1x_defines.h
 Internal defines required by the SHT10/SHT11/SHT15 driver.
 
file  sht1x_params.h
 Default configuration for SHT10/SHT11/SHT15 devices.
 

Data Structures

struct  sht1x_dev_t
 SHT10/11/15 temperature humidity sensor. More...
 
struct  sht1x_params_t
 Parameters required to set up the SHT10/11/15 device driver. More...
 

Enumerations

enum  sht1x_conf_t { SHT1X_CONF_LOW_RESOLUTION = 0x01, SHT1X_CONF_SKIP_CALIBRATION = 0x02, SHT1X_CONF_ENABLE_HEATER = 0x04, SHT1X_CONF_SKIP_CRC = 0x08 }
 Possible configuration (=status byte) values of the SHT10/11/15. More...
 
enum  sht1x_vdd_t {
  SHT1X_VDD_5_0V = 0, SHT1X_VDD_4_0V = 1, SHT1X_VDD_3_5V = 2, SHT1X_VDD_3_0V = 3,
  SHT1X_VDD_2_5V = 4
}
 Possible values for Vdd (measured temperature depends on it)
 

Functions

int sht1x_init (sht1x_dev_t *dev, const sht1x_params_t *params)
 Initialize the SHT10/11/15 sensor. More...
 
int16_t sht1x_temperature (const sht1x_dev_t *dev, uint16_t raw)
 Calculate the temperature from the raw input. More...
 
int16_t sht1x_humidity (const sht1x_dev_t *dev, uint16_t raw, int16_t temp)
 Calculate the relative humidity from the raw input. More...
 
int sht1x_read (const sht1x_dev_t *dev, int16_t *temp, int16_t *hum)
 Read the current temperature. More...
 
int sht1x_configure (sht1x_dev_t *dev, sht1x_conf_t conf)
 Apply the given configuration (= status byte) to. More...
 
int sht1x_read_status (sht1x_dev_t *dev, uint8_t *status)
 Read the status byte of an SHT1X sensor. More...
 
int sht1x_reset (sht1x_dev_t *dev)
 Reset the sensor's configuration to default values. More...
 

Enumeration Type Documentation

◆ sht1x_conf_t

Possible configuration (=status byte) values of the SHT10/11/15.

These values can be or'ed together to get the configuration.

Enumerator
SHT1X_CONF_LOW_RESOLUTION 

Use 8/12 bit resolution instead of 12/14 bit for temp/hum.

SHT1X_CONF_SKIP_CALIBRATION 

Don't upload calibration data to register to safe 10 millisec.

SHT1X_CONF_ENABLE_HEATER 

Waste 8mA at 5V to increase the sensor temperature up to 10°C.

SHT1X_CONF_SKIP_CRC 

Skip the CRC check (and reading the CRC byte) to safe time.

Definition at line 38 of file sht1x.h.

Function Documentation

◆ sht1x_configure()

int sht1x_configure ( sht1x_dev_t dev,
sht1x_conf_t  conf 
)

Apply the given configuration (= status byte) to.

Parameters
devSHT1X device to configure
confConfiguration to apply
Return values
0Configuration applied
-EINVALCalled with dev == NULL
-EIOI/O error (gpio_init() failed)
-EPROTOSensor did not acknowledge command
-ECANCELEDSensor did not apply configuration
-EBADMSGCRC checksum error while verifying uploaded configuration

◆ sht1x_humidity()

int16_t sht1x_humidity ( const sht1x_dev_t dev,
uint16_t  raw,
int16_t  temp 
)

Calculate the relative humidity from the raw input.

Note
This internal function is exposed for unit tests
Parameters
devDevice from which the raw value was received
rawThe raw (unprocessed) temperature value
tempThe temperature at which the humidity was measure in E-02 °C
Returns
The correct temperature in E-02 %
Return values
-1Passed NULL for parameter dev

◆ sht1x_init()

int sht1x_init ( sht1x_dev_t dev,
const sht1x_params_t params 
)

Initialize the SHT10/11/15 sensor.

Parameters
devSHT1X sensor to initialize
paramsInformation on how the SHT1X is connected to the board
Return values
0Success
-EIOIO failure (gpio_init() failed)
-EPROTOSensor did not acknowledge reset command

◆ sht1x_read()

int sht1x_read ( const sht1x_dev_t dev,
int16_t *  temp,
int16_t *  hum 
)

Read the current temperature.

Parameters
devSHT1X sensor to read
tempStore the measured temperature in E-02 °C here
humStore the measured relative humidity in E-02 % here
Return values
0Success
-EIOIO failure (gpio_init() failed)
-EBADMSGCRC-8 checksum didn't match (--> Retry)
-EINVALPassed NULL for dev or for both temp and hum
-EBADMSGCRC checksum didn't match
-ECANCELEDMeasurement timed out
-EPROTOSensor did not acknowledge command

For either temp or hum NULL can be passed, if only one value is of interest. Passing NULL for hum speeds up the communication, but passing NULL for temp does not. The temperature value is required to calculate the relative humidity from the raw input. So the temperature is measured in any case, it is just not returned if temp is NULL.

◆ sht1x_read_status()

int sht1x_read_status ( sht1x_dev_t dev,
uint8_t *  status 
)

Read the status byte of an SHT1X sensor.

Parameters
devSHT1X device to receive the status from
statusStore the received status byte here
Return values
0Configuration applied
-EINVALCalled with dev == NULL
-EIOI/O error (gpio_init() failed)
-EPROTOSensor did not acknowledge command
-EBADMSGCRC checksum didn't match

◆ sht1x_reset()

int sht1x_reset ( sht1x_dev_t dev)

Reset the sensor's configuration to default values.

Parameters
devSHT1X device to reset
Return values
0Reset successful
-EINVALCalled with dev == NULL
-EIOI/O error (gpio_init() failed)
-EPROTOSensor did not acknowledge reset command

◆ sht1x_temperature()

int16_t sht1x_temperature ( const sht1x_dev_t dev,
uint16_t  raw 
)

Calculate the temperature from the raw input.

Note
This internal function is exposed for unit tests
Parameters
devDevice from which the raw value was received
rawThe raw (unprocessed) temperature value
Returns
The correct temperature in E-02 °C
Return values
INT16_MINPassed NULL for parameter dev or dev->vdd