Measures 0 to100% humidity and -40 to 125°C temperature with I2C interface
Description
The GY-21 HTU21D Humidity / Temperature Sensor Module uses the I2C interface to report both humidity (0 – 100%) and temperature (-40 – 125°C).
PACKAGE INCLUDES:
GY-21 HTU21D Humidity / Temperature Sensor Module
1×4 Male Header Strip
KEY FEATURES OF GY-21 HTU21D HUMIDITY / TEMPERATURE MODULE:
Reports humidity over range of 0% to 100% RH
Humidity reading accuracy is ±2% over 5 to 95% RH (typ)
Reports temperature over range of -40 to 125°C
Temperature reading accuracy is ±0.6°C over range of -30°C to 90°C (typ)
Fast <50mS read time
Uses I2C interface
3.3 and 5V logic compatible
This GY-21 module mounts the HTU21D which is a combined humidity and temperature sensor. The HTU21D sensor itself operates at 3V. The backside of the module mounts a 3.3V regulator and level shifting MOSFET transistors to make the module compatible with both 3.3V and 5V MCUs.
The small size of the module allows it to be mounted into just about anything for monitoring or controlling humidity and/or temperature such as thermostats, humidistats, indoor weather stations and similar devices.
The HTU21D sensor is capable of reading humidity over the full range of 0 to 100% RH with a typical accuracy of ± 2% over the range of 5 to 95% with a maximum of ± 5% at the extremes of the range. Humidity reading has 12-bit resolution by default.
The maximum temperature range of the device is -40 to 125°C. The HTU21D temperature sensor has a typical accuracy of ±0.4°C over the range of 0 to 70°C with a maximum of ±1°C over -30 to 90°C and a maximum of ±1.6°C at the extreme ends of the -40 to 125°C range. The temperature reading has a 14-bit resolution by default.
The sensor has a small window for air to contact the sensor. Keep contaminates away from the window as that can affect the accuracy of the humidity reading. The window must remain open to the air, but it can be protected from dust and similar contaminates with a PTFE membrane, gauze or other material that still allows air to flow through or by positioning it in an enclosure where air passes through but is protected from excess dust or moisture.
If soldering to the board, it is safest to forego cleaning any flux from the board, though it can be done if care is used to not allow the cleaning solution to enter the window of the sensor.
Module Connections
The module has a 4-pin header on the assembly.
1 x 4 Header
VIN = Connect to 3.3V or 5V to match MCU.
GND = Connect to system ground. This ground needs to be in common with the MCU.
SCL = I2C Clock / SCL – Connects to SCL on MCU
SDA = I2C Data / SDA – Connects to SDA on MCU
OUR EVALUATION RESULTS:
This is a nice very small module for humidity and temperature measurement with good accuracy and repeatability.
Once up and running with a microcontroller, it is easy to test basic functionality of the module by breathing on the sensor. That will increase both humidity and temperature temporarily.
The test program below uses the Adafruit_HTU21DF.h library that can be downloaded from the Arduino IDE Library Manager. It is very minimalistic, but easy to use.
Simply connect the VIN pin to either 3.3V or 5V to match your MCU and ground to ground.
SCL and SDA pins connect to the same on the MCU.
The program outputs the measured temperature in °C and °F along with the humidity. Once the program is downloaded, open the Serial Monitor window and set to 9600 baud to see the output. This shows an example output. It is snowing outside, so humidity is very low.
HTU21D Humidity / Temperature Sensor Test Program
/*************************************************** GY-21 HTU21D Test Program Connect Vin to 3-5VDC to match MCU Connect GND to ground Connect SCL to I2C SCL clock pin Connect SDA to I2C SDA data pin ****************************************************/#include<Wire.h>#include"Adafruit_HTU21DF.h"Adafruit_HTU21DFHTU21=Adafruit_HTU21DF();//===============================================================================// Initialization//===============================================================================voidsetup(){Serial.begin(9600);Serial.println("HTU21D Test");if(!HTU21.begin()){Serial.println("Sensor not found!");while(1);}}//===============================================================================// Main//===============================================================================voidloop(){floattempC=HTU21.readTemperature();floatrelative_hum=HTU21.readHumidity();Serial.print("Temp: ");Serial.print(tempC);Serial.print(" C : ");floattempF=(tempC*1.8+32);// Convert C to FSerial.print(tempF);Serial.print(" F ");Serial.print("Relative Humidity: ");Serial.print(relative_hum);Serial.println(" %");delay(1000);}
BEFORE THEY ARE SHIPPED, THESE MODULES ARE:
Sample inspected and tested per incoming shipment.
Reliable JST connector cables with secure locking design, UL-certified wires, and high-quality crimping. Supports up to 3A current with compact 2.5mm pitch. Ensures stable power and signal transmission for PCB, LED, robotics, and industrial use. Custom lengths, colors, and pin counts available.
cables are made with high-purity copper wires and solid copper terminals, ensuring excellent conductivity, low resistance, and long-term reliability in power and signal transmission. Ideal for high-performance electronic applications.
Are any purchases final sale?
We are unable to accept returns on certain items. These will be carefully marked before purchase.
When will I get my order?
We will work quickly to ship your order as soon as possible. Once your order has shipped, you will receive an email with further information. Delivery times vary depending on your location.
Where are your products manufactured?
Our products are manufactured both locally and globally. We carefully select our manufacturing partners to ensure our products are high quality and a fair value.
How much does shipping cost?
Shipping is calculated based on your location and the items in your order. You will always know the shipping price before you purchase.