humidity and temperature sensor combine source code

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

humidity and temperature sensor combine source code

Postby alung92 » 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 .
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
alung92
Novice
 
Posts: 17
Joined: Thu Aug 21, 2014 12:57 pm

Re: humidity and temperature sensor combine source code

Postby yonghui » Tue Aug 26, 2014 2:42 pm

I am quite confused with your code.

i see you use value that is not properly initialize to the reading of adc.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: humidity and temperature sensor combine source code

Postby alung92 » Tue Aug 26, 2014 3:02 pm

I'm quite new in this field ,i'm trying and some code copy from other web page . Can u give me a example and guide line how to write code with this two sensor combine together. Thanks a lot .
alung92
Novice
 
Posts: 17
Joined: Thu Aug 21, 2014 12:57 pm

Re: humidity and temperature sensor combine source code

Postby yonghui » Tue Aug 26, 2014 9:35 pm

i assume that Humidity sensor is connected AN0 and Temperature sensor is connected to AN3

word Temperature;
word Humidity;

void loop()
{
Humidity = analogRead(0);
Temperature =analogRead(3);
// do some calculation here to convert the humidity value to valid value then print it

// print Humidity
// print temperature

delay(500);

}
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm


Return to Sensor

Who is online

Users browsing this forum: No registered users and 6 guests

cron