Driver for Sensirion SHT10/SHT11/SHT15 Humidity and Temperature Sensor.
More...
Driver for Sensirion SHT10/SHT11/SHT15 Humidity and Temperature Sensor.
|
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.
|
|
◆ 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.
◆ sht1x_configure()
Apply the given configuration (= status byte) to.
- Parameters
-
dev | SHT1X device to configure |
conf | Configuration to apply |
- Return values
-
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 |
◆ 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
-
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 |
- Returns
- The correct temperature in E-02 %
- Return values
-
-1 | Passed NULL for parameter dev |
◆ sht1x_init()
Initialize the SHT10/11/15 sensor.
- Parameters
-
dev | SHT1X sensor to initialize |
params | Information on how the SHT1X is connected to the board |
- Return values
-
0 | Success |
-EIO | IO failure (gpio_init() failed) |
-EPROTO | Sensor 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
-
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 |
- Return values
-
0 | Success |
-EIO | IO failure (gpio_init() failed) |
-EBADMSG | CRC-8 checksum didn't match (--> Retry) |
-EINVAL | Passed NULL for dev or for both temp and hum |
-EBADMSG | CRC checksum didn't match |
-ECANCELED | Measurement timed out |
-EPROTO | Sensor 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
-
dev | SHT1X device to receive the status from |
status | Store the received status byte here |
- Return values
-
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 |
◆ sht1x_reset()
Reset the sensor's configuration to default values.
- Parameters
-
- Return values
-
0 | Reset successful |
-EINVAL | Called with dev == NULL |
-EIO | I/O error (gpio_init() failed) |
-EPROTO | Sensor 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
-
dev | Device from which the raw value was received |
raw | The raw (unprocessed) temperature value |
- Returns
- The correct temperature in E-02 °C
- Return values
-
INT16_MIN | Passed NULL for parameter dev or dev->vdd |