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.
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 |
Power Connections:
I2C Connections:
Microcontroller Configuration:
#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
}
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.