2016-08-04 01:48 AM
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.2016-08-04 11:04 AM
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,2016-08-04 09:13 PM
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;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
2016-08-05 03:11 AM
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
Antonella2016-08-05 03:39 AM
Registers readiness show that the data is ready ! Fixed code , vseravno 29.0 humidity . And with the register read 0xAE. It seems that it is certainly broken sensors .
This party was sent probes to our company as a sample for review.
The amount of 3 pieces.New corrected code:
<<
// Àäðåñ HTS221
#define HTS221R 0xBF
#define HTS221W 0xBE
// Ñòà òóñ
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;
}
// ÈÃèöèà ëèçà öèÿ
void HTS221_Init(void)
{
uint8_t Dat[2];
// Ã�à ñòðîéêà òî÷Ãîñòè
Dat[0] = 0x10;
Dat[1] = 0x1B;
HAL_I2C_Master_Transmit(&hi2c1, HTS221W, Dat, 2, 100);
// Ã�à ñòðîéêà ðåæèìà è ñêîðîñòè îòäà ÷è äà ÃÃûõ â 1 Ãö
Dat[0] = 0x20;
Dat[1] = 0x85;
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;
// Wait for
while (HTS221_GetStatus() != 3)
HAL_Delay(5);
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] = 0x36;
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;
}
>>