Interpreting humidity and temperature readings in the HTS221 digital humidity sensor

Similar documents
TN1251 Technical note

How to interpret the LPS331AP pressure and temperature readings. Main components mbar absolute barometer with digital output

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

STSW-STWBCFWDT. STWBC firmware downloader tool. Description. Features

STSW-BNRGUI. BlueNRG GUI SW package. Data brief. Features. Description

AN4491 Application note

ST Payment Secure Solution Java Card platform with up to 100 Kbytes of user NVM for AMEX payment applications

Dynamic Electro-Thermal simulator for VIPower products. Description

UM2167 User manual. OrCAD PSpice model usage instructions

AN4872 Application note

Description. January 2019 DB2381 Rev 3 1/5

P-NUCLEO-IKA02A1. STM32 Nucleo pack: electrochemical toxic gas sensor expansion board with CO sensor. Description. Features

L9958 Evaluation board for high current (8.6A) DC and Stepper Motors. Description

RN0084 Release note. ST-LINK/V2 firmware upgrade. About this release note

Table 1: Device summary Part numbers Device info (stored in register 0xF0 and 0xF1) Comment SPIRIT1QTR 0x0130 Cut 3.0

DT0095 Design tip. Datalogging the SensorTile through a PC. Purpose and benefits. Description

Description. July 2016 DocID Rev 2 1/6

X-NUCLEO-53L1A1. Long distance ranging Time-of-Flight sensor expansion board based on VL53L1X for STM32 Nucleo. Description.

A scalable approach to your body, networking and security platforms. Description

Motor control power board based on the SLLIMM-nano 2 nd series

Bluetooth low energy profiles for the X-CUBE-BLE1 expansion for STM32Cube. Description

X-NUCLEO-53L0A1. Ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo. Description. Features

ST Payment Secure Solution - Java Card platform with up to 90 Kbytes of user NVM for Visa, MasterCard, AMEX, Discover and Interac applications

Using the GPIOs and interrupt controller to drive LEDs on STM8 Nucleo-64 boards

UM2361. Getting started with the ST BlueNRG-Mesh ios application. User manual. Introduction

STEVAL-IPMnM2N. Motor control power board based on the SLLIMM-nano 2 nd series. Description. Features. RoHS compliant

NUCLEO-L496ZG. STM32 Nucleo-144 board. Features. Description

300 ma triple DC-DC converter for powering AMOLED displays. Description. Table 1: Device summary Negative voltage. Auxiliary positive voltage

STTS V memory module temperature sensor. Features

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

Getting started with MotionMC magnetometer calibration library in X-CUBE-MEMS1 expansion for STM32Cube

SPC58EHx,SPC58NHx. A scalable approach for high-end body, networking and security platforms for Automotive. Description. Features

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

UM1641 User manual. Sampling rate conversion SRC236 library software expansion for STM32Cube. Introduction

AN4045 Application note

UM2092 User manual. Basic metrology firmware for the STM32F103RD and the STPM32 devices. Introduction

TN1235 Technical note

ST25DV-DISCOVERY. Discovery kit for the ST25DV04K dynamic NFC/RFID tag. Features

UM2192. Getting started with MotionMC magnetometer calibration library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

SPC584Cx, SPC58ECx. 32-bit Power Architecture microcontroller for automotive ASIL-B applications. Features

STSW-BNRG-Mesh. Mesh over Bluetooth low energy. Features. Description. Applications

STM32-MP3NL/DEC. STM32 audio engine MP3 decoder library. Description. Features

SPC58NE84E7, SPC58NE84C3

EVLKSTCOMET10-1. STCOMET smart meter system-on-chip development kit. Features

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery Data brief. Features. Description

Software GUI user guide for STEVAL-ISV021V1, STEVAL- IDS002V1 and STEVAL-IDS003V1 evaluation boards

UM2119 User manual. Graphical user interface (GUI) for EVAL-L9907-H. Introduction

AN3281 Application note

IoT node with BLE connectivity, digital microphone, environmental and motion sensors, motion and audio middleware libraries.

EVAL6494L. Demonstration board for L6494L gate driver. Description. Features

Getting started with STEVAL-IDB007V1 and STEVAL-IDB008V1 evaluation boards

Getting started with osxmotiongc gyroscope calibration library for X-CUBE-MEMS1 expansion for STM32Cube

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery. Features. Description

UM2216 User manual. Getting started with MotionFA fitness activity library in X CUBE MEMS1 expansion for STM32Cube. Introduction

AN5123 Application note

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

Getting started with MotionPM real-time pedometer library in X CUBE-MEMS1 expansion for STM32Cube

32F412GDISCOVERY. Discovery kit with STM32F412ZG MCU. Features. Description

TN1234 Technical note

32L476GDISCOVERY. Discovery kit with STM32L476VG MCU. Features. Description

AN5115 Application note

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on STUSB1602. Description

AN2667 Application note

UM2255 User manual. SPC58NG-DISP user manual. Introduction

Running a simple 6LowPAN network consisting of one receiver node and one or more sensor nodes in a Sub-1GHz RF band

UM1978 User manual. Multi-sensor RF platform sensor board. Introduction

AN4113 Application note

P-NUCLEO-53L1A1. VL53L1X nucleo pack with X-NUCLEO-53L1A1 expansion board and STM32F401RE nucleo board. Description. Features

AN2676 Application note

P-NUCLEO-6180X2. Proximity, gesture, ambient light sensor expansion board based on VL6180X for STM32L053R8. Description. Features

STOD32W. 100 ma triple DC-DC converter for powering AMOLED displays. Applications. Features. Description

OSPlus USB Extension. OSPlus USB 2.0 extension. Description. Features. Application. TCP/IP stack NexGenOS NexGenIP VFS. FAT Ext2 LVM Device layer

EVALSTGAP1AS. Demonstration board for STGAP1AS galvanically isolated single gate driver. Description. Features

EMIF06-HMC02F2. 6-line IPAD, EMI filter including ESD protection. Description. Features. Applications. Complies with the following standards

EV-AUTO-LDOS. L5150GJ-L5300AH7-L4995AK Evaluation Board. Applications. Features. Description

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on the STUSB1602

AN2261 APPLICATION NOTE

UM2194. Getting started with MotionAW activity recognition for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

Getting started with MotionPM real-time pedometer library in X-CUBE-MEMS1 expansion for STM32Cube

UM1844 User manual. EVAL-L9958 Graphical user interface (GUI) Introduction

AN2825 Application Note

AN2672 Application note

AN4833 Application note

STEVAL-PCC010V1. ST802RT1A Ethernet PHY demonstration board with STM32F107 controller add-on board. Features. Description

STEVAL-STLKT01V1. SensorTile development kit. Description. Features

NUCLEO-L433RC-P NUCLEO-L452RE-P

Getting started with the FP-SNS-ALLMEMS1 Bluetooth low energy and sensors software expansion for STM32Cube

AN4943 Application note

STEVAL-CCM002V1. TFT-LCD panel demonstration board based on the STM32 as LCD controller. Features. Description

UM1982 User manual. Multi-Sensor RF 868 MHz platform. Introduction

L9966. FlexInput IC for automotive applications. Data brief. Features. Description

AN4782 Application note

SPC584C80C3, SPC58EC80C3

STM32-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

STM32-SK/RAIS,STR91X-SK/RAI,STR7-SK/RAIS STM32-D/RAIS,STR9-D/RAIS,STR7-D/RAIS

EV-VND7040AJ. VND7040AJ evaluation board. Features. Applications

AN4838. Managing memory protection unit (MPU) in STM32 MCUs. Application note. Introduction

ST21NFCB. Near field communication controller. Features. RF communications. Hardware features. Communication interfaces. Electrical characteristics

Transcription:

TN1218 Technical note Interpreting humidity and temperature readings in the HTS221 digital humidity sensor Introduction The purpose of this technical note is to guide the user in the interpretation of humidity and temperature values stored in the registers of the HTS221 device. The HTS221 humidity sensor measures relative humidity (RH) and temperature (T) and stores the values as two's complement integers (16-bit words) which can be read over the I2C or SPI host interface (refer to the following figure). The values stored are raw data, available as output from the ADC, so the user has to convert the data read from the registers to obtain the temperature in C and the relative humidity in %. Figure 1. Humidity sensor analog-to-digital flow TN1218 - Rev 3 - February 2018 For further information contact your local STMicroelectronics sales office. www.st.com

How to obtain the relative humidity value (%RH) 1 How to obtain the relative humidity value (%RH) The humidity sensor HTS221 stores the humidity value in raw counts in two 8-bit registers: HUMIDITY_OUT_H (0x29) HUMIDITY_OUT_L (0x28) The 2 bytes are concatenated to form a 16-bit word which is represented in two's complement (not single bytes). The relative humidity value RH has to be computed by linear interpolation of the current registers (HUMIDITY_OUT_H & HUMIDITY_OUT_L in 2's complement) with calibration registers according to the table below. The device is factory calibrated and the coefficients required to convert the ADC 16-bit values into RH % can be read from the internal registers of the sensor listed in the table below. Further calibration by the user is not requested. Table 1. HTS221 calibration registers for computing RH% value Addr Variable Format (1) b7 b6 b5 b4 b3 b2 b1 b0 0x28 H_OUT s(16) H7 H6 H5 H4 H3 H2 H1 H0 0x29 H15 H14 H13 H12 H11 H10 H9 H8 0x30 H0_rH_x2 u(16) H0.7 H0.6 H0.5 H0.4 H0.3 H0.2 H0.1 H0.0 0x31 H1_rH_x2 u(16) H1.7 H1.6 H1.5 H1.4 H1.3 H1.2 H1.1 H1.0 0x36 H0_T0_OUT s(16) 7 6 5 4 3 2 1 0 0x37 15 14 13 12 11 10 9 8 0x3A H1_T0_OUT s16) 7 6 5 4 3 2 1 0 0x3B 15 14 13 12 11 10 9 8 1. (u16) unsigned 16-bit quantity, (s16) signed 16-bit quantity using two's complement. The steps for the humidity conversion from ADC_OUT (LSB) to RH % are described as follows: 1. Read the value of coefficients H0_rH_x2 and H1_rH_x2 from registers 0x30 & 0x31. 2. Divide by two the content of registers 0x30 (H0_rH_x2) and 0x31 (H1_rH_x2) in order to obtain the value of coefficients H0_rH and H1_rH. 3. Read the value of H0_T0_OUT from registers 0x36 & 0x37. 4. Read the value of H1_T0_OUT from registers 0x3A & 0x3B. 5. Read the humidity value in raw counts H_T_OUT from registers 0x28 & 0x29 6. Compute the RH [%] value, by linear interpolation, applying the formula below: H RH % = H1_rH H0_rH H_T_OUT H0_T0_OUT H1_T0_OUT H0_T0_OUT + H0_rH (1) Note that the H0_rH, H1_rH, H0_T0_OUT and H1_T0_OUT coefficients are factory calibrated at temperature T0 and stored in NVM memory (further calibration by the user is not required), while the H_T_OUT value (registers 0x28 & 0x29) depends on temperature T measured from the sensor during the reading of RH%. So it is possible to read the coefficients (step 1, 2, 3 and 4) only once and repeat cyclically only steps 5 and 6. Example 1: 1. Read H0_rH and H1_rH coefficients a. H0_rH_x2 = 40 => H0_rH= 40/2 = 20.0% rh; b. H1_rH_x2 = 80 => H1_rH= 80/2 = 40.0% rh; 2. Read H0_T0_OUT = 4000 3. Read H1_T0_OUT = 6000 4. Read the humidity value in raw counts H_T_OUT = 5000 5. Compute the RH[%] value by linear interpolation H_RH [%] = 30% TN1218 - Rev 3 page 2/10

TN1218 How to obtain the relative humidity value (%RH) Figure 2. Linear interpolation to convert LSB to rh % When the actual vapor pressure is equal to the saturation vapor pressure (saturation condition), the value of RH can be equal to or greater than 100%. In the last case the RH value is set to 100% by firmware code. The reference code for the HTS221_Get_Humidity API of the ST's HTS221 software library is provided in the following figure. TN1218 - Rev 3 page 3/10

How to obtain the relative humidity value (%RH) Figure 3. Reference code for HTS221_Get_Humidity API /** * @brief Read HTS221 Humidity output registers, and calculate humidity. * @param Pointer to the returned humidity value that must be divided by 10 to get the value in [%]. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ HTS221_Error_et HTS221_Get_Humidity(uint16_t* value) { int16_t H0_T0_out, H1_T0_out, H_T_out; int16_t H0_rh, H1_rh; uint8_t buffer[2]; uint32_t tmp; /* 1. Read H0_rH and H1_rH coefficients*/ if(hts221_readreg(hts221_h0_rh_x2, 2, buffer)) H0_rh = buffer[0]>>1; H1_rh = buffer[1]>>1; /*2. Read H0_T0_OUT */ if(hts221_readreg(hts221_h0_t0_out_l, 2, buffer)) H0_T0_out = (((uint16_t)buffer[1])<<8) (uint16_t)buffer[0]; /*3. Read H1_T0_OUT */ if(hts221_readreg(hts221_h1_t0_out_l, 2, buffer)) H1_T0_out = (((uint16_t)buffer[1])<<8) (uint16_t)buffer[0]; /*4. Read H_T_OUT */ if(hts221_readreg(hts221_hr_out_l_reg, 2, buffer)) H_T_out = (((uint16_t)buffer[1])<<8) (uint16_t)buffer[0]; /*5. Compute the RH [%] value by linear interpolation */ tmp = ((int32_t)(h_t_out - H0_T0_out)) * ((int32_t)(h1_rh - H0_rh)*10); *value = (uint16_t) (tmp/(h1_t0_out - H0_T0_out) + H0_rh*10); /* Saturation condition*/ if(*value>1000) *value = 1000 return HTS221_OK; } TN1218 - Rev 3 page 4/10

How to obtain the temperature value in degree Celsius ( C) 2 How to obtain the temperature value in degree Celsius ( C) The humidity sensor HTS221 stores the temperature value in raw counts in two 8-bit registers: TEMP_OUT_H (0x2B) TEMP_OUT_L (0x2A) The 2 bytes are concatenated to form a 16-bit word which is represented in two's complement (not single bytes). The most significant bit (MSB) of the TEMP_OUT_H register indicates the polarity: If the sign bit is zero, then the value read is positive If the sign bit is one, then the value read is negative: in this case we take the two's complement of the complete word. The temperature value T has to be computed by linear interpolation of the current registers (TEMP_OUT_H & TEMP_OUT_L in 2's complement) with calibration registers according to the table below. Table 2. Decoding the coefficients in the sensor Flash Adr Variable Format b7 b6 b5 b4 b3 b2 b1 b0 Output registers 28 H_OUT (s16) H7 H6 H5 H4 H3 H2 H1 H0 29 H15 H14 H13 H12 H11 H10 H9 H8 2A T_OUT (s16) T7 T6 T5 T4 T3 T2 T1 T0 2B T15 T14 T13 T12 T11 T10 T9 T8 Calibration registers 30 H0_rH_x2 (u8) H0.7 H0.6 H0.5 H0.4 H0.3 H0.2 H0.1 H0.0 31 H1_rH_x2 (u8) H1.7 H1.6 H1.5 H1.4 H1.3 H1.2 H1.1 H1.0 32 T0_degC_x8 (u8) T0.7 T0.6 T0.5 T0.4 T0.3 T0.2 T0.1 T0.0 33 T1_degC_x8 (u8) T1.7 T1.6 T1.5 T1.4 T1.3 T1.2 T1.1 T1.0 34 Reserved (u16) 35 T1/T0 msb (u2),(u2) Reserved T1.9 T1.8 T0.9 T0.8 36 H0_T0_OUT (s16) 7 6 5 4 3 2 1 0 37 15 14 13 12 11 10 9 8 38 Reserved 39 3A H1_T0_OUT (s16) 7 6 5 4 3 2 1 0 3B 15 14 13 12 11 10 9 8 3C T0_OUT (s16) 7 6 5 4 3 2 1 0 3D 15 14 13 12 11 10 9 8 3E T1_OUT (s16) 7 6 5 4 3 2 1 0 3F 15 14 13 12 11 10 9 8 The steps for the temperature conversion from ADC_OUT (LSB) to C are described as follows: 1. Read the value of coefficients T0_degC_x8 and T1_degC_x8 from registers 0x32 & 0x33. 2. Divide by 8 the content of registers 0x32 (T0_degC_x8) and 0x33 (T1_degC_x8) in order to obtain the value of coefficients T0_degC and T1_degC. TN1218 - Rev 3 page 5/10

TN1218 How to obtain the temperature value in degree Celsius ( C) 3. 4. 5. 6. 7. Read the MSB bits of T1_degC (T1.9 and T1.8 bit) and T0_degC (T0.9 and T0.8 bit) from register 0x35 to compute T0_DegC and T1_DegC. Read from registers 0x3C & 0x3D the value of T0_OUT. Read the value of T1_OUT from registers 0x3E & 0x3F. Read the value T_OUT (ADC_OUT) from 0x2A & 0x2B registers. Compute the T [degc] value, by linear interpolation, applying the following formula: T degc = T1_degC T0_degC T_OUT T0_OUT + T0_degC T1_OUT T0_OUT (2) Note that the T0_OUT, T1_OUT, T1_degC and T0_degC coefficients are factory calibrated at T0 and T1 temperatures and stored in NVM memory (further calibration by the user is not required), while the T_OUT value (0x2A & 0x2B registers) is the temperature (AD_OUT) measured from the sensor during the reading of RH%. So it is possible perform step 1 to 5 only once and repeat cyclically only steps 6 and 7. Example 2: 1. Calculate T0_degC and T1_degC coefficients starting from the value read from registers 0x32, 0x33 and 0x35. a. T0_degC_x8 = 80 C => T0_degC= 80/8 = 10.0 C; b. T1_degC_x8 = 160 C => T1_degC= 160/8 = 20.0 C; 2. Read T0_OUT = 300 3. Read T1_OUT = 500 4. Read the raw temperature value T_OUT = 400 5. Compute the T[degC] value by linear interpolation T [degc] = 15 C This is the value of temperature corresponding to the RH percentage of 30% calculated in example 1 (see Section 1 How to obtain the relative humidity value (%RH)). Figure 4. Linear interpolation to convert LSB to C The reference code for the HTS221_Get_Temperature API of ST's HTS221 software library is provided in the following figure. TN1218 - Rev 3 page 6/10

How to obtain the temperature value in degree Celsius ( C) Figure 5. Reference code for HTS221_Get_Temperature API /** * @brief Read HTS221 temperature output registers, and calculate temperature. * @param Pointer to the returned temperature value that must be divided by 10 to get the value in ['C]. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ HTS221_Error_et HTS221_Get_Temperature(int16_t *value) { int16_t T0_out, T1_out, T_out, T0_degC_x8_u16, T1_degC_x8_u16; int16_t T0_degC, T1_degC; uint8_t buffer[4], tmp; uint32_t tmp32; /*1. Read from 0x32 & 0x33 registers the value of coefficients T0_degC_x8 and T1_degC_x8*/ if(hts221_readreg(hts221_t0_degc_x8, 2, buffer)) /*2. Read from 0x35 register the value of the MSB bits of T1_degC and T0_degC */ if(hts221_readreg(hts221_t0_t1_degc_h2, 1, &tmp)) /*Calculate the T0_degC and T1_degC values*/ T0_degC_x8_u16 = (((uint16_t)(tmp & 0x03)) << 8) ((uint16_t)buffer[0]); T1_degC_x8_u16 = (((uint16_t)(tmp & 0x0C)) << 6) ((uint16_t)buffer[1]); T0_degC = T0_degC_x8_u16>>3; T1_degC = T1_degC_x8_u16>>3; /*3. Read from 0x3C & 0x3D registers the value of T0_OUT*/ /*4. Read from 0x3E & 0x3F registers the value of T1_OUT*/ if(hts221_readreg(hts221_t0_out_l, 4, buffer)) T0_out = (((uint16_t)buffer[1])<<8) (uint16_t)buffer[0]; T1_out = (((uint16_t)buffer[3])<<8) (uint16_t)buffer[2]; /* 5.Read from 0x2A & 0x2B registers the value T_OUT (ADC_OUT).*/ if(hts221_readreg(hts221_temp_out_l_reg, 2, buffer)) T_out = (((uint16_t)buffer[1])<<8) (uint16_t)buffer[0]; /* 6. Compute the Temperature value by linear interpolation*/ tmp32 = ((int32_t)(t_out - T0_out)) * ((int32_t)(t1_degc - T0_degC)*10); *value = tmp32 /(T1_out - T0_out) + T0_degC*10; return HTS221_OK; } TN1218 - Rev 3 page 7/10

Revision history Table 3. Document revision history Date Revision Changes 14-Oct-2015 1 Initial release 15-Mar-2016 2 Replaced Table 2 with a new table: Decoding the coefficients in the sensor Flash 16-Feb-2018 3 Updated Section 1 How to obtain the relative humidity value (%RH) and instruction #5 in Figure 3. Reference code for HTS221_Get_Humidity API Updated bit 0 of register 30h in Table 2. Decoding the coefficients in the sensor Flash Updated instruction #6 in Figure 5. Reference code for HTS221_Get_Temperature API TN1218 - Rev 3 page 8/10

Contents Contents 1 How to obtain the relative humidity value (%RH)...2 2 How to obtain the temperature value in degree Celsius ( C)...5 Revision history...8 TN1218 - Rev 3 page 9/10

IMPORTANT NOTICE PLEASE READ CAREFULLY STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST s terms and conditions of sale in place at the time of order acknowledgement. Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers products. No license, express or implied, to any intellectual property right is granted by ST herein. Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product. ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces information previously supplied in any prior versions of this document. 2018 STMicroelectronics All rights reserved TN1218 - Rev 3 page 10/10