ST意法半导体
直播中

莫钻红

7年用户 240经验值
私信 关注
[问答]

hts221返回0xAE

HTS221读取所有湿度寄存器后的最终值始终为29.0%且未及时更改。所有数据寄存器都包含0xAE值。 HTS221的ST固件驱动程序也返回了29.0%和0xAE寄存器值。
根据数据表,标准的连接图

尝试了几个传感器,一个和同一个。对不起我的英语不好。

以上来自于谷歌翻译


以下为原文




HTS221 after read all humidity registers final value always 29.0% and not changed in time. All data register contain 0xAE values. ST firmware driver for HTS221 also returned 29.0% and 0xAE registers values.
Connection diagram of the standard, according to datasheet
.
Tried several sensors, one and the same. sorry for my english.

回帖(3)

赵羽

2018-10-24 11:29:31
你好,
 
 
我也在尝试使用HTS221传感器,并一直怀疑固件。我想知道你是否有一个名为HAL_EnvSensors.h的文件以及HTS221固件。如果有的话,请你分享一下这个文件吗?
 
谢谢,

以上来自于谷歌翻译


以下为原文





Hello,


I am also trying to work with HTS221 sensor and have been posting doubts about the firmware. I would like to know if you have a file called HAL_EnvSensors.h along with the HTS221 firmware. Can you please share the file, in case you have it?  

Thanks,
举报

莫钻红

2018-10-24 11:48:21
交换传感器测试,工作,固定标识符读取正确(188或0xBC)两者的数据表,但寄存器中的数据不更新。尝试了所有选项注册设置。始终是同一个29%的湿度。温度也是固定的。准备就绪将数据准备好的报告记录为温度和湿度。显然是有缺陷的批次。
 
我的代码:
 
<<
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++
 
//ÃÃÃÃååHTS221
#define HTS221R 0xBF
#define HTS221W 0xBE
 
//ÃÃÃèèÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃèÿ
void HTS221_Init(void)
{
 uint8_t Dat [2];
 
 //ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃððÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃà ÃÃÃÃÃÃÃÃÃâ1Ãö¶
 Dat [0] = 0x20;
 Dat [1] = 0x85;
 HAL_I2C_Master_Transmit(& hi2c1,HTS221W,Dat,2,100);
 
 //ÃÃÃÃÃÃÃÃÃðÃÃÃÃÃÃÃÃÃÃÃ?Ã
 Dat [0] = 0x10;
 Dat [1] = 0x1B;
 HAL_I2C_Master_Transmit(& hi2c1,HTS221W,Dat,2,100);
}
 
//Ã-ÃÃÃÃÃÃÃÃÃÃÃÀÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃüÃ
void HTS221_GetHymidity(void)
{
 uint8_t Dat [4];
 int16_t H0_T0_out,H1_T0_out,H_T_out;
 int16_t H0_rh,H1_rh;
 uint32_t tmp;
 
 Dat [0] = 0x30;
 HAL_I2C_Master_Transmit(& hi2c1,HTS221W,Dat,1,100);
 HAL_I2C_Master_Receive(& hi2c1,HTS221R,Dat,2,100);
 H0_rh = Dat [0]>> 1;
 H1_rh = Dat [1]>> 1;
 
 Dat [0] = 0x30;
 HAL_I2C_Master_Transmit(& hi2c1,HTS221W,Dat,1,100);
 HAL_I2C_Master_Receive(& hi2c1,HTS221R,Dat,2,100);
 H0_T0_out =(((uint16_t)Dat [1])<< 8)| (uint16_t)Dat [0];
 
 Dat [0] = 0x3A;
 HAL_I2C_Master_Transmit(& hi2c1,HTS221W,Dat,1,100);
 HAL_I2C_Master_Receive(& hi2c1,HTS221R,Dat,2,100);
 H1_T0_out =(((uint16_t)Dat [1])<< 8)| (uint16_t)Dat [0];
 
 Dat [0] = 0x28;
 HAL_I2C_Master_Transmit(& hi2c1,HTS221W,Dat,1,100);
 HAL_I2C_Master_Receive(& hi2c1,HTS221R,Dat,2,100);
 H_T_out =(((uint16_t)Dat [1])<< 8)| (uint16_t)Dat [0];
 
 //ÃÃÃÃÃÃåå
 tmp =((uint32_t)(H_T_out - H0_T0_out))*((uint32_t)(H1_rh - H0_rh)* 10);
 CHymidity = tmp /(H1_T0_out - H0_T0_out)+ H0_rh * 10;
 if(CHymidity> 1000)CHymidity = 1000;
 CHymidity / = 10.0;
}
 
//Ã'ÃÃÃÃÃÃÃÃÃñ
uint8_t HTS221_GetStatus(void)
{
 uint8_t Byte = 0x27;
 HAL_I2C_Master_Transmit(& hi2c1,HTS221W,& Byte,1,100);
 HAL_I2C_Master_Receive(& hi2c1,HTS221R,& Byte,1,100);
 返回字节;
}
 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++
>>

以上来自于谷歌翻译


以下为原文








Exchange with sensor tested, working, fixed identifier read correctly (188 or 0xBC) datasheet for both, but the data in the registers are not updated. Having tried all the options register settings. Always one and the same humidity of 29%. The temperature is also fixed. readiness Register reports that are ready the data as temperature and humidity. Apparently the defective batch.



My code:



<<

// ++++++++++++++++++++++++++++++++ HTS221 +++++++++++++++++++++++++++++++++++++



// Àäðåñ HTS221

#define HTS221R 0xBF

#define HTS221W 0xBE



// Èíèöèà ëèçà öèÿ

void HTS221_Init(void)

{

                uint8_t Dat[2];

               

                // Ã�à ñòðîéêà Ã°Ã¥Ã¦Ã¨Ã¬Ã  Ã¨ ñêîðîñòè îòäà ÷è äà ííûõ â 1 Ãö

                Dat[0] = 0x20;

                Dat[1] = 0x85;

                HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 2, 100);



                // Ã�à ñòðîéêà Ã²Ã®Ã·Ã­Ã®Ã±Ã²Ã¨

                Dat[0] = 0x10;

                Dat[1] = 0x1B;

                HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 2, 100);         

}



// ×èòà åì âëà æíîñòü

void HTS221_GetHymidity(void)

{

                uint8_t Dat[4];

                int16_t H0_T0_out, H1_T0_out, H_T_out;

                int16_t H0_rh, H1_rh;

                uint32_t tmp;



                Dat[0] = 0x30;

                HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                H0_rh = Dat[0] >> 1;

                H1_rh = Dat[1] >> 1;

               

                Dat[0] = 0x30;

                HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                H0_T0_out = (((uint16_t) Dat[1]) << 8) | (uint16_t) Dat[0];

               

                Dat[0] = 0x3A;

                HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                H1_T0_out = (((uint16_t) Dat[1]) << 8) | (uint16_t) Dat[0];

               

                Dat[0] = 0x28;

                HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 1, 100);

                HAL_I2C_Master_Receive(&hi2c1, HTS221R, Dat, 2, 100);

                H_T_out = (((uint16_t)Dat[1]) << 8) | (uint16_t) Dat[0];

               

                // Ã�à ñ÷åò

                tmp =((uint32_t)(H_T_out - H0_T0_out)) * ((uint32_t)(H1_rh - H0_rh) * 10);

                CHymidity = tmp / (H1_T0_out - H0_T0_out)  + H0_rh * 10;

                if (CHymidity > 1000) CHymidity = 1000;

                CHymidity /= 10.0;

}



// Ñòà òóñ

uint8_t HTS221_GetStatus(void)

{

                uint8_t Byte = 0x27;

                HAL_I2C_Master_Transmit(&hi2c1, HTS221W, &Byte, 1, 100);

                HAL_I2C_Master_Receive(&hi2c1, HTS221R, &Byte, 1, 100);

                return Byte;

}



// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

>>
举报

李代三

2018-10-24 12:01:03
嗨,
 
 我见过你的代码,我有一些建议和问题:1。在设置AV_CONF(10h)寄存器然后设置CTRL_REG1(20h)寄存器之前,应该更好地改变HTS221_Init的设置顺序。
2.在HTS221_GetHymidity中,我猜有一个错误。
 
 要获得H0_T0_out值,必须读取0x36寄存器而不是0x30; 3。我不清楚你在哪里使用函数HTS221_GetStatus。
 
 在调用HTS221_GetHymidity之前,您是否调用了此功能并检查了湿度数据是否准备就绪?
 
 安东内拉

以上来自于谷歌翻译


以下为原文






Hi,

I 've seen your code and I have some suggestions and questions:1. In the HTS221_Init should be better change the order of settings, before set the AV_CONF (10h) register and then the CTRL_REG1 (20h) register.
2. In the HTS221_GetHymidity, I guess there is an mistake.

To get the H0_T0_out value, you have to read the 0x36 register and not 0x30;3. I am not clear where you use the function HTS221_GetStatus.

Did you call this function and checked that the humidity data is ready before to call the HTS221_GetHymidity?Regards

Antonella
举报

更多回帖

发帖
×
20
完善资料,
赚取积分