# HIH-4030 Humidity Sensor and Arduino

Maybe I'm not understanding how to use the analog voltage reading from the Arduino with this sensor.

If 0 is 0 volts, and 1023 is 5 volts, it looks to me like this sensor would output a value between 0 and 765 from analogRead()

I'm getting that 765 number by taking the maximum voltage output according to the datasheet (3.75 volts at 25 degrees C and 100%ish RH on average), and dividing that my the 4.9mV per unit that the analogRead function is supposed to return.. So :

3750 / 4.9 = 765.30

If 765.30 is the max the sensor should return, then getting the RH% should be to divide the value from analogRead() by 765, and multiply by 100, correct?

It can't be, so I'm clearly doing something wrong ;-)

I have this setup in my office and the average reading is 265, which by my calculation would me 34.6% RH - but that seems REALLY low. Unfortunately I don't have any way to verify that number. Can someone help?

Are you handling the numbers as floats and not ints?

No, the analogRead() is storing a value in an int.

I did all the math outside the Arduino. Right now the sketch just reads from the analog pin and sends that value to the serial port.

For example, right now I'm getting a pretty steady "280" from the sensor.

Doing the math on that, that's about 36% RH - and I seriously doubt that is accurate since that is only slightly higher than the average RH of the Sahara Desert ;-)

I know I must be doing something wrong...

No, the analogRead() is storing a value in an int.

Yes but all the other maths must be done as floats or else the divisions truncate and mess up your values.

The recommended level of indoor humidity is in the range of 30-60%. [9][10]

That is from:-

http://en.wikipedia.org/wiki/Thermal_comfort

so I am not sure why you think:-

36% RH - ...... that is only slightly higher than the average RH of the Sahara Desert

says

The region's low relative humidity rarely exceeds 30% and is often in the 4% to 5% range.

Thanks Mike - it looks like the information I based my expectation on was totally wrong.

I guess this thing is working just the way it should. I'll stick it in the humidor tonight and see how the numbers match up there.

Looks like you edited your original reply.. I was relying on the (lacking) knowledge of a co-worker. He insisted that 30% wasn't accurate so I trusted him on it.

He now has office cleanup duty for a month ;-)

hello, im trying to read this sensor and ive got a problem.. the datasheet says that to read the sensor at 25 degrees C you must do this (VOUT - 0.958)/0.0307 .For example at Vout = 2V you get (2 - 0.958)/0.0307 = 33.9%RH but if you look at the graph in Vout = 2V you should get 40%RH. Wich one is the correct method to read this sensor?

(2-.958)/.0307 = 33.94, not 62. You subtracted .0958, not .958.

That’s closer to the 40% value indicated by the graph as well as by the equation up in Table 1, though far enough away that there must be something else going on.

oops yes.iv modified it but still its not the 40% that i see in the graph

6% off isn't terrible.

Are you positive about the ambient temperature?

No cause the temperature will be stable at 25 C. The 6% isn't terrible but its mentionable and i want to be as accurate as i can

So..Any help on this?