Formula for Outputting Wet Bulb temp from Temp and RH

Ok, I have a dht11 which gives me Temperture and Relative Humidity.

What i'm trying to do is have an arduino display current WET BULB temp on a display. I can get it to display Temp and RH, but thats as far as I've gotten.

I found an old post with some math, but I need help turning that into something that I can put into my code.

here is the math I found online;
On a range Tdry bulb=15..40[deg C] and rh=10...90[%]you can calculate the Twet bulb[degC] at P=1006[mbar](=755 Torr)with max relative error~6% with an approximative polynomial model that you can put in a cells. For lower Tdry and rh the relative error will be higher.
Twet bulb= ATdry + Brh + CTdry^2 + Drh^2+ ETdryrh + F
where
A=5,391260E-01
B=1,047837E-01
C=-7,493556E-04
D=-1,077432E-03
E=6,414631E-03
F=-5,151526E+00

Anyone able to break this down for me and help me out?
Thanks in advance...

Anyone able to break this down for me and help me out?

What do you need help with? * is multiplication, and is done with the same symbol in C++. ^2 means squared, which is equivalent to x * x.

float Twet= A*Tdry + B*rh + C*Tdry*Tdry + D*rh*rh+ E*Tdry*rh + F ;

MarkT:

float Twet= A*Tdry + B*rh + C*Tdry*Tdry + D*rh*rh+ E*Tdry*rh + F ;

Excellent, now I just to learn how to put the values of a-f into some sort of variable so this function can read them.

Cheers, and thanks for all your helps far. I am a newbie when it comes to C and more so when it comes to arduino.

M

Ok, I think I have it now.

Maybe someone could check my code and see if I did it right?

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 
int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

// read the buttons
int read_LCD_buttons()
{
 adc_key_in = analogRead(0);      // read the value from the sensor 
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 // For V1.1 us this threshold
 if (adc_key_in < 50)   return btnRIGHT;  
 if (adc_key_in < 250)  return btnUP; 
 if (adc_key_in < 450)  return btnDOWN; 
 if (adc_key_in < 650)  return btnLEFT; 
 if (adc_key_in < 850)  return btnSELECT;  

 return btnNONE;  // when all others fail, return this...
}

#define DHT11_PIN 0      // ADC0  Define the ANALOG Pin connected to DHT11 Sensor
int temp1[3];                //Temp1, temp2, hum1 & hum2 are the final integer values that you are going to use in your program. 
int temp2[3];                // They update every 2 seconds.
int hum1[3];
int hum2[3];

byte read_dht11_dat()
{
  byte i = 0;
  byte result=0;
  for(i=0; i< 8; i++){


    while(!(PINC & _BV(DHT11_PIN)));  // wait for 50us
    delayMicroseconds(30);

    if(PINC & _BV(DHT11_PIN)) 
      result |=(1<<(7-i));
    while((PINC & _BV(DHT11_PIN)));  // wait '1' finish


  }
  return result;
}


long dht11delay_previousMillis = 0;        // will store last time LED was updated
long dht11delay_interval = 1000;           // dht11delay_interval at which to blink (milliseconds)

void setup()
{
  DDRC |= _BV(DHT11_PIN);
  PORTC |= _BV(DHT11_PIN);

  Serial.begin(9600);
  delay(100);
}

void loop()
{




  unsigned long dht11delay_currentMillis = millis();

  if(dht11delay_currentMillis - dht11delay_previousMillis > dht11delay_interval) {
    // save the last time you blinked the LED 
    dht11delay_previousMillis = dht11delay_currentMillis;   
    byte dht11_dat[5];
    byte dht11_in;
    byte i;
    // start condition
    // 1. pull-down i/o pin from 18ms
    PORTC &= ~_BV(DHT11_PIN);
    delay(18);
    PORTC |= _BV(DHT11_PIN);
    delayMicroseconds(40);

    DDRC &= ~_BV(DHT11_PIN);
    delayMicroseconds(40);

    dht11_in = PINC & _BV(DHT11_PIN);

    if(dht11_in){
      Serial.println("dht11 start condition 1 not met");
      return;
    }
    delayMicroseconds(80);

    dht11_in = PINC & _BV(DHT11_PIN);

    if(!dht11_in){
      Serial.println("dht11 start condition 2 not met");
      return;
    }
    delayMicroseconds(80);
    // now ready for data reception
    for (i=0; i<5; i++)
      dht11_dat[i] = read_dht11_dat();

    DDRC |= _BV(DHT11_PIN);
    PORTC |= _BV(DHT11_PIN);

    byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
    // check check_sum
    if(dht11_dat[4]!= dht11_check_sum)
    {
      Serial.println("DHT11 checksum error");
    }



    temp1[0]=dht11_dat[2];
    temp2[0]=dht11_dat[3];
    lcd.begin(16,2);
    lcd.setCursor(0,0);
    lcd.print("Tmp:");
    lcd.print(temp1[0]);
    lcd.print("c ");
    lcd.print("WB:");
    lcd.print(5.391260E-01*temp1[0] + 1.047837E-01*hum1[0] + -7.493556E-04*hum1[0]*hum1[0] + -1.077432E-03*hum1[0]*hum1[0] + 6.414631E-03*temp1[0]*hum1[0] + 5.151526E+00);
    hum1[0]=dht11_dat[0];
    hum2[0]=dht11_dat[1];
    lcd.setCursor(0,1);
    lcd.print("Hum:");
    lcd.print(hum1[0]);
    lcd.print("%");
    
  }
}
// END OF CODE

michaeli:

MarkT:

float Twet= A*Tdry + B*rh + C*Tdry*Tdry + D*rh*rh+ E*Tdry*rh + F ;

Excellent, now I just to learn how to put the values of a-f into some sort of variable so this function can read them.

variables not needed, indeed they are constant(!)

#define A 0.539126
#define B 0.1047837
...