cancel
Showing results for 
Search instead for 
Did you mean: 

HTS221 and SPI using HTS221_Driver.c

Posted on May 14, 2016 at 21:08

Hello,

i tried to connect my STM32F103 to a HTS221 sensor, but I do not get correct values for temperature and humidity. HTS221_Driver.c has version 1.0.0 from 07/04/2014 What I did so far:


...

HTS221_Set_PowerDownMode(HTS221_SET); // Tried with HTS221_RESET as well

... // Do other stuff for ~10ms

uint8_t deviceId;

HTS221_Get_DeviceID(&deviceId); // successfully returns 0xbc

HTS221_StartOneShotMeasurement();

HTS221_BitStatus_et humidityStatus = HTS221_RESET, temperatureStatus = HTS221_RESET;

while (temperatureStatus == HTS221_RESET) {

HTS221_Get_DataStatus(&humidityStatus, &temperatureStatus);

}

HTS221_Get_Temperature(&tempTemperature);

while (humidityStatus == HTS221_RESET) {

HTS221_Get_DataStatus(&humidityStatus, &temperatureStatus);

}

HTS221_Get_Humidity(&tempHumidity);

HTS221_DeActivate();

humidity = ((float) tempHumidity / 10); // Result is 100%

temperature = ((float) tempTemperature / 10); // Result is 127°C

Did I missed anything? Please help me, I checked a lot of code samples but most of them deal with I2C only. Thx in advance! Alexander #hts221 #stm32f10x
1 REPLY 1
licciardello.anto
Associate II
Posted on May 16, 2016 at 10:14

Hi,

Can you try to read the CTRL_REG1 (0x20h) after the HTS221_Set_PowerDownMode instruction?

What is the read value?

Keep in mind that HTS221_ReadReg and HTS221_WriteReg instructions in the driver, have to be remapped with functions using SPI and that for HTS221 SPI is 3 wires.

Do you have check that the device is correctly read and written at level of SPI?

Regards

Antonella