sht1x.h¶
SHT10/SHT11/SHT15 Device Driver.
-
enum
sht1x_conf_t¶ - SHT1X_CONF_LOW_RESOLUTION
= 0x01 - Use 8/12 bit resolution instead of 12/14 bit for temp/hum.
- SHT1X_CONF_SKIP_CALIBRATION
= 0x02 - Don’t upload calibration data to register to safe 10 millisec.
- SHT1X_CONF_ENABLE_HEATER
= 0x04 - Waste 8mA at 5V to increase the sensor temperature up to 10°C.
- SHT1X_CONF_SKIP_CRC
= 0x08 - Skip the CRC check (and reading the CRC byte) to safe time.
- SHT1X_CONF_LOW_RESOLUTION
-
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
- SHT1X_VDD_5_0V
-
int
sht1x_init(sht1x_dev_t * dev, const sht1x_params_t * params)¶ Initialize the SHT10/11/15 sensor.
Parameters
dev: SHT1X sensor to initialize params: Information on how the SHT1X is connected to the board Parameters
0: Success -EIO: IO failure ( gpio_init()failed)-EPROTO: Sensor did not acknowledge reset command
-
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
dev: Device from which the raw value was received raw: The raw (unprocessed) temperature value Parameters
INT16_MIN: Passed NULLfor parameterdevordev->vddReturn values
- The correct temperature in E-02 °C
-
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
dev: Device from which the raw value was received raw: The raw (unprocessed) temperature value temp: The temperature at which the humidity was measure in E-02 °C Parameters
-1: Passed NULLfor parameterdevReturn values
- The correct temperature in E-02 %
-
int
sht1x_read(const sht1x_dev_t * dev, int16_t * temp, int16_t * hum)¶ Read the current temperature.
Parameters
dev: SHT1X sensor to read temp: Store the measured temperature in E-02 °C here hum: Store the measured relative humidity in E-02 % here Parameters
For either0: Success -EIO: IO failure ( gpio_init()failed)-EBADMSG: CRC-8 checksum didn’t match (> Retry) -EINVAL: Passed NULLfor dev or for bothtempandhum-EBADMSG: CRC checksum didn’t match -ECANCELED: Measurement timed out -EPROTO: Sensor did not acknowledge command temporhumNULLcan be passed, if only one value is of interest. PassingNULLforhumspeeds up the communication, but passingNULLfortempdoes 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 iftempisNULL.
-
int
sht1x_configure(sht1x_dev_t * dev,sht1x.h::sht1x_conf_tconf)¶ Apply the given configuration (= status byte) to.
Parameters
dev: SHT1X device to configure conf: Configuration to apply Parameters
0: Configuration applied -EINVAL: Called with dev == NULL-EIO: I/O error ( gpio_init()failed)-EPROTO: Sensor did not acknowledge command -ECANCELED: Sensor did not apply configuration -EBADMSG: CRC checksum error while verifying uploaded configuration
-
int
sht1x_read_status(sht1x_dev_t * dev, uint8_t * status)¶ Read the status byte of an SHT1X sensor.
Parameters
dev: SHT1X device to receive the status from status: Store the received status byte here Parameters
0: Configuration applied -EINVAL: Called with dev == NULL-EIO: I/O error ( gpio_init()failed)-EPROTO: Sensor did not acknowledge command -EBADMSG: CRC checksum didn’t match
-
int
sht1x_reset(sht1x_dev_t * dev)¶ Reset the sensor’s configuration to default values.
Parameters
dev: SHT1X device to reset Parameters
0: Reset successful -EINVAL: Called with dev == NULL-EIO: I/O error ( gpio_init()failed)-EPROTO: Sensor did not acknowledge reset command
-
struct
sht1x_dev_t¶ SHT10/11/15 temperature humidity sensor.
-
gpio.h::gpio_tclk¶ GPIO connected to the clock pin of the SHT1X.
-
gpio.h::gpio_tdata¶ GPIO connected to the data pin of the SHT1X.
-
int16_t
temp_off¶ Offset to add to the measured temperature.
-
int16_t
hum_off¶ Offset to add to the measured humidity.
-
uint8_t
conf¶ Status byte (containing configuration) of the SHT1X.
-
uint8_t
vdd¶ Supply voltage of the SHT1X (as sht1x_vdd_t)
-
-
struct
sht1x_params_t¶ Parameters required to set up the SHT10/11/15 device driver.
-
gpio.h::gpio_tclk¶ GPIO connected to the clock pin of the SHT1X.
-
gpio.h::gpio_tdata¶ GPIO connected to the data pin of the SHT1X.
-
sht1x.h::sht1x_vdd_tvdd¶ The supply voltage of the SHT1X.
-