#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <DHT22.h>
//define pin dataint
int pinDATA = 2; // SDA, or almost any other I/O pin
DHT22 dht22(pinDATA);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(115200); //1bit=10µs
Serial.println("\ntest capteur DTH22");
lcd.init();
// turn on the backlight
lcd.backlight();
}
void loop() {
Serial.println(dht22.debug()); //optionnal
float t = dht22.getTemperature();
float h = dht22.getHumidity();
if (dht22.getLastError() != dht22.OK) {
Serial.print("last error :");
Serial.println(dht22.getLastError());
}
Serial.print("h=");Serial.print(h,1);Serial.print("\t");
Serial.print("t=");Serial.println(t,1);
delay(2000); //Collecting period should be : >1.7 second
lcd.setCursor(0,0);
// tell the screen to write “hello, from” on the top row
lcd.print("tem: ");
lcd.setCursor(1,0);
// tell the screen to write “hello, from” on the top row
lcd.print(t);
// tell the screen to write on the bottom row
}
// |———————————————————————————————————————————————————————|
// | made by Arduino_uno_guy 11/13/2019 |
// | https://create.arduino.cc/projecthub/arduino_uno_guy|
// |———————————————————————————————————————————————————————|