cancel
Showing results for 
Search instead for 
Did you mean: 

Why are my HTS221s getting bad temperature values?

IC.1
Associate II

0693W000008ypLHQAY.png0693W000008ypJBQAY.png 

I want to know if anyone else has encountered this, I have multiple HTS221 on different boards, and they all give me different temperature values. They are "working," in the fact that when I put my hand on the sensor the temperature increases, etc, but are just giving me wrong temperature values.

I have begun to suspect that it is the factory calibration values. Here are the calibration values and temperature readings from 3 different boards above. You can see t0_out for one of them differ by a lot, but the T_OUT is quite similar. The temperatures are in the form XX.X C, so 245 C is actually 24.5 C. Help is appreciated.

15 REPLIES 15

Niccolo,

Yes, the behavior is consistent across all my sensors.

I've been a bit bad in explaining my problem, let me try again.

The humidity value I am reading now is 77.5%. I have a temperature/humidity sensor that I bought by Dracal, which seems to be very accurate, to compare the temperature and humidity values. Right now, the temperature of the hts221 and the Dracal sensor are very consistent, besides the humidity. Dracal is reading 54.9% while hts221 is reading 77.5%.

That is very interesting... I looked at my humidity values on my screenshot just now. That is true, it seems that it was reading the right values before.

I will look into that.

The specific problem with the SPI was this. I have two functions, one for reading a single byte, and one for reading multiple bytes through SPI. My problem was in the function that was reading multiple bytes through SPI. The first problem with it was that it first off was reading bad values. Second, was that I found out for both the functions, I had to do an extra clock cycle for the SPI to read the right value. I tested the correctness of this by reading from the WHO_AM_I register.

I use the function that reads multiple bytes through SPI to get all the calibration values, reading 16 bytes starting from 0x30, so from 0x30 to 0x3F. The problem in the past was that my calibration values were getting bad values because my function wasn't working correctly in the first place.

It could very well have affected the humidity readings... which is interesting given the presupposition that I was reading correct humidity values and wrong temperature values before, and now I am reading the wrong humidity values and right temperature values.

And yes, I understand that the 0x28 register is only a part of the whole data. I am reading both registers and then shifting the upper register to the left by 8 bits (<< 8) and combining them.

Thanks for the tips, I will look at what could have changed the humidity readings.

Isaac

0693W00000AOz3dQAD.png0693W00000AOz3YQAT.pngHere are the results from two different sensors. You can see the temperature is quite accurate, while the humidity is off, even when compared with just each other. The humidity value on the Dracal sensor reads 53.3%.

I also posted the calibration values in case that helps.

By the way, to answer your previous question, this is a driver I wrote myself. Would seeing the code for it help?

Isaac

Hi Isaac @IC.1​ ,

it is indeed strange that the humidity values were right while reading them in a wrong way =\

I would start from that to check why they are not what we should expect now.

is the extra clock cycle the only difference?

another check you can do is trying to read 4 times the 0x28 and 0x29 registers, but with a little twist:

first time start from 0x27 and read 3 registers

second time start from 0x27 and read 4 registers

third time read 0x27,28,29,2A as single outputs

let's see if there are any discrepancies.

checking the code is somewhat of a last resort, because I don't have the same hardware you do, so it's better if you debug it

Niccolò

Niccolò,

No problem, I was just wondering for what reason you asked what driver I was using.

So I tried all of your suggestions, and they all read the same value, so I don't think it is something wrong with SPI for now.

The extra clock cycle wasn't the only difference, the function that read multiple bytes had something wrong with reading multiple bytes in the first place, it had something to do with a counter, but anyways it is fixed now.

The thing is though, although the humidity from the very first screenshots seem correct, I don't know if they were correct since I didn't have the Dracal sensor.

Thanks, I will continue debugging.

Isaac

Hi Isaac @IC.1​ ,

I'm sorry if I can't help you more, but I think you are taking the right steps toward the solution

feel free to ask any other questions you may have

Niccolò

I've received new hardware, and both the temperature and humidity values seem much more accurate, although still not up to the specifications of the datasheet. I don't think there is anything else I can do. Thanks for the help.

Isaac