/* https://wokwi.com/projects/406690699742710785
https://journals.ametsoc.org/view/journals/bams/86/2/bams-86-2-225.xml
Td = t - ((100 - RH)/5.)
where Td is dew point temperature (in degrees Celsius),
t is observed temperature (in degrees Celsius),
and RH is relative humidity (in percent).
Apparently this relationship is fairly accurate for relative humidity values above 50%.
*/
#include <DHT22.h>
#include <LCD-I2C.h>
//define pin data
#define pinDATA A0 // SDA, or almost any other I/O pin
DHT22 dht22(pinDATA);
LCD_I2C lcd(0x27, 16, 2); // Default address of most PCF8574 modules, change according
float t;
float RH;
float Td;
void setup() {
Serial.begin(9600); //1bit=10µs
Serial.println("\Simulation DTH22");
lcd.begin();
lcd.display();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Simulation DTH22");
delay(3000);
}
void loop() {
// Serial.println(dht22.debug()); //optionnal
t = dht22.getTemperature() ;
RH = dht22.getHumidity() ;
Td = t - ((100 - RH)/5) ;
if (dht22.getLastError() != dht22.OK) {
Serial.print("last error :");
Serial.println(dht22.getLastError()); }
Serial.print("RH="); Serial.print(RH,1); Serial.print("\t");
Serial.print("t="); Serial.print(t,1); Serial.print("\t");
Serial.print("DP=");Serial.println(Td,1);
lcd.clear();
lcd.setCursor(0, 0); lcd.print("RH="); lcd.print(RH,1);
lcd.setCursor(8, 0); lcd.print("t="); lcd.print(t,1);
lcd.setCursor(0, 1); lcd.print("DP="); lcd.print(Td,1);
delay(2000); //Collecting period should be : >1.7 second
}