Device driver interface for the SHT2x sensor.  
More...
Device driver interface for the SHT2x sensor. 
 | 
| file   | sht2x.h | 
|   | Device driver implementation for the SHT2x humidity and temperature humidity sensor. 
  | 
|   | 
| file   | sht2x_params.h | 
|   | Default configuration for SHT2x humidity and temperature sensor. 
  | 
|   | 
 | 
| enum   | {  
  SHT2X_OK = 0
, SHT2X_ERR_I2C = -1
, SHT2X_ERR_NODEV = -2
, SHT2X_ERR_NOCAL = -3
,  
  SHT2X_ERR_I2C_READ = -4
, SHT2X_ERR_TIMEDOUT = -5
, SHT2X_ERR_CRC = -6
, SHT2X_ERR_USERREG = -7
,  
  SHT2X_ERR_RES = -8
, SHT2X_ERR_OTHER = -999
 
 } | 
|   | Status and error return codes.  More...
  | 
|   | 
| enum   | sht2x_res_t { SHT2X_RES_12_14BIT = 0x00
, SHT2X_RES_8_12BIT = 0x01
, SHT2X_RES_10_13BIT = 0x80
, SHT2X_RES_11_11BIT = 0x81
 } | 
|   | Available resolutions.  More...
  | 
|   | 
| enum   | sht2x_measure_mode_t { SHT2X_MEASURE_MODE_HOLD = 0
, SHT2X_MEASURE_MODE_NO_HOLD = 1
 } | 
|   | Available Measuring modes.  More...
  | 
|   | 
◆ SHT2X_USER_RESOLUTION_MASK
      
        
          | #define SHT2X_USER_RESOLUTION_MASK   0x81 | 
        
      
 
User register masks. 
Notice that the values of sht2x_res_t must only have the bits in SHT2X_USER_RESOLUTION_MASK. 
Definition at line 78 of file sht2x.h.
 
 
◆ anonymous enum
Status and error return codes. 
| Enumerator | 
|---|
| SHT2X_OK  | everything was fine  
 | 
| SHT2X_ERR_I2C  | error initializing the I2C bus  
 | 
| SHT2X_ERR_NODEV  | did not detect SHT2x  
 | 
| SHT2X_ERR_NOCAL  | could not read calibration data  
 | 
| SHT2X_ERR_I2C_READ  | I2C read error.  
 | 
| SHT2X_ERR_TIMEDOUT  | timed out  
 | 
| SHT2X_ERR_CRC  | CRC error.  
 | 
| SHT2X_ERR_USERREG  | cannot write User Reg  
 | 
| SHT2X_ERR_RES  | invalid resolution  
 | 
| SHT2X_ERR_OTHER  | fatal error  
 | 
Definition at line 39 of file sht2x.h.
 
 
◆ sht2x_measure_mode_t
Available Measuring modes. 
| Enumerator | 
|---|
| SHT2X_MEASURE_MODE_HOLD  | trigger measurement, hold master  
 | 
| SHT2X_MEASURE_MODE_NO_HOLD  | trigger measurement, no hold master (i.e.  
poll)  
 | 
Definition at line 67 of file sht2x.h.
 
 
◆ sht2x_res_t
Available resolutions. 
The values represent bits 7 and 0 in the User Register 
| Enumerator | 
|---|
| SHT2X_RES_12_14BIT  | RH=12bit, T=14bit.  
 | 
| SHT2X_RES_8_12BIT  | RH= 8bit, T=12bit.  
 | 
| SHT2X_RES_10_13BIT  | RH=10bit, T=13bit.  
 | 
| SHT2X_RES_11_11BIT  | RH=11bit, T=11bit.  
 | 
Definition at line 57 of file sht2x.h.
 
 
◆ sht2x_init()
Initialize the given SHT2X device. 
- Parameters
 - 
  
    | [out] | dev | Initialized device descriptor of SHT2X device  | 
    | [in] | params | The parameters for the SHT2x device | 
  
   
- Returns
 - SHT2X_OK on success 
 
- 
SHT2X_ERR_I2C if given I2C is not enabled in board config 
 
- 
SHT2X_ERR_RES invalid resolution 
 
- 
SHT2X_ERR_USERREG error writing User Register 
 
- 
errors returned by sht2x_write_userreg or sht2x_read_userreg 
 
 
 
◆ sht2x_read_humidity()
      
        
          | uint16_t sht2x_read_humidity  | 
          ( | 
          const sht2x_t *  | 
          dev | ) | 
           | 
        
      
 
Read humidity value from the given SHT2X device, returned in centi RH. 
Notice that this function will sleep (max 29 ms) when the measure_mode is set to SHT2X_MEASURE_MODE_NO_HOLD.
- Parameters
 - 
  
    | [in] | dev | Device descriptor of SHT2X device to read from | 
  
   
- Returns
 - Humidity in centi RH (i.e. the percentage times 100). In case of an error it returns 0 (i.e. an unrealistic value). 
 
 
 
◆ sht2x_read_ident()
      
        
          | int sht2x_read_ident  | 
          ( | 
          const sht2x_t *  | 
          dev,  | 
        
        
           | 
           | 
          uint8_t *  | 
          buffer,  | 
        
        
           | 
           | 
          size_t  | 
          buflen  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Read identification code from the given SHT2X device. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of SHT2X device to read from  | 
    | [out] | buffer | Buffer to write the identification code to  | 
    | [in] | buflen | The size of buffer  | 
  
   
- Returns
 - >= 0 on success, number of bytes read 
 
- 
SHT2X_ERR_CRC in case of a CRC mismatch 
 
- 
<0 errors returned by i2c_read_regs 
 
 
 
◆ sht2x_read_temperature()
      
        
          | int16_t sht2x_read_temperature  | 
          ( | 
          const sht2x_t *  | 
          dev | ) | 
           | 
        
      
 
Read temperature value from the given SHT2X device, returned in centi °C. 
Notice that this function will sleep (max 85 ms) when the measure_mode is set to SHT2X_MEASURE_MODE_NO_HOLD.
- Parameters
 - 
  
    | [in] | dev | Device descriptor of SHT2X device to read from | 
  
   
- Returns
 - The temperature in centi Celsius. In case of an error it returns INT16_MIN. 
 
 
 
◆ sht2x_read_userreg()
      
        
          | int sht2x_read_userreg  | 
          ( | 
          const sht2x_t *  | 
          dev,  | 
        
        
           | 
           | 
          uint8_t *  | 
          userreg  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Read User Register from the given SHT2X device. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of SHT2X device to read from  | 
    | [out] | userreg | The value of User Register | 
  
   
- Returns
 - SHT2X_OK on success 
 
- 
SHT2X_ERR_I2C if given I2C is not enabled in board config 
 
- 
SHT2X_ERR_OTHER if NULL pointer was given for 
buffer  
 
 
◆ sht2x_reset()
Reset the SHT2X device. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of SHT2X device to read from | 
  
   
- Returns
 - SHT2X_OK on success 
 
- 
SHT2X_ERR_I2C if given I2C is not enabled in board config 
 
 
 
◆ sht2x_write_userreg()
      
        
          | int sht2x_write_userreg  | 
          ( | 
          const sht2x_t *  | 
          dev,  | 
        
        
           | 
           | 
          uint8_t  | 
          userreg  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Write User Register to the given SHT2X device. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of SHT2X device to read from  | 
    | [in] | userreg | The value of User Register | 
  
   
- Returns
 - SHT2X_OK on success 
 
- 
SHT2X_ERR_I2C if given I2C is not enabled in board config