HTU21D is a digital humidity sensor with temperature output that uses MEAS (Measurement Specialties), the chip has embedded in a reflow solderable Dual flat leads (DFN) package with a size of 3X3X0.9MM. The HTU21D provides a calibrated linearized signal in digital, additionally, it communicates using TWI / i2C protocol. These chips are designed and dedicated to temperature and humidity plug/play transducers along with reliable and accurate measurements. However, with the integration of most popular microcontroller are need to acquire signal output with this sensor. HTU21X is powered by 3 ~ 3.8 max voltage suitable for home appliances, medical equipment, printers, humidifiers, handheld devices, computers, any devices that do expose to -40 Degree to 125 Degree Celsius.
This sensor is calibrated and factory tested with a checksum improves communication reliability, with a resolution that can be changed by a command 8/12bit up to 12/14bit. Additionally, it has an optional PTFE filter membrane that protects the HTU2D sensor against dust and water immersion as well as against contamination by a particle. These PTFE filters preserve a high response time and integrated already in the sensor housing.
The HTU21D is suitable for many uses, especially for environmental purposes, and digital probes. For more technical details please refer to the technical documentation and datasheets below.
Requirements and Alternatives
- Arduino IDE | Atmel Studio | MPLAB | Energia | PlatformIO | Processing |
- Eclipse IDE | embedXcode | Ktechlab | Codebender | Visual Micro | Zeus IDE
- SONY SPRESENSE Development Board
- Please refer to this link
- ESPRESSIF
- ESP8266 12, 12E, ESP32, ESP8266 NodeMCU, ESPDuino
- Microchip
- ATMEGA4809 Curiosity Nano, ChipKIT DP32, chipKIT WF32,
- ARDUINO
- MKR WAN, MK, MKR, PRO, FIO, NANO, EVERY, UNO, MINI, MEGA, PRO MINI, LEO, BT, DUE, ETHERNET,LILYPAD, ATMEGA328 16/12, ATMEGA32u4 16/8/ MHz, ESP8266,ATMEGA250 16 MHz, ATSAM3x8E, STM32,
- Note: For AVR (please see the flash size of the MCU and respective pin-outs & bus configuration )
- Note: The Diagram below is using ATMEGA328TQFP & ATMEGA4809. (please refer to each MCU’s respective pin-outs & bus configuration)
- Others
- Teensy, MSP430 Launchpad, Flora, Metro, Trinket, Pro Trinket, LinkItOne.
- HTU21D Sensor
- XC6206 3.0 Regulator / AMS1117 3.3v Regulator
- NTJD4401N Dual N-Channel MOSFET
- Resistors (See below required values)
- Capacitor(See below required values)
Wiring Guide
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
#include <htu21d.h> htu21d m_htu21d; void setup() { htu21_battery_status battery_status; htu21_status status; Serial.begin(9600); Serial.println("14CORE | TEST CODE FOR >>>"); Serial.println("======== HTU21D ========="); m_htu21d.begin(); status = m_htu21d.get_battery_status(&battery_status); Serial.println(battery_status == htu21_battery_ok ? "Battery OK" : "Battery LOW"); m_htu21d.set_i2c_master_mode(htu21_i2c_hold); } void loop() { htu21_status status; float temperature; float humidity; boolean connected; connected = m_htu21d.is_connected(); if (connected) { Serial.println(connected ? "Sensor Connected" : "Sensor Disconnected"); status = m_htu21d.read_temperature_and_relative_humidity(&temperature, &humidity); Serial.print("---Temperature = "); Serial.print(temperature, 1); Serial.print((char)176); Serial.println("C"); Serial.print("---Humidity = "); Serial.print(humidity, 1); Serial.println("%RH"); } else { Serial.println(connected ? "Sensor Connected" : "Sensor Disconnected"); } delay(1000); } |
Downloads
- Download the TE-HTU21D Datasheet
- Download the TE0HTU21D Product Manual
- Download TE-HTU21D Code Library