交换传感器测试,工作,固定标识符读取正确(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;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
交换传感器测试,工作,固定标识符读取正确(188或0xBC)两者的数据表,但寄存器中的数据不更新。尝试了所有选项注册设置。始终是同一个29%的湿度。温度也是固定的。准备就绪将数据准备好的报告记录为温度和湿度。显然是有缺陷的批次。
我的代码:
&LT;&LT;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++
//ÃÃÃÃåå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(&amp; hi2c1,HTS221W,Dat,2,100);
//ÃÃÃÃÃÃÃÃÃðÃÃÃÃÃÃÃÃÃÃÃ?Ã
Dat [0] = 0x10;
Dat [1] = 0x1B;
HAL_I2C_Master_Transmit(&amp; 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(&amp; hi2c1,HTS221W,Dat,1,100);
HAL_I2C_Master_Receive(&amp; hi2c1,HTS221R,Dat,2,100);
H0_rh = Dat [0]&gt;&gt; 1;
H1_rh = Dat [1]&gt;&gt; 1;
Dat [0] = 0x30;
HAL_I2C_Master_Transmit(&amp; hi2c1,HTS221W,Dat,1,100);
HAL_I2C_Master_Receive(&amp; hi2c1,HTS221R,Dat,2,100);
H0_T0_out =(((uint16_t)Dat [1])&lt;&lt; 8)| (uint16_t)Dat [0];
Dat [0] = 0x3A;
HAL_I2C_Master_Transmit(&amp; hi2c1,HTS221W,Dat,1,100);
HAL_I2C_Master_Receive(&amp; hi2c1,HTS221R,Dat,2,100);
H1_T0_out =(((uint16_t)Dat [1])&lt;&lt; 8)| (uint16_t)Dat [0];
Dat [0] = 0x28;
HAL_I2C_Master_Transmit(&amp; hi2c1,HTS221W,Dat,1,100);
HAL_I2C_Master_Receive(&amp; hi2c1,HTS221R,Dat,2,100);
H_T_out =(((uint16_t)Dat [1])&lt;&lt; 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(&amp; hi2c1,HTS221W,&amp; Byte,1,100);
HAL_I2C_Master_Receive(&amp; hi2c1,HTS221R,&amp; Byte,1,100);
返回字节;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++
&GT;&GT;
以上来自于谷歌翻译
以下为原文
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;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
举报