//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include"DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.print("WIFI Connecting");
lcd.setCursor(0,1);
lcd.print("Please wait....");
Serial.println("Connecting Wifi....");
lcd.setCursor(0,0);
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
lcd.setCursor(0,0);
lcd.print("Humidity: ");
lcd.print(h); // Виведення Вологості на LCD
lcd.print(" % ");
lcd.setCursor(0,1);
lcd.print("Temperature:");
lcd.print(t); // Виведення температури на LCD
lcd.write(1);
lcd.print("C");
lcd.setCursor(0,2);
lcd.print(f);
lcd.print(" F");
delay(1000);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Next : "));
}