Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use Adafruit HTU21D-F Temperature & Humidity Sensor: Examples, Pinouts, and Specs

Image of Adafruit HTU21D-F Temperature & Humidity Sensor
Cirkit Designer LogoDesign with Adafruit HTU21D-F Temperature & Humidity Sensor in Cirkit Designer

Introduction

The Adafruit HTU21D-F (Part ID: 1899) is a digital sensor designed to measure temperature and humidity with high accuracy and low power consumption. This compact and reliable sensor is ideal for environmental monitoring, weather stations, IoT applications, and HVAC systems. Its I2C interface makes it easy to integrate into microcontroller-based projects, including Arduino and Raspberry Pi systems.

Explore Projects Built with Adafruit HTU21D-F Temperature & Humidity Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO with HTU21D-F Sensor for Temperature and Humidity Monitoring
Image of Interfacing HTU21D Temperature and Humidity Sensor with Arduino UNO: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
This circuit connects an Arduino UNO microcontroller to an Adafruit HTU21D-F Temperature & Humidity Sensor. The Arduino is programmed to read temperature and humidity data from the sensor and output the readings to the Serial Monitor at half-second intervals. The sensor is powered by the Arduino's 5V output and communicates with the microcontroller via the I2C protocol using the SCL and SDA lines.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO with Adafruit HTU21D-F Sensor for Temperature and Humidity Monitoring
Image of Interfacing HTU21D Temperature and Humidity Sensor with Arduino UNO: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
This circuit connects an Arduino UNO to an Adafruit HTU21D-F Temperature & Humidity Sensor via I2C communication protocol. The Arduino provides power to the sensor and reads temperature and humidity data, which it then outputs to the Serial Monitor every 500 milliseconds. The purpose of this circuit is to monitor environmental conditions.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino-Based Temperature and Humidity Monitor with DHT11 and I2C LCD
Image of  I2C LCD and DHT Sim Test - I2C on analog pins: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
This circuit uses an Arduino UNO to read temperature data from a DHT11 sensor and display it on a 16x2 I2C LCD. The Arduino is programmed to periodically read the temperature and update the LCD display, providing real-time temperature monitoring.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Mega 2560-Based Multi-Sensor Weather Station with TFT Display and IR Control
Image of aqua2: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
This circuit uses an Arduino Mega 2560 to read temperature data from multiple DS18B20 sensors, display the data on an ILI9341 TFT display, and maintain time using an Adafruit DS1307 RTC module. It also receives IR signals using a VS1838B IR receiver and includes an Adafruit MS8607 PHT sensor for additional environmental monitoring.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with Adafruit HTU21D-F Temperature & Humidity Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Interfacing HTU21D Temperature and Humidity Sensor with Arduino UNO: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
Arduino UNO with HTU21D-F Sensor for Temperature and Humidity Monitoring
This circuit connects an Arduino UNO microcontroller to an Adafruit HTU21D-F Temperature & Humidity Sensor. The Arduino is programmed to read temperature and humidity data from the sensor and output the readings to the Serial Monitor at half-second intervals. The sensor is powered by the Arduino's 5V output and communicates with the microcontroller via the I2C protocol using the SCL and SDA lines.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Interfacing HTU21D Temperature and Humidity Sensor with Arduino UNO: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
Arduino UNO with Adafruit HTU21D-F Sensor for Temperature and Humidity Monitoring
This circuit connects an Arduino UNO to an Adafruit HTU21D-F Temperature & Humidity Sensor via I2C communication protocol. The Arduino provides power to the sensor and reads temperature and humidity data, which it then outputs to the Serial Monitor every 500 milliseconds. The purpose of this circuit is to monitor environmental conditions.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of  I2C LCD and DHT Sim Test - I2C on analog pins: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
Arduino-Based Temperature and Humidity Monitor with DHT11 and I2C LCD
This circuit uses an Arduino UNO to read temperature data from a DHT11 sensor and display it on a 16x2 I2C LCD. The Arduino is programmed to periodically read the temperature and update the LCD display, providing real-time temperature monitoring.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of aqua2: A project utilizing Adafruit HTU21D-F Temperature & Humidity Sensor in a practical application
Arduino Mega 2560-Based Multi-Sensor Weather Station with TFT Display and IR Control
This circuit uses an Arduino Mega 2560 to read temperature data from multiple DS18B20 sensors, display the data on an ILI9341 TFT display, and maintain time using an Adafruit DS1307 RTC module. It also receives IR signals using a VS1838B IR receiver and includes an Adafruit MS8607 PHT sensor for additional environmental monitoring.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications

  • Weather monitoring systems
  • Indoor air quality monitoring
  • IoT devices for environmental sensing
  • HVAC (Heating, Ventilation, and Air Conditioning) systems
  • Industrial and agricultural monitoring

Technical Specifications

The HTU21D-F sensor offers precise measurements and is designed for low-power operation. Below are its key technical details:

Parameter Value
Supply Voltage 3.3V to 5V
Operating Current 0.15 mA (typical)
Temperature Range -40°C to +125°C
Temperature Accuracy ±0.3°C
Humidity Range 0% to 100% RH
Humidity Accuracy ±2% RH
Communication Protocol I2C
I2C Address 0x40
Dimensions 15mm x 15mm x 2mm

Pin Configuration

The HTU21D-F sensor has four pins, as described in the table below:

Pin Name Description
1 VIN Power supply input (3.3V to 5V)
2 GND Ground connection
3 SCL I2C clock line
4 SDA I2C data line

Usage Instructions

Connecting the HTU21D-F to an Arduino UNO

To use the HTU21D-F sensor with an Arduino UNO, follow these steps:

  1. Connect the VIN pin of the sensor to the 5V pin on the Arduino.
  2. Connect the GND pin of the sensor to the GND pin on the Arduino.
  3. Connect the SCL pin of the sensor to the A5 pin on the Arduino (I2C clock line).
  4. Connect the SDA pin of the sensor to the A4 pin on the Arduino (I2C data line).

Arduino Code Example

Below is an example Arduino sketch to read temperature and humidity data from the HTU21D-F sensor. This code uses the Adafruit HTU21D-F library, which can be installed via the Arduino Library Manager.

#include <Wire.h>
#include "Adafruit_HTU21DF.h"

// Create an instance of the HTU21D-F sensor
Adafruit_HTU21DF htu = Adafruit_HTU21DF();

void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud
  Serial.println("HTU21D-F Temperature & Humidity Sensor Test");

  // Initialize the sensor
  if (!htu.begin()) {
    Serial.println("Couldn't find sensor! Check wiring.");
    while (1); // Halt execution if sensor initialization fails
  }
}

void loop() {
  // Read temperature and humidity values
  float temp = htu.readTemperature();
  float humidity = htu.readHumidity();

  // Print the values to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temp);
  Serial.println(" °C");

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");

  delay(2000); // Wait 2 seconds before the next reading
}

Important Considerations

  • Ensure proper pull-up resistors (typically 4.7kΩ) are connected to the SCL and SDA lines if your microcontroller does not have internal pull-ups.
  • Avoid exposing the sensor to extreme conditions (e.g., high humidity for prolonged periods) to maintain accuracy and longevity.
  • Handle the sensor carefully to prevent damage to its delicate components.

Troubleshooting and FAQs

Common Issues

  1. Sensor not detected by the Arduino:

    • Verify the wiring connections, especially the SCL and SDA lines.
    • Ensure the I2C address (0x40) matches the one used in the code.
    • Check for proper pull-up resistors on the I2C lines.
  2. Incorrect or fluctuating readings:

    • Ensure the sensor is not exposed to sudden temperature or humidity changes.
    • Verify that the power supply voltage is stable and within the specified range.
  3. Library not found:

    • Install the Adafruit HTU21D-F library via the Arduino Library Manager.

FAQs

Q: Can the HTU21D-F sensor operate at 3.3V?
A: Yes, the sensor is compatible with both 3.3V and 5V power supplies.

Q: What is the typical response time of the sensor?
A: The sensor has a response time of approximately 5 seconds for humidity and less than 1 second for temperature.

Q: Can I use the HTU21D-F sensor with a Raspberry Pi?
A: Yes, the sensor can be used with a Raspberry Pi via the I2C interface. Ensure proper configuration of the I2C pins and install the necessary libraries.

Q: How do I protect the sensor in harsh environments?
A: Use a protective enclosure or filter to shield the sensor from dust, water, and contaminants while allowing air to pass through.

By following this documentation, you can effectively integrate the Adafruit HTU21D-F sensor into your projects for accurate temperature and humidity measurements.