humidity and temperature sensor combine source code
Posted: Tue Aug 26, 2014 12:40 am
i had Temperature Sensor Module and Humidity Sensor Module both bought from cytron and connect to arduino main board. i tried combine this 2 sensor source code together. I expected will display temperature reading and humidity reading in RH% , but the output is quite weird. MAybe my source code, formula or somewhere got mistake. Someone please help me to correct it . i Need help !!!!. thanks a lot .
output
- CODE: SELECT_ALL_CODE
float val = 0;
float RH = 0;
float temp;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead(0);
delay(500);
Serial.println(val);
//RH = ((((val/1023)*5)-0.8)/3.1)*100;
Serial.println(RH);
RH = ((0,0004*20 + 0,149)*temp)-(0,0617*20 + 24,436);
delay(500);
temp = analogRead(3)/9.31;
Serial.print("TEMPRATURE = ");
Serial.print(temp);
Serial.print("*C");
Serial.println();
delay(1000);
}
output
- CODE: SELECT_ALL_CODE
TEMPRATURE = 30.50*C
24.00
4109.22
TEMPRATURE = 30.50*C
23.00
4109.22
TEMPRATURE = 30.61*C
24.00
4109.22
TEMPRATURE = 30.61*C
24.00
4125.22
TEMPRATURE = 30.61*C
24.00
4125.22
TEMPRATURE = 30.50*C
24.00
4125.22
TEMPRATURE = 30.50*C
24.00
4109.22
TEMPRATURE = 30.50*C