====== LamaPLC: HTU TE Connectivity temperature/humidity sensors with I²C communication ====== {{ :sensor:htu21_4.png?180|HTU21 TE Connectivity temperature/humidity sensors with I²C communication}} The HTUs are highly accurate, digital relative humidity and temperature sensors known for their low power consumption, I²C interface, and factory calibration. **Key Features** * **High Accuracy:** * **Humidity:** Typical accuracy of ±2% RH within the optimized range of 5% to 95% RH. * **Temperature:** Typical accuracy of ±0.3°C over an operating range of 0°C to 70°C. * **Digital I²C Interface:** Uses the common I²C protocol for easy integration with most microcontrollers (e.g., Arduino, ESP32, Raspberry Pi), requiring only two data lines (SDA and SCL) in addition to power. * **Low Power Consumption:** Designed for battery-powered and power-sensitive applications, with current consumption as low as 0.14µA in sleep mode. * **Wide Operating Range:** * **Humidity:** 0% to 100% RH range. * **Temperature:** -40°C to 125°C range. * **Selectable Resolution:** The resolution can be configured by the user, ranging from 8/12 bits for RH/T to a maximum of 12/14 bits for RH/T, allowing a trade-off between measurement speed and precision. * **Fast Response Time:** Offers a typical humidity response time of 5 seconds. * Factory Calibrated & Linearized: Each sensor is individually calibrated and provides a linearized digital signal, eliminating the need for complex calibration routines in the host device. * **Integrated Fault Detection:** Includes a checksum (CRC) feature to improve communication reliability and an electronic identification code stored on the chip for traceability. * **Protective Filter Option:** The HTU21D(F) variant includes an optional hydrophobic PTFE filter that protects the sensor from dust and water immersion, preserving performance in demanding environments. * **Full Interchangeability:** No calibration is required when swapping sensors under standard conditions. {{page>:tarhal}} **Difference between HTU31D, HTU21D and HTU20D** The primary difference among the HTU20D, HTU21D, and HTU31D is an incremental improvement in accuracy, supply-voltage range, and power consumption as the model number increases. The sensors are largely interchangeable and use the same I²C communication protocol. ^Specification^HTU20D^HTU21D^HTU31D| | |{{:sensor:htu20_2.png?150|}}|{{:sensor:htu21_4.png?150|HTU21}}|{{:sensor:htu31_2.png?150|}}| ^Similar types|SHT20, HTU20, Si702, GY-20 ¹|SHT21, HTU21, Si7021, GY-21, GY-213V, HDC1080 ²|SHT31, HTU31, Si7031, GY-31 ³| ^Humidity Accuracy (Typical)|±5% RH|±2% RH|±2% RH| ^Temperature Accuracy (Typical)|Not specified in source|±0.3°C|±0.2°C| ^Supply Voltage Range|1.5V - 3.6V|1.5V - 3.6V|3V - 5.5V| ^Power Consumption (Sleep)|Not specified|~0.14 µA|~0.14 µA (estimated based on similar operation)| ^Interface|I²C|I²C|I²C| ^Filter Option|HTU20D(F) option available|HTU21D(F) option available|HTU31D(F) option available| ¹: //The SHT20, HTU20, Si702, GY-20 are different manufacturers' versions of essentially the same I²C digital humidity and temperature sensor chip, designed to be hardware- and software-compatible. The GY-20 is a generic breakout board that uses one of these chips.// ²: //The SHT21, HTU21, Si7021, GY-21, GY-213V, HDC1080 are very similar digital humidity and temperature sensor chips from different manufacturers (Sensirion, Measurement Specialties, and Silicon Labs, respectively), while the GY-21 is a generic breakout board that uses one of these chips. They are largely interchangeable in hardware and software for most general-purpose applications.// ³: //The SHT31, HTU31, Si7031, and GY-31 are high-accuracy digital temperature and humidity sensor chips from different manufacturers (Sensirion, TE Connectivity, and Silicon Labs, respectively) that are designed to be largely interchangeable. The GY-31 is a generic name for a breakout board that typically uses the SHT31 chip.// ==== Arduino & HTU31D ==== To read the HTU31D, the most reliable method is to use the **Adafruit HTU31D** Library. Compared to the older HTU21D, this sensor handles a wider voltage range (3V–5.5V) and offers even better precision. **Wiring (I²C)** * **VIN:** 3.3V or 5V * **GND:** Ground * **SCL:** Pin A5 (on Uno/Nano) * **SDA:** Pin A4 (on Uno/Nano) * **ADR Pin:** Leave disconnected for default address **0x40**. Connect to VIN for 0x41. **Arduino Example Code** Install the **Adafruit HTU31D** and **Adafruit BusIO** libraries via the Arduino Library Manager. #include #include "Adafruit_HTU31D.h" Adafruit_HTU31D htu = Adafruit_HTU31D(); void setup() { Serial.begin(115200); while (!Serial) delay(10); Serial.println("HTU31D test"); if (!htu.begin(0x40)) { // Use 0x41 if ADR pin is tied to High Serial.println("Couldn't find sensor!"); while (1); } } void loop() { sensors_event_t humidity, temp; // Get both temperature and humidity at once htu.getEvent(&humidity, &temp); Serial.print("Temp: "); Serial.print(temp.temperature); Serial.print(" C \t"); Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println(" %"); delay(1000); } **Advanced Features** The HTU31D includes a built-in heater to dry the sensor if it accumulates condensation. You can toggle it in your code: * //htu.enableHeater(true);// Turn on heater * //htu.enableHeater(false);// Turn off heater **Resolution Settings** You can optimize for speed or precision using htu.setResolutions(//temp_res, hum_res//). * **Temperature:** 0.012°C to 0.04°C resolution. * **Humidity:** 0.01% to 0.02% resolution. ===== I²C topics on lamaPLC ===== {{topic>i2c}} \\ \\ {{tag>HTU HTU31D HTU21D HTU20D SHT20 HTU20 SHT21 HTU21 Si7021 GY-21 GY-213V HDC1080 Si702 GY-20 SHT31 HTU31 Si7031 GY-31 TE_Connectivity temperature humidity i2c communication sensor arduino code}} This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}