ESP32 HDC1080 / GY-213V-HDC1080 Temperature and Humidity Sensor Pinout
Overview
The HDC1080 sensor is a digital humidity and temperature sensor that provides accurate and reliable measurements. Its low power consumption and factory calibration make it ideal for applications such as HVAC systems, weather stations, and consumer electronics.
About HDC1080 / GY-213V-HDC1080 Temperature and Humidity Sensor
The HDC1080, developed by Texas Instruments, is a high-accuracy digital humidity and temperature sensor designed for low-power applications. With factory-calibrated sensors and a wide supply voltage range, it offers a cost-effective and energy-efficient solution for various environmental monitoring applications.
⚡ Key Features
- Low Power Consumption – Ideal for battery-powered IoT and embedded systems.
- Factory-Calibrated Sensors – Ensures high accuracy without additional calibration.
- Wide Operating Voltage – Compatible with various power sources.
- I²C Communication – Simple integration with ESP32, Arduino, and other microcontrollers.
With its efficient power usage and reliable performance, the HDC1080 is a great choice for climate control, smart home devices, and portable monitoring applications. 🚀
Where to Buy HDC1080 / GY-213V-HDC1080 Temperature and Humidity Sensor
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
HDC1080 / GY-213V-HDC1080 Datasheet and Technical Specifications
HDC1080 / GY-213V-HDC1080 Pinout Diagram
The VCC
pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND
pin is the ground connection and must be connected to the ground of your ESP32.
The HDC1080 pinout is as follows:
- Pin 1 (GND): Ground.
- Pin 2 (VDD): Power supply voltage (2.7V to 5.5V).
- Pin 3 (SDA): Serial Data Line for I2C communication.
- Pin 4 (SCL): Serial Clock Line for I2C communication.
HDC1080 / GY-213V-HDC1080 Wiring with ESP32
- Connect VDD to the 3.3V pin on the ESP32.
- Connect GND to the ground (GND) of the ESP32.
- Connect SDA to the ESP32's GPIO21 (default I2C data pin).
- Connect SCL to the ESP32's GPIO22 (default I2C clock pin).
- Place pull-up resistors (10kΩ) between SDA and VDD, and SCL and VDD, to ensure reliable communication.
HDC1080 / GY-213V-HDC1080 Troubleshooting Guide
Common Issues
💧 Humidity Readings Stuck at 100%
Issue: The HDC1080 sensor reports a constant humidity value of 100%, regardless of the actual environmental conditions.
Possible causes include sensor saturation due to prolonged exposure to high humidity environments or contamination on the sensor's surface.
Solution: Allow the sensor to operate in a controlled, lower humidity environment to facilitate recovery. If the issue persists, consider activating the sensor's internal heater to help eliminate moisture or contaminants. Ensure that the sensor is not exposed to condensing environments, and verify that no physical obstructions or residues are present on the sensor's surface. (e2e.ti.com)
🌡️ Temperature and Humidity Readings Return 0xFFFF
Issue: Attempts to read temperature and humidity values from the HDC1080 sensor consistently return 0xFFFF
, indicating a communication error.
Possible causes include incorrect I2C communication sequences, improper sensor initialization, or issues with the microcontroller's I2C implementation.
Solution: Review the I2C communication sequence to ensure it aligns with the HDC1080 datasheet specifications. Confirm that the sensor's configuration register is correctly set before initiating measurements. Additionally, verify the integrity of the I2C connections and consider testing with a different microcontroller or I2C library to rule out implementation-specific issues. (e2e.ti.com)
⚠️ Humidity Measurement Errors Up to +6%
Issue: The HDC1080 sensor exhibits humidity measurement errors, with readings deviating by up to +6% from the actual humidity levels.
Possible causes include sensor drift over time, exposure to contaminants, or calibration issues.
Solution: Implement a regular calibration schedule to maintain measurement accuracy. Ensure that the sensor is protected from environmental contaminants and consider using conformal coatings if appropriate. If the sensor has been exposed to harsh conditions, utilize the internal heater to attempt recovery. For critical applications, consider cross-referencing readings with a calibrated reference device. (e2e.ti.com)
🔄 Inconsistent Humidity Readings Across Multiple Sensors
Issue: Multiple HDC1080 sensors in identical conditions report significantly different humidity values, indicating inconsistency among sensors.
Possible causes include manufacturing variances, sensor contamination, or differences in sensor placement leading to micro-environmental discrepancies.
Solution: Perform a controlled comparison by placing all sensors in a stable environment and recording their outputs. Identify and replace any outliers that consistently deviate from the mean. Ensure that all sensors are handled and soldered according to the manufacturer's guidelines to prevent contamination. For applications requiring high precision, consider individual sensor calibration. (e2e.ti.com)
Debugging Tips
🔍 Serial Monitor
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
⚡ Voltage Checks
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
HDC1080 / GY-213V-HDC1080 Code Examples
Arduino Example
#include <Wire.h>
#include "ClosedCube_HDC1080.h"
ClosedCube_HDC1080 hdc1080;
void setup() {
Wire.begin();
Serial.begin(9600);
hdc1080.begin(0x40);
}
void loop() {
float temperature = hdc1080.readTemperature();
float humidity = hdc1080.readHumidity();
Serial.print("Temperature: ");
Serial.print(temperature, 2);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity, 2);
Serial.println(" %");
delay(2000);
}
ESP-IDF Example
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/i2c.h"
#define I2C_MASTER_SCL_IO 22 /!< GPIO number used for I2C master clock /
#define I2C_MASTER_SDA_IO 21 /!< GPIO number used for I2C master data /
#define I2C_MASTER_NUM I2C_NUM_0 /!< I2C master I2C port number /
#define I2C_MASTER_FREQ_HZ 100000 /!< I2C master clock frequency /
#define HDC1080_SENSOR_ADDR 0x40 /!< HDC1080 I2C address /
static esp_err_t i2c_master_init(void) {
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.scl_io_num = I2C_MASTER_SCL_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
esp_err_t err = i2c_param_config(I2C_MASTER_NUM, &conf);
if (err != ESP_OK) {
return err;
}
return i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);
}
void read_hdc1080_sensor() {
uint8_t data[4];
// Send command to measure temperature and humidity
uint8_t cmd = 0x00; // Temperature measurement command
i2c_master_write_to_device(I2C_MASTER_NUM, HDC1080_SENSOR_ADDR, &cmd, 1, pdMS_TO_TICKS(1000));
vTaskDelay(pdMS_TO_TICKS(15)); // Delay for measurement to complete
// Read 4 bytes of data: temperature (2 bytes) + humidity (2 bytes)
i2c_master_read_from_device(I2C_MASTER_NUM, HDC1080_SENSOR_ADDR, data, 4, pdMS_TO_TICKS(1000));
// Convert temperature and humidity values
uint16_t raw_temp = (data[0] << 8) | data[1];
uint16_t raw_humidity = (data[2] << 8) | data[3];
float temperature = (raw_temp / 65536.0) 165.0 - 40.0;
float humidity = (raw_humidity / 65536.0) 100.0;
printf("Temperature: %.2f °C, Humidity: %.2f %%\n", temperature, humidity);
}
void app_main() {
ESP_ERROR_CHECK(i2c_master_init());
while (1) {
read_hdc1080_sensor();
vTaskDelay(pdMS_TO_TICKS(2000));
}
}
ESPHome Example
sensor:
- platform: hdc1080
temperature:
name: "Living Room Temperature"
humidity:
name: "Living Room Humidity"
update_interval: 60s
update_interval
is set to 60 seconds, ensuring that the sensor data is updated once per minute.PlatformIO Example
platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
closedcube/ClosedCube HDC1080 @ ^1.1.0
monitor_speed = 115200
PlatformIO Example Code
#include <Wire.h>
#include "ClosedCube_HDC1080.h"
ClosedCube_HDC1080 hdc1080;
void setup() {
Wire.begin();
Serial.begin(115200);
hdc1080.begin(0x40);
Serial.println("HDC1080 initialized.");
}
void loop() {
float temperature = hdc1080.readTemperature();
float humidity = hdc1080.readHumidity();
Serial.print("Temperature: ");
Serial.print(temperature, 2);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity, 2);
Serial.println(" %");
delay(2000);
}
ClosedCube_HDC1080
library to interface with the HDC1080 sensor. It initializes the sensor and reads temperature and humidity data every 2 seconds, printing the results to the Serial Monitor.MicroPython Example
from machine import I2C, Pin
from time import sleep
# Initialize I2C
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# HDC1080 I2C address
HDC1080_ADDR = 0x40
# Function to read temperature and humidity
def read_hdc1080():
i2c.writeto(HDC1080_ADDR, b'\x00') # Command to start measurement
sleep(0.015) # Wait for measurement to complete
data = i2c.readfrom(HDC1080_ADDR, 4) # Read 4 bytes of data
# Convert temperature and humidity data
raw_temp = (data[0] << 8) | data[1]
raw_humidity = (data[2] << 8) | data[3]
temperature = (raw_temp / 65536.0) 165.0 - 40.0
humidity = (raw_humidity / 65536.0) 100.0
return temperature, humidity
while True:
temp, hum = read_hdc1080()
print("Temperature: {:.2f} °C".format(temp))
print("Humidity: {:.2f} %".format(hum))
sleep(2)
Conclusion
The ESP32 HDC1080 / GY-213V-HDC1080 Temperature and Humidity Sensor is a powerful environment sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.