ZHCU873D June   2021  – February 2025 HDC3020 , HDC3020-Q1 , HDC3021 , HDC3021-Q1 , HDC3022 , HDC3022-Q1 , HDC3120 , HDC3120-Q1

 

  1.   1
  2.   摘要
  3.   商标
  4. 1HDC3x 器件
    1. 1.1 HDC3x2x 封装比较
    2. 1.2 采用 WSON 封装的 HDC3020
    3. 1.3 采用 WSON 封装的 HDC3021
    4. 1.4 采用 WSON 封装的 HDC3022
    5.     采用 WSON 封装的 HDC3120
  5. 2存储和处理指南
    1. 2.1 暴露于污染物中
    2. 2.2 化学分析
      1. 2.2.1 饱和和恢复测试
      2. 2.2.2 长时间暴露
    3. 2.3 包装和存储
      1. 2.3.1 封装
      2. 2.3.2 在极端环境中的应用
  6. 3对 HDC3020 进行编程
    1. 3.1 功能模式
    2. 3.2 按需触发
    3. 3.3 自动测量
    4. 3.4 对 CRC 进行编程
      1. 3.4.1 CRC C 代码
    5. 3.5 示例代码
    6. 3.6 凝结消除
    7. 3.7 偏移误差校正
      1. 3.7.1 采用指板的偏移误差校正示例
  7. 4参考资料
  8. 5修订历史记录

示例代码

示例 C 代码可以在 SysConfg 中通过 ASCStudio 找到:HDC302x 示例代码

以下代码提供了一个示例,说明如何使用 Arduino 对 HDC302x 执行温度和湿度读取操作:

//HDC302x Sample Code v0.2
//Texas Instruments
//HG

#include <Wire.h>

// Data buffer to hold data from HDC Sensor
uint8_t HDC_DATA_BUFF[4];

//Humidity Variables
uint16_t HUM_MSB;
uint16_t HUM_DEC;
uint16_t HUM_OUTPUT;

//Temperature Variables
uint16_t TEMP_MSB;
uint16_t TEMP_DEC;
uint16_t TEMP_OUTPUT;

//Device and Address Configurations

#define DEVICE_ADDR 0x45       //

//Lowest noise, highest repeatability 
#define DEVICE_CONFIG_MSB 0x24 // 
#define DEVICE_CONFIG_LSB 0x00 //

void setup() {

  // put your setup code here, to run once:
  Wire.begin();
  Serial.begin(115200);
  Serial.println("HDC302x Sample Code");

}

void loop() {

  float humidity;
  float temp;

// send device command for highest repeatability 
  Wire.beginTransmission(DEVICE_ADDR);
  Wire.write(0x24); //send MSB of command
  Wire.write(0x00); //command LSB
  Wire.endTransmission();
  delay(25); //wait 25 ms before reading

  Wire.requestFrom(DEVICE_ADDR, 6); //request 6 bytes from HDC device
  Wire.readBytes(HDC_DATA_BUFF, 6); //move 6 bytes from HDC into a temporary buffer

  temp = getTemp(HDC_DATA_BUFF);
  Serial.print("Temp (C): ");
  Serial.println(temp);

  delay(1000);

  humidity = getHum(HDC_DATA_BUFF);
  Serial.print("Humidity (RH): ");
  Serial.print(humidity);
  Serial.println("%");

  delay(1000);

}

float getTemp(uint8_t humBuff[]) {

  float tempConv;
  float celsius;

  TEMP_MSB = humBuff[0] << 8 | humBuff[1]; //shift 8 bits off data in first array index to get MSB then OR with LSB
  tempConv = (float)(TEMP_MSB);
  celsius = ((tempConv / 65535) * 175) - 45; //calculate celcius using formula in data sheet
  
  return celsius; 

}

float getHum(uint8_t humBuff[]){

  float humConv;
  float humidity;

  HUM_MSB = (humBuff[3] << 8) | humBuff[4]; //shift 8 bits off data in first array index to get MSB then OR with LSB
  humConv = (float)(HUM_MSB);
  humidity = (humConv / 65535) * 100; //calculate celcius using formula in datasheet

  return humidity;

}