// DHT22 and LCD by Nitigan
/* You must include element for dht22
*/
#include <DHT.h>
#include <DHT_U.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
// Define 16x2 LCD
int screenWidth = 16;
int screenHeight = 2;
// To move ONLY one line needs to move one character at a time
// Define two line
String line1 = " Temp & Humid "; // stationary " LCD ep3: "
String line2 = " Data is "; // scroll this line " This is a one line scrolling tutorial! "
int stringStart, stringEnd = 0;
int scrollCursor = screenWidth;
void setup() {
dht.begin();
// use dht begin
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
lcd.init();
lcd.backlight();
lcd.begin(screenWidth, screenHeight);
}
void loop() {
float temperature= dht.readTemperature();
float humidity = dht.readHumidity();
lcd.setCursor(0, 0); // Seting the cursor on first row
lcd.print("Temp: "); // To print line1 message
Serial.print("Temp: ");
Serial.println(temperature, 1);
lcd.print(temperature, 1);
lcd.print("C ");
lcd.setCursor(0, 1); // Seting the cursor on first row
lcd.print("Humidity: "); // To print line1 message
Serial.print("Humidity: ");
Serial.println(humidity, 1);
lcd.print(humidity, 1);
lcd.print("%");
delay(1000);
lcd.clear(); // clear message
/*
get data from dht22
*/
/*
show data from dht with LCD
*/
}