Go Down

### Topic: HIH-4030 Humidity Sensor and Arduino (Read 1 time)previous topic - next topic

#### Jay_OR

##### Jun 20, 2012, 05:59 pm
Hi,

In the old forum, I found this topic:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267245927

Indicating how to convert the values ??in% RH, dewpoint and humidex.
But the function to convert dewpoint, I get an error, which is a value added and multiplied, what is the correct formula to get it?

Code: [Select]
`dewpoint = (237,7*(17.271*((temp-32)*5/9))/(237.7+*((temp-32)*5/9)+log(RH/100))/(17.271-(17.271*((temp-32)*5/9))/(237.7+*((temp-32)*5/9)+(log(RH/100)));// the numbers are constants, RH =relative humidity, temperature must be in C`

Thanks,

#### pylon

#1
##### Jun 20, 2012, 06:26 pm
This code is syntactically incorrect. I simplified it a little and added the necessary braces at the end, although I don't know if this calculates the correct value (I haven't studied the wikipedia article).

Code: [Select]
`  float tempC = 25.7;  float temp = (tempC -32) * 5 / 9;  float RH = 35.9;  float dewpoint = (237.7*(17.271*temp)/(237.7*temp+log(RH/100))/(17.271-(17.271*temp)/(237.7*temp+(log(RH/100)))));`

This at least compiles. I took out the recurring calculation of the temperature in Fahrenheit and made it before the dewpoint calculation.

#### Reinderien

#2
##### Jun 20, 2012, 09:11 pmLast Edit: Jun 20, 2012, 11:58 pm by Reinderien Reason: 1
You may also want to try:

Code: [Select]
` const float tempC = 25.7, temp = (tempC - 32) * 5/9, logRH = -1.024433, // ln(35.9/100) a = 17.271, b = 237.7, y = a*temp/(b + temp) + logRH, Td = b*y/(a - y);`

#### Jay_OR

#3
##### Jun 21, 2012, 04:42 pmLast Edit: Jun 21, 2012, 04:45 pm by Jay_OR Reason: 1

This code is syntactically incorrect. I simplified it a little and added the necessary braces at the end, although I don't know if this calculates the correct value (I haven't studied the wikipedia article).

Code: [Select]
`  float tempC = 25.7;  float temp = (tempC -32) * 5 / 9;  float RH = 35.9;  float dewpoint = (237.7*(17.271*temp)/(237.7*temp+log(RH/100))/(17.271-(17.271*temp)/(237.7*temp+(log(RH/100)))));`

This at least compiles. I took out the recurring calculation of the temperature in Fahrenheit and made it before the dewpoint calculation.

For this formula, the result I get is 0.00.
I used this formula, but I can not confirm if the values ??are correct.

Code: [Select]
`float aux = (log(RH / 100) + ((17.27 * temperatureC) / (237.3 + temperatureC))) / 17.27;  float dewpoint = (237.3 * aux) / (1 - aux);`

The values ??that I'm getting are:

Code: [Select]
`24.22 *C   75.59 *F   43.69 %RH   11.09 dew point *C   18.66 Humidex`

Can you confirm if I'm right?

You may also want to try:

Code: [Select]
` const float tempC = 25.7, temp = (tempC - 32) * 5/9, logRH = -1.024433, // ln(35.9/100) a = 17.271, b = 237.7, y = a*temp/(b + temp) + logRH, Td = b*y/(a - y);`

In this calculation, it seems to me you were to ignore the value of the logarithm of %RH.
But I'm not sure.

#### Reinderien

#4
##### Jun 21, 2012, 04:59 pm
Quote
In this calculation, it seems to me you were to ignore the value of the logarithm of %RH.

In your code, %RH was a constant, so log(RH/100) is also a constant. Since log is an expensive operation, it might as well be pre-computed.

#### robtillaart

#5
##### Jun 21, 2012, 09:21 pm

from - http://arduino.cc/playground/Main/DHT11Lib - the NOAA reference algorithm and the fast variation

Code: [Select]
`// dewPoint function NOAA// reference: http://wahiduddin.net/calc/density_algorithms.htmdouble dewPoint(double celsius, double humidity){        double A0= 373.15/(273.15 + celsius);        double SUM = -7.90298 * (A0-1);        SUM += 5.02808 * log10(A0);        SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;        SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;        SUM += log10(1013.246);        double VP = pow(10, SUM-3) * humidity;        double T = log(VP/0.61078);   // temp var        return (241.88 * T) / (17.558-T);}// delta max = 0.6544 wrt dewPoint()// 5x faster than dewPoint()// reference: http://en.wikipedia.org/wiki/Dew_pointdouble dewPointFast(double celsius, double humidity){        double a = 17.271;        double b = 237.7;        double temp = (a * celsius) / (b + celsius) + log(humidity/100);        double Td = (b * temp) / (a - temp);        return Td;}`
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### katie-darby

#6
##### Jun 28, 2012, 03:17 am
I took out the recurring calculation of the temperature in Fahrenheit and made it before the dewpoint calculation.

nice to meet you guys here to share the beautiful life with so many people.
Rc Helicopter|
Mini Rc Helicopter Reviews|
Rc Hobby Stores

Go Up

Please enter a valid email to subscribe