//For evaluation WOKWI simulation software with 2 sensors DHT22 and HC-SR04
//and LCD I2C
//2/21/23
/* How to use the DHT-22 sensor with Arduino uno
Temperature and humidity sensor
More info: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
Dev: Michalis Vasilakis // Date: 1/7/2015 // www.ardumotive.com */
//Libraries
#include <DHT.h>;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address
//Constants
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
Serial.begin(9600);
dht.begin();
lcd.begin(16,2); // initialize the lcd
}
void loop()
{
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
lcd.setCursor(0, 0);
lcd.print("RH:");
lcd.print((int)hum);
lcd.print("% T:");
lcd.print(temp, 1);
lcd.print(" oC");
delay(500);
}