Blog
No More Fluctuating Readings! HDC1080 High-Precision Sensor is Awesome
Introduction
HDC1080 is an integrated digital temperature and humidity sensor that delivers exceptional measurement accuracy with ultra-low power consumption, offering up to 14-bit measurement resolution, ±2% relative humidity accuracy, and ±0.2°C temperature accuracy. It maintains excellent stability even in high-humidity environments. The sensor operates at a supply voltage range of 2.7V to 5.5V, providing high voltage compatibility. As a cost-effective and low-power alternative to competing solutions, it is widely used in common temperature and humidity measurement applications.
Pin Functions
| Pin | I/O TYPE | DESCRIPTION |
|---|---|---|
| SDA | I/O | Serial data line for I2C, open-drain; requires a pull-up resistor to VDD. |
| GND | G | Ground |
| NC | – | These pins may be left floating, or connected to GND. |
| VDD | P | Supply Voltage |
| SCL | I | Serial clock line for I2C, open-drain; requires a pull-up resistor to VDD. |
| DAP | – | Die Attach Pad. Should be left floating. (On bottom of the device, not shown in the figure) |
I2C Timing
The HDC1080 communicates with the host as a slave device via the I2C bus. Since the HDC1080’s address is fixed as 1000000 (7-bit address), multiple HDC1080 devices cannot be connected on the same I2C bus. After power-on, the sensor enters its operational state within a maximum of 15ms. The SCL clock frequency ranges from a minimum of 10kHz to a maximum of 400kHz.
To read or write sensor registers, the desired register address value must be written to the pointer register (the pointer value is the first byte transmitted after the address byte). That is, after sending the slave addressing address, the host sends the address of the specific register to be operated on. Each write operation to the HDC1080 requires a value in the pointer register. Register bytes are transmitted with the MSB first, followed by the LSB. The fixed address of the HDC is a 7-bit binary code (1000000X), where the last bit indicates the read/write flag: 10000000 is the write address, and 10000001 is the read address.
- The host initiates a start signal, sends the 7-bit slave device address along with a write register command, and the slave device sends an acknowledgment signal upon receiving it.
- The host sends the 8-bit register address, and the slave device receives and sends an acknowledgment signal.
- The host sends the high 8-bit data, and the slave device receives and sends an acknowledgment signal.
- The host sends the low 8-bit data, the slave device receives and sends an acknowledgment signal, and then the host issues a stop signal.
According to the write register timing, the HDC1080 write function is implemented as follows:
void HDC1080_WriteReg(u8 Addr, u16 Data)
{
unsigned char data[2];
data[0] = (uint8_t)((Data & 0xFF00) >> 8); // High byte of data
data[1] = (uint8_t)(Data & 0x00FF); // Low byte of data
IIC_Start();
IIC_Send_Byte(0x80); // Device address 10000000, write operation
IIC_Wait_Ack(); // Wait for slave acknowledgement
IIC_Send_Byte(Addr); // Write register address
IIC_Wait_Ack();
IIC_Send_Byte(data[0]); // Send high byte data
IIC_Wait_Ack();
IIC_Send_Byte(data[1]); // Send low byte data
IIC_Wait_Ack();
IIC_Stop(); // Stop signal
}
- The host sends a start signal, transmits the 7-bit slave device address along with a write register command, and the slave device responds with an acknowledgment signal after receiving it.
- The host sends the register address to be read, and the slave device returns an acknowledgment signal after receiving it.
- The host sends a start signal, transmits the 7-bit slave device address along with a read register command, and the slave device responds with an acknowledgment signal after receiving it.
- The slave device transmits the high 8-bit data, and the host receives it and sends an acknowledgment signal.
- The slave device transmits the low 8-bit data, and the host receives it and sends an acknowledgment signal, after which the host issues a stop signal.
According to the read register timing, the HDC1080 read function is written as follows:
u16 HDC1080_ReadReg(u8 Addr)
{
unsigned char bytes[2];
u16 data; // 16-bit data to be received (2 bytes)
IIC_Start();
IIC_Send_Byte(0x80); // Address: 10000000, write address
IIC_Wait_Ack();
IIC_Send_Byte(Addr); // Register address to read
IIC_Wait_Ack();
IIC_Start();
IIC_Send_Byte(0x81); // Address: 10000001, read address
IIC_Wait_Ack();
bytes[1] = IIC_Read_Byte(1); // Read high byte data
bytes[0] = IIC_Read_Byte(1); // Read low byte data
IIC_NAck();
IIC_Stop();
data = (bytes[1] << 8) + bytes[0];
return data; // Return 16-bit data
}
Register Description
Register Address Mapping
The key addresses to note are 0x00 (temperature data), 0x01 (humidity data), and 0x02 (sensor configuration). Other addresses store ID information and can generally be ignored.
# define HDC1080_TEMPERATURE 0x00
# define HDC1080_HUMIDITY 0x01
# define HDC1080_CONFIGURATION 0x02
Registers from 0x03 to 0xFA are reserved and must not be written to. The HDC1080 features an 8-bit pointer that specifies which data register is to be accessed. This pointer determines which data register responds to read or write commands executed on the two-wire bus. The pointer register is set each time a write command is issued. Before executing a read command, a write command must be issued to set the pointer to the correct value.
Temperature Register
The temperature register is a 16-bit result register in binary format (the two least significant bits, D1 and D0, are always 0), and the acquired result is always a 14-bit value. The accuracy of the result is related to the selected conversion time. The temperature can be calculated from the output data as follows:
Humidity Register
The humidity register is a 16-bit result register in binary format (the two least significant bits, D1 and D0, are always 0). The acquired result is always a 14-bit value, and its accuracy is related to the selected conversion time. The relative humidity can be calculated from the output data as follows:
Configuration Register
| Field | Bits | Explanation |
|---|---|---|
| RST | [15] | Software reset bit. 0: Normal operation (this bit is automatically cleared). 1: Software reset. |
| Reserved | [14] | 0: Reserved, must be set to 0. |
| HEAT | [13] | Heater function. 0: Heater disabled, 1: Heater enabled. |
| MODE | [12] | Sampling mode. 0: Temperature or humidity, 1: Sequential sampling of temperature and humidity, with temperature prioritized. |
| BTST | [11] | Battery status. 0: Voltage > 2.8V, 1: Voltage < 2.8V. |
| TRES | [10] | Temperature measurement resolution. 0: 14-bit, 1: 11-bit. |
| HRES | [9:8] | Humidity measurement resolution. 00: 14-bit, 01: 11-bit, 10: 8-bit. |
| Reserved | [7:0] | 0: Reserved, must be set to 0. |
Device Measurement Configuration
By default, the HDC1080 will first perform a temperature measurement, followed by a humidity measurement. Upon power-up, the HDC1080 enters a low-power sleep mode and cannot actively measure. Use the following steps to execute temperature and humidity measurements and then retrieve the results:
- Configure the acquisition parameters in register address 0x02.
- Set the acquisition mode to measure both temperature and humidity by configuring bit [12] to 1.
- Set the desired temperature measurement resolution.
Set bit [10] to 0 to achieve 14-bit resolution.
Set bit [10] to 1 to obtain 11-bit resolution.
- Set the desired humidity measurement resolution.
Set bits [9:8] to 00 to achieve 14-bit resolution.
Set bits [9:8] to 01 to obtain 11-bit resolution.
Set bits [9:8] to 10 for 8-bit resolution.
- Trigger the measurement by executing a pointer write transaction and setting the address pointer to 0x00.
Set the address pointer to 0x00 for temperature measurement.
Set the address pointer to 0x01 for humidity measurement.
- Wait for the measurement to complete according to the conversion time.
- Read the output data.
Read temperature data from register address 0x00, then read humidity data from register address 0x01 within a single transaction. If the measurement results are not yet available, the read operation will return a NACK.
Note
During temperature or relative humidity measurements, the output registers (addresses 0x00 and 0x01) can be read without affecting any ongoing measurements. Please note that writing to addresses 0x00 or 0x01 while a measurement is in progress will abort the ongoing measurement.
Typical Application Circuit
HDC1080 Arduino
Mode of Connection
| HDC1080 | OLED | Arduino |
|---|---|---|
| VCC | VCC | 3.3V |
| GND | GND | GND |
| SCL | SCL | SCL(A5) |
| SDA | SDA | SDA(A4) |
Arduino Code
#include
#include
#include
// Device addresses
#define OLED_ADDR 0x3C
#define HDC1080_ADDR 0x40
// OLED object
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
Serial.begin(9600);
Wire.begin();
// Initialize OLED
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.setTextColor(WHITE);
// Scan I2C devices
scanI2C();
}
void loop() {
float temp = readTemperature();
float hum = readHumidity();
// Display on OLED
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0, 0);
display.print("T:");
display.print(temp, 1);
display.println("C");
display.print("H:");
display.print(hum, 1);
display.println("%");
display.display();
// Output to Serial
Serial.print("Temp: ");
Serial.print(temp, 1);
Serial.print("C, Hum: ");
Serial.print(hum, 1);
Serial.println("%");
delay(2000);
}
// Read temperature
float readTemperature() {
Wire.beginTransmission(HDC1080_ADDR);
Wire.write(0x00);
Wire.endTransmission();
delay(20);
Wire.requestFrom(HDC1080_ADDR, 2);
if(Wire.available() >= 2) {
uint16_t raw = (Wire.read() << 8) | Wire.read();
return (raw * 165.0 / 65536.0) - 40.0;
}
return -99.9;
}
// Read humidity
float readHumidity() {
Wire.beginTransmission(HDC1080_ADDR);
Wire.write(0x01);
Wire.endTransmission();
delay(20);
Wire.requestFrom(HDC1080_ADDR, 2);
if(Wire.available() >= 2) {
uint16_t raw = (Wire.read() << 8) | Wire.read();
return raw * 100.0 / 65536.0;
}
return -1.0;
}
// I2C device scan
void scanI2C() {
Serial.println("Scanning I2C...");
for(byte addr=1; addr<127; addr++) {
Wire.beginTransmission(addr);
if(Wire.endTransmission() == 0) {
Serial.print("Device: 0x");
Serial.println(addr, HEX);
}
}
}
Precautions
- The recommended I2C clock frequency is ≤400 kHz.
- Long-term exposure to condensation environments may affect accuracy.
- The heater function can be used for defogging (increasing current consumption by 2.5mA).
Application
- HVAC
- Smart Thermostats and Room Monitors
- White Goods
- Printers
- Handheld Meters
- Medical Devices
- Wireless Sensor
Relative Information
FAQ
1. How to Properly Configure the I2C Address of HDC1080 for Reading Temperature and Humidity Data?
When using the HDC1080 sensor, a common issue is incorrect I2C address configuration, which leads to the inability to accurately read temperature and humidity data. The default I2C address of the HDC1080 is 0x40, but its address can be modified via the AD0 pin (AD0 grounded corresponds to 0x40, pulled high to 0x41). If the program does not correctly match the address of the actual hardware connection, communication will fail.
Solution
First, verify the state of the AD0 pin to ensure the I2C address defined in the code matches the hardware configuration. For example, in Arduino, use Wire.beginTransmission(0x40) or Wire.beginTransmission(0x41) based on the actual connection. Additionally, ensure proper initialization of the I2C bus and call the appropriate register configuration (such as writing configuration parameters to address 0x02 to set the resolution). If data still cannot be read, use an I2C scanning tool to check whether the device address is correctly recognized. This helps quickly locate issues and ensures normal communication.
2.What is the difference between HDC1080 and SI7021?
- Measurement Accuracy & Flexibility
- HDC1080: Superior humidity accuracy (±2% RH typical), supports 8-bit low-resolution mode for scenarios demanding higher power efficiency and speed, and temperature accuracy (±0.2°C typical) is also slightly better than the SI7021.
- SI7021: Slightly lower accuracy but meets the needs of most general applications. Resolution is limited to 12/14-bit (humidity) and 11/14-bit (temperature), with fewer configuration options.
2.Functional Expansion
- HDC1080: Introduces two practical features—a built-in heater (activation removes condensation on the sensor surface, reducing measurement drift in high-humidity environments) and battery voltage monitoring (providing power supply status via registers, suitable for battery-powered devices).
- SI7021: Features a simple design with no additional auxiliary functions, focusing solely on temperature and humidity acquisition.
3.Power Consumption & Package
- HDC1080: Slightly higher sleep mode power consumption (100nA typical), but with a slightly larger package (3mm × 3mm) offering better heat dissipation, making it suitable for scenarios with thermal management requirements.
- SI7021: Lower sleep mode power consumption (60nA typical), smaller package size (2.5mm × 2.5mm), higher space utilization, suitable for compact devices.
4.Compatibility
- HDC1080: The I2C address is fixed at 0x40 and cannot be modified, so address conflicts must be considered when networking multiple devices.
- SI7021: Supports four selectable I2C addresses, configurable via hardware pins, offering greater flexibility for networking.