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 is a high-quality, digital temperature and humidity sensor that communicates over an I2C interface. It offers excellent measurement accuracy and is ideal for a wide range of applications, including environmental monitoring, HVAC control, and weather stations. Its small form factor and low power consumption make it suitable for portable and battery-powered devices.

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

Technical Specifications

Key Features

  • Measurement Range:
    • Temperature: -40°C to +125°C
    • Humidity: 0 to 100% RH
  • Accuracy:
    • Temperature: ±0.3°C
    • Humidity: ±2% RH
  • Resolution:
    • Temperature: 0.01°C
    • Humidity: 0.04% RH
  • Operating Voltage: 3.3V to 5V
  • Current Consumption: 500µA during measurement, 1.5µA in standby
  • Communication Interface: I2C
  • I2C Address: 0x40 (fixed)

Pin Configuration

Pin Number Name Description
1 VDD Power supply (3.3V to 5V)
2 GND Ground connection
3 SDA I2C Data line
4 SCL I2C Clock line

Usage Instructions

Integration with a Circuit

  1. Power Connections:

    • Connect the VDD pin to a 3.3V or 5V power supply.
    • Connect the GND pin to the ground of the power supply.
  2. I2C Connections:

    • Connect the SDA pin to the I2C data line of your microcontroller.
    • Connect the SCL pin to the I2C clock line of your microcontroller.
    • If necessary, use pull-up resistors on the SDA and SCL lines.
  3. Microcontroller Configuration:

    • Set up the I2C interface on your microcontroller.
    • Use the I2C address 0x40 to communicate with the sensor.

Best Practices

  • Place the sensor in a location with good air circulation to ensure accurate measurements.
  • Avoid exposing the sensor to direct sunlight or moisture.
  • Use proper ESD precautions when handling the sensor to prevent damage.

Example Code for Arduino UNO

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

// Create an instance of the Adafruit_HTU21DF class
Adafruit_HTU21DF htu = Adafruit_HTU21DF();

void setup() {
  Serial.begin(9600);
  Serial.println("HTU21D-F test");

  if (!htu.begin()) {
    Serial.println("Couldn't find sensor!");
    while (1);
  }
}

void loop() {
  float temp = htu.readTemperature();
  float humidity = htu.readHumidity();

  // Check if any reads failed and exit early (to try again).
  if (isnan(temp) || isnan(humidity)) {
    Serial.println("Failed to read from HTU21D-F sensor!");
    return;
  }

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

  delay(2000); // Wait a few seconds between measurements
}

Troubleshooting and FAQs

Common Issues

  • Sensor Not Detected: Ensure that the wiring is correct and that the sensor is properly powered.
  • Inaccurate Readings: Verify that the sensor is not placed near heat sources or in direct sunlight.
  • I2C Communication Errors: Check for proper pull-up resistors on the SDA and SCL lines.

FAQs

Q: Can the sensor be used with a 5V microcontroller? A: Yes, the HTU21D-F can be interfaced with both 3.3V and 5V systems.

Q: How long should I wait between measurements? A: The sensor can provide a new measurement every 2 seconds. It's recommended to wait at least this long for the most accurate readings.

Q: Is the sensor waterproof? A: No, the HTU21D-F is not waterproof and should be protected from moisture and condensation.

For further assistance, consult the Adafruit HTU21D-F datasheet and the Adafruit support forums.