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_HTU21DF HTU21 = Adafruit_HTU21DF(); //=============================================================================== // Initialization //=============================================================================== void setup() { Serial.begin(9600); Serial.println("HTU21D Test"); if (!HTU21.begin()) { Serial.println("Sensor not found!"); while (1); } } //=============================================================================== // Main //=============================================================================== void loop() { float tempC = HTU21.readTemperature(); float relative_hum = HTU21.readHumidity(); Serial.print("Temp: "); Serial.print(tempC); Serial.print(" C : "); float tempF = (tempC * 1.8 + 32); // Convert C to F Serial.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.
Notes:
- None
Technical Specifications
Maximum Ratings | ||
Vcc | Range | 3.3 to 5.5V |
Vmax | <200uA | |
Tmin | Minimum Sampling Period | 50mS |
Operating Ratings | ||
Humidity | Max Range | 0% to 100%RH (± 5%RH) |
Optimum Range | 5% to 95%RH (± 2%RH typ) | |
Temperature | Max Range | -40 to 125°C (±1.6°C) |
Optimum Range | -30 to 90°C (±0.6°C typ ) | |
Dimensions | L x W (PCB) | 13.5 x 10.5mm (0.53 x 0.42″) |
Datasheet | TE | HTU21D |