Library for interfacing Sensirion SHT2x family (SHT20, SHT21, SHT25) humidity and temperature sensors
The SHT2x is a fully calibrated temperature and humidity sensor. -) I2C interface with communication speed up to 400 kHz -) Temperature range: -40 to 125°C ±0.3°C (SHT25: ±0.2°C) -) Relative humidity range: 0..100%rH (SHT20:±3%rH, SHT21:±2%rH, SHT25: ±1.8%rH)
typical I2C clock speed to be used (400kHz, I2C Fast-Mode)
SHT2x I2C address
User Register configuration bits
Measurement resolution (User register, bit7 and bit0)
Initializes i2c communication with the SHT2x and prepares the SHT2x for use
First copies the I2C port, I2C address and the transferred configuation to the transferred empty device handle. Afterwards the configuration is written into the user register. This also checks whether the SHT2x is present.
SHT21 measurement process state handling
The SHT21 must be initialised using SHT2x_Init(() before calling this function for the first time. Each time the function is called, it checks the current state of the SHT21 measurement process and switches to the respective communication step. The first time it is called, a soft reset is performed. On the second call, the configuration stored in the device handle is transferred to the SHT21. From the third call the following sequence is executed: Trigger temperature measurement -> Read temperature -> Trigger humidity measurement -> Read humidity -> Trigger temperature measurement -> ...
Reads temperature value stored in the device handle
The function checks if any valid temperature value is available in the device handle and returns it if so.
Reads humidity value stored in the device handle
The function checks if any valid humidity value is available in the device handle and returns it if so.
absolute maximum I2C clock speed
Available Commands for SHT2x access
Sends a command to the STH21
The function sends one byte of data containing the command to the sensor.
Reads configuration data from the SHT21
The function sends one byte of data containing the Read user register command to the sensor and reads one byte of configuration data.
Writes configuration data to the SHT21
Since the reserved bits in the user register must not be changed, the current content of the user register is first read out. After that, the value to be written to the user register is composed of the read value and the desired configuration. Finally two bytes of data containing the write user register command and the composed configuration data are sent to the sensor.
Reads measurement value from the SHT21
The function reads two bytes of measurement data from the SHT21. Depending on the status information contained in the measurement data, the raw value read is then converted into the temperature [0.01°C] or the humidity [0.1%].
Gets SHT21 serial number
The function reads data from memory location 1 & 2 and returns the serial number for the given SHT21 sensor.