//written by K A M T Kodikara
//[email protected]
//linkedin.com/in/maleeshakodikara/
#include "DHT.h"
#include <LiquidCrystal.h>
#define DHTPIN 22 // The pin number to which the DHT sensor is connected
#define DHTTYPE DHT22 // The type of DHT sensor being used (DHT22)
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD1602: RS, EN, D4, D5, D6, D7
void setup() {
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
lcd.print("Reading sensor");
dht.begin();
}
void loop() {
float temperature, humidity;
humidity = dht.readHumidity();
temperature = dht.readTemperature();
delay(2000); // Delay between readings
lcd.clear();
lcd.setCursor(0, 0); // Set cursor to the first column (0) of the first row (0)
lcd.print("T:");
lcd.print(temperature);
lcd.print((char)223); // Print the degree symbol
lcd.print("C ");
lcd.setCursor(0, 1); // Set cursor to the first column (0) of the second row (1)
lcd.print("H:");
lcd.print(humidity);
lcd.print("%");
}