Other Parts Discussed in Thread: HDC3020,
Dear,
One customer used HDS3022 for his application, now he met the question is that the tested humidity result is higher .temp=31.75 humidity=23
While he tested the temperature is about 26, and humidity is 39.
He used the flying lead test:
Does he need compensation? If there is calibration before factory?
Below is the code, please help to analyze:
// set offset
op = HDC3020_OFFSET_MSB<<8|HDC3020_OFFSET_LSB;
buf[0] = 0x00;
buf[1] = 0x00;
buf[2] = hdc3020_crc(buf, 2);
i2c_write_poll(op, buf, 3);
[2:30 PM] Eking-YiQing Chen
int hdc3020_read(int32_t values[])
{
uint16_t op = HDC3020_MODE_TRIG_MSB<<8|HDC3020_MODE_TRIG_LPM0;
uint8_t buf[6] = {0};
i2c_write_poll(op, buf, 0);
rt_thread_mdelay(20);
i2c_read_poll(op, buf, 6);
// check temp crc
uint8_t tcrc[] = {buf[0], buf[1], buf[2]};
if (hdc3020_crc(tcrc, 3))
{
// crc error
return -1;
}
// check humidity crc
uint8_t hcrc[] = {buf[3], buf[4], buf[5]};
if (hdc3020_crc(hcrc, 3))
{
// crc error
return -1;
}
/* store temperature */
values[0] = ((int32_t)buf[0]) << 8 | buf[1];
/* store humidity */
values[1] = ((int32_t)buf[3]) << 8 | buf[4];
return 0;
}
int32_t hdc3020_toCelsius(int32_t x)
{
float f = ((float) x) / 65535 * 175 - 45;
return (int32_t)(f * 100);
}
int32_t hdc3020_toRH(int32_t x)
{
float f = ((float) x) / 65535 * 100;
return (int32_t)f;
}
Best regards
kailyn