Page 1 of 1

Anyone used a HIH6030 humidity sensor?

Posted: Wed Apr 06, 2016 8:57 am
by richardb
I was wondering if anyone has used the HIH6030-021-001 humidity and temp sensor chip?


I have just added this part to an existing board and the temp readings don't seem to be real.

Code: Select all

Sub SendBackHIH6030()
    Dim RelativeHumidity As Word
    Dim I2cTemparature As Word
    Const StartW As Byte =$4e'(2*$27)
    Const StartR As Byte =$4f'(2*$27)+1                  
    SI2C.Start                    
    SI2C.WriteByte(startw) 
    SI2C.Stop 
    DelayMS(100) 
     SI2C.Start                    
    SI2C.WriteByte(startr)             
    RelativeHumidity.byte1=SI2C.ReadByte
    SI2C.Acknowledge(I2C_ACKNOWLEDGE)
    RelativeHumidity.byte0=SI2C.ReadByte
    SI2C.Acknowledge(I2C_ACKNOWLEDGE)
    I2cTemparature.byte1=SI2C.ReadByte
    SI2C.Acknowledge(I2C_ACKNOWLEDGE)
    I2cTemparature.byte0=SI2C.ReadByte   
    SI2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
    SI2C.Stop 
    RelativeHumidity.14 = 0  'clear status bit
    RelativeHumidity.15 = 0  'clear status bit
    USART.Write(10,13,"RH=",FloatToStr(RelativeHumidity/163.8))
    USART.Write(" Tempbin =",bintostr(I2cTemparature))
    I2cTemparature =   I2cTemparature>>2        
    USART.Write(" Tempraw2 =",dectostr(I2cTemparature))
    USART.Write(" Temp=",FloatToStr(((I2cTemparature/16382.0)*165)-40))
End Sub
I get the following result most of the time. the humidity does seem to work if I breath on it.
RH=27.344 Tempbin =111111101111111 Tempraw2 =8159 Temp=42.177

any ideas as it seems odd that its half working?
PS
this is the first time that I've used I2C

Re: Anyone used a HIH6030 humidity sensor?

Posted: Wed Apr 06, 2016 10:42 am
by Jerry Messina
I've never used that chip, but I'd start with printing out the four raw data bytes. That way you can see the two status bits.
I have a feeling that maybe the last three bytes are all reading '01111111' ($7F).

What value are the pullups on the I2C pins?

Re: Anyone used a HIH6030 humidity sensor?

Posted: Wed Apr 06, 2016 1:25 pm
by richardb
it does this for long periods when left
byte0=10001 byte1=1111111 byte2=1111111 byte3=1111111 RH=27.344 Temp=288.740
and this after breathing on it
byte0=110010 byte1=1001100 byte2=1100111 byte3=1110100 RH=78.608 Temp=226.747

the pullups are 2k2

if you google the following test the protocol is there.

I2C Comms HumidIcon TN_009061-2-EN_Final_07Jun12.pdf

Re: Anyone used a HIH6030 humidity sensor?

Posted: Wed Apr 06, 2016 5:42 pm
by Jerry Messina
I don't know why you're getting that first set or results (it must be REALLY hot where you are!),
but for the second set I get something a lot more reasonable. I took your bytes 2 and 3 and here's what I got:

Code: Select all

converting: 26484
 byte2 (msb)= 01100111
 byte3 (lsb)= 01110100
 Tempraw2= 6621
 Temp= 26.686
Here's the code I used:

Code: Select all

    I2cTemparature = 26484      ' 26484 = 0110 0111 0111 0100

    USART.Write("converting: ",dectostr(I2cTemparature), 13, 10)
    USART.Write(" byte2 (msb)= ",bintostr(I2cTemparature.byte1, 8), 13, 10)   ' 01100111
    USART.Write(" byte3 (lsb)= ",bintostr(I2cTemparature.byte0, 8), 13, 10)   ' 01110100

    I2cTemparature =   I2cTemparature>>2        // 26484 >> 2 = 6621       
    USART.Write(" Tempraw2= ",dectostr(I2cTemparature), 13, 10)
    USART.Write(" Temp= ",FloatToStr(((I2cTemparature/16382.0)*165)-40), 13, 10)     // 26.686
Maybe there's something you have to do to trigger a new measurement?

Re: Anyone used a HIH6030 humidity sensor?

Posted: Fri Apr 08, 2016 6:54 am
by richardb
sorry for the slow reply as I was off work!

I should have noticed but I'd commented out the shift by mistake the values are as below.
byte0=10010 byte1=1111111 byte2=1111111 byte3=1111111 RH=28.907 Temp=42.177
even so...

if I breath on it I occasionally gives more reasonable temp results but no real use if its this erratic.

did you manage to look at the pdf?

I was wondering if I've don something obviously wrong as I have never used I2c before.

Re: Anyone used a HIH6030 humidity sensor?

Posted: Fri Apr 08, 2016 9:28 am
by SHughes_Fusion
A couple of quick suggestions.

Firstly, you don't seem to be checking the status bits, just assuming the results are OK. May be worth adding a check.

Second, is your clock set up correctly? You are assuming the DelayMS(100) is long enough for the conversion to complete. The datasheet does say 50mS so it should be but that function only works if the Clock definition is correct at the start of your source. As above, polling the status bits would be a better solution.

Thirdly, probably not an issue, but it says to start a conversion you send the address with write set, wait for an ACK from the sensor then send a stop. I'm not sure if the software I2C looks for the ACK or not, it could be that you think the start measurement is being sent but it isn't.

Re: Anyone used a HIH6030 humidity sensor?

Posted: Fri Apr 08, 2016 10:57 am
by richardb
Firstly, you don't seem to be checking the status bits, just assuming the results are OK. May be worth adding a check.
I'm not checking in the app but I can see on the terminal that the 2 bits are always zero. if I reduce the delay to 10ms I get bit 6 (s0)set every other cycle. Which is what you would expect.

yes the clock looks correct.

There maybe something to your last point, although I'm not sure yet how I will resolve that.

Re: Anyone used a HIH6030 humidity sensor?

Posted: Mon Apr 11, 2016 8:23 am
by richardb
It's amazing what a weekend does!.

this is a little embarrassing but...

I almost always leave B.6 and B.7 free but I'd run out of pins on this board, I had remembered to disable the debug that I normally send out on these pins but I had forgotten that leaving the programmer connected might add some capacitance/additional loading.


It seems that everything if fine once the programmer is removed. :oops:

Thanks for everyone's help :)

PS although not obvious in the documentation.

A NotAcknowledged Boolean is available to the user to test for acknowledgement of the sent byte.


Rich