 # HIH4000 humidity sensor, can't make it work

I'm trying to measure humidity, but I get 46,44%RH always. There must be some error in my calculations. If I put sensor in higher humidity, analog input voltage rises. Sensor in connected to analog input 5 and supply voltage is measured with analog input 4. Sensor datasheet: http://www.phanderson.com/hih-4000.pdf

``````  float temp = float(tempC);

float dV = Vout/Vsupply;

float temp_compensation = (Vout-(0,9237-0,0041*temp+0,000040*(temp*temp)))/(0,0305+0,000044*temp-0,0000011*(temp*temp));
float humidity = ((dV-0,16)/0,0062);
float humidity_compensated = humidity+temp_compensation;
Serial.print(humidity_compensated);
Serial.println("% RH");
``````
``````float(5)
``````

An explicit cast of 5 to float is silly, when 5.0 IS a float.

float temp = float(tempC);

This is silly, too. Just assign temp the value in tempC. An implicit cast will be performed. The explicit cast is not needed.

``````  float temp_compensation = (Vout-(0,9237-0,0041*temp+0,000040*(temp*temp)))/(0,0305+0,000044*temp-0,0000011*(temp*temp));
float humidity = ((dV-0,16)/0,0062);
``````

It might be a convention in your area to use the , as a decimal point, but compilers expect . as the decimal point. The comma operator does something completely different.

It does not hurt to add more parentheses to make certain that the operators are applied in the correct order.

PaulS: It might be a convention in your area to use the , as a decimal point, but compilers expect . as the decimal point. The comma operator does something completely different.

It does not hurt to add more parentheses to make certain that the operators are applied in the correct order.

Thanks. I changed all commas to dots and I got a result that changes. But humidity and temp compensation are both over 67% and compensated humidity is over 130%. I don't know if I read datasheet correctly. I probably have some errors in that formula...

What, exactly, is connected to pin 4?

The calculation of Vin and Vsupply is based on 5.0. I would have expected you to have determined Vin based on Vsupply.

I probably have some errors in that formula...

I think that there is. The formula that you are trying to use for temp_compensation, has RH in it, on the data sheet, but not in your formula.

The calculation of RH is based on Vout (what you call Vin) and Vsupply, not dV.

Analog pin 4 has +5V connected. Analog pin 5 has sensor output connected. Vout is voltage from sensor and Vsupply is Arduino's supply voltage. I could probably just use number 5 instead of Vsupply calculation, because voltage regulator should be pretty exact. Somehow I calculated that I need Vout/Vsupply so I made dV. I should check that over tomorrow. My mind is too tired, I guess.

I don't know if this is right. Long time passed since school and math lessons. :D

``````from this
Vout=(0.0305+0.000044*T-0.0000011*T*T)(Sensor RH)+(0.9237-0.0041*T+0.000040*T*T)
to that:
Sensor RH = (Vout-(0.9237-(0.0041*tempC)+(0.000040*(tempC*tempC))))/(0.0305+(0.000044*tempC)-(0.0000011*(tempC*tempC)));
``````

Temperature sesnor is DS18B20. results: 25.81C 58.31% RH

Temperature sesnor is DS18B20. results: 25.81C 58.31% RH

Does this pass the sniff test? That is, do these values feel reasonable for the environment in which they were taken?

I can't say anything about the humidity, but last days have been really warm. Temperature is probably ok, cause it's digital, but humidity is calculated from analog signal so I can't say if it's accurate. I should probably find calibrated moisture meter and then compare.

I have one more HIH4000 sensor, but it only outputs 3.00V no matter where I put it. It's probably dead?