const byte nsum=10;
int humidityPin=2;
int Thgm20Pin=3;
unsigned int sensorValue2 = 0;
unsigned int sensorValue3 = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
for (byte i=0;i<nsum;i++)
{
sensorValue2 += analogRead(humidityPin);
sensorValue3 += analogRead(Thgm20Pin);
}
int sensorValue2Avg=sensorValue2/nsum;
float RH= 0.1515*sensorValue2Avg-12.0;
int sensorValue3Avg=sensorValue3/nsum;
float Vt=(float) sensorValue3Avg*5.0/1023.0;
float R=(5.0-Vt)*10.0/Vt; //lakukan kalibrasi untuk nilai yang sesuai
float TinC=281.583*pow(1.0230,(1.0/R))*pow(R,-0.1227)-150.6614; //lakukan kalibrasi untuk nilai yang sesuai
Serial.print("Kelembaban: ");
Serial.print(RH,0);
Serial.println(" % ");
Serial.print("Suhu : ");
Serial.print(TinC,1);
Serial.println(" C ");
sensorValue2=0;
sensorValue3=0;
delay(1000);
}
Tidak ada komentar:
Posting Komentar