ST意法半导体
直播中

李皓茗

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

STM32F103连接到HTS221传感器没有得到正确的温度和湿度值

你好,


我试图将我的STM32F103连接到HTS221传感器,但我没有得到正确的温度和湿度值。
HTS221_Driver.c从07/04/2014开始的1.0.0版本

到目前为止我做了什么:

我错过了什么吗?
请帮助我,我检查了很多代码示例,但大多数只处理I2C。

Thx提前!
亚历山大
#hts221#stm32f10x

以上来自于谷歌翻译


以下为原文




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:

  • 01.

  • ...

  • 02.

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

  • 03.

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

  • 04.

  • uint8_t deviceId;

  • 05.

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

  • 06.

  • HTS221_StartOneShotMeasurement();

  • 07.

  • HTS221_BitStatus_et humidityStatus = HTS221_RESET, temperatureStatus = HTS221_RESET;

  • 08.

  • while (temperatureStatus == HTS221_RESET) {

  • 09.



  • HTS221_Get_DataStatus(&humidityStatus, &temperatureStatus);

  • 10.

  • }

  • 11.

  • HTS221_Get_Temperature(&tempTemperature);

  • 12.

  • while (humidityStatus == HTS221_RESET) {

  • 13.



  • HTS221_Get_DataStatus(&humidityStatus, &temperatureStatus);

  • 14.

  • }

  • 15.

  • HTS221_Get_Humidity(&tempHumidity);

  • 16.

  • HTS221_DeActivate();

  • 17.

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

  • 18.

  • 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)

李代三

2018-12-3 09:59:19
嗨,
 
 您可以尝试在HTS221_Set_PowerDownMode指令后读取CTRL_REG1(0x20h)吗?
 什么是读取值?
 
 请记住,驱动程序中的HTS221_ReadReg和HTS221_WriteReg指令必须使用SPI重新映射,而HTS221 SPI则需要3线。
 您是否检查过设备是否正确读取和写入SPI级别?
 
 问候
 安东内拉

以上来自于谷歌翻译


以下为原文








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
举报

更多回帖

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