<Arduino: 1.6.1 (Windows 7), Board: "Arduino Uno"
DHT.ino:1:17: fatal error: DHT.h: No such file or directory
compilation terminated.
Error compiling.>
(I came across the above error while compiling all the three files.)
(By project.h, I meant dht.h.)
DHT.h
#ifndef DHT_h //prevents problems if someone accidently #include's your library twice
#define DHT_h
#include "Arduino.h" // access to the standard types and constants of the Arduino language
#define Tc
class DHT{
public: //can be accessed by anyone using your library
DHT(int pin); //all the variables and functions needed are defined here
float celsius();
float fahrenheit(celsius); //on the right is a constructor
long saturated_vapor_density();
float actual_vapor_density();
float relative_humidity();
double dewPoint;
private: // can be accessed within the class itself
int _pin;
};
#endif
DHT.cpp
#include "Arduino.h
#include "DHT.h"
{
pinMode(pin, INPUT);
_pin = pin;
}
float celsius
{
cel = (analogRead(_pin500)/1023);
}
float fahrenheit(float celsius)
{
fah = 1.8cel + 32;
return fah;
}
long saturated_vapor_density()
{
s_v_d = 6.335 + 0.6718Tc - 2.0887
10-2(Tc2) + 7.3095(104)(Tc3); //it is Tc to power of 1,2,and 3
//and 10 to power of -2 and 4
}
float actual_vapor_density = 1.156;
float relative_humidity(){
r_h = (actual_vapor_density/s_v_d);
}
double dewPoint(){
d_p = Tc - ((100 - r_h));
}
/Tc is taken to be 25 degree - as this is the ideal temperature. Any value can be taken.
For 25 degree, the value obtained for actual vapor density is 1.156 g/m3.
Humidity is the actual vapor density by the saturated vapor density and is found to be 5% as in the datasheet./
KEYWORDS.txt
DHT KEYWORD1
celsius KEYWORD2
fahrenheit KEYWORD2
saturated_vapor_density KEYWORD2
relative_humidity KEYWORD2
dewPoint KEYWORD2
DHT.ino
#include "DHT.h"
#define DHTPIN 4 //the pin sensor is connected to
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
}
void loop {
delay(2000); //wait for few seconds before measurements
float fah = dht.fahrenheit();
long s_v_d = dht.saturated_vapor_density();
float r_h = dht.relative_humidity();
double d_p = dht.dewPoint();
Serial.print("Temp in Fahrenheit: ");
Serial.print(fah);
Serial.print("F%t");
Serial.print("Saturated_Vapor_Density: ");
Serial.print(s_v_d);
Serial.println(" gm/m3 ");
Serial.print("Relative Humidity: ");
Serial.print(r_h);
Serial.print(" %\t ");
Serial.print("Dew Point: ");
Serial.print(d_p);
Serial.println(' ');
}
Datasheet
http://www.micropik.com/PDF/dht11.pdf