Created
March 26, 2015 20:30
-
-
Save annappropriate/48f6891159e89adc06a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dht.h> | |
#include <LiquidCrystal_I2C.h> | |
#include <Wire.h> | |
LiquidCrystal_I2C lcd(0x27, 16, 2); | |
DHT dht11 = DHT(); | |
int HIH4030_Pin = A5; | |
void setup() { | |
lcd.init(); | |
lcd.backlight(); | |
dht11.attach(A0); | |
Serial.begin(9600); | |
Serial.println("Temp,DHT11_RH,HIH4030_Volt,HIH4030_RH_calc"); | |
} | |
void loop() { | |
dht11.update(); | |
lcd.clear(); | |
int t = dht11.getTemperatureInt(); | |
int h = dht11.getHumidityInt(); | |
lcd.print("T: "); | |
lcd.print(t); | |
lcd.print(" "); | |
Serial.print(t); | |
Serial.print(","); | |
lcd.print("DHT11: "); | |
lcd.print(h); | |
Serial.print(h); | |
Serial.print(","); | |
lcd.setCursor(0, 1); | |
int hihv = analogRead(HIH4030_Pin); | |
// lcd.print("HIH4030 Volt: "); | |
// lcd.println(hihv); | |
Serial.print(hihv); | |
Serial.print(","); | |
int hih4030_rh = getHih4030Humidity(t); | |
lcd.print("HIH4030: "); | |
lcd.print(hih4030_rh); | |
Serial.println(hih4030_rh); | |
delay(1000); | |
} | |
float getHih4030Humidity(float degreesCelsius){ | |
//caculate relative humidity | |
float supplyVolt = 5.0; | |
// read the value from the sensor: | |
int HIH4030_Value = analogRead(HIH4030_Pin); | |
float voltage = HIH4030_Value/1023.; // convert to voltage value | |
float sensorRH = 161.3 * voltage - 25.8; | |
float trueRH = sensorRH / (1.0546 - 0.00216 * degreesCelsius); //temperature adjustment | |
return trueRH; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revised