#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#define DHTPIN 6
#define DHTTYPE DHT22
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
dht.begin();
oled.begin(SSD1306_EXTERNALVCC,0x3C);
delay(2000);
oled.clearDisplay();
oled.setTextSize(1);
oled.setTextColor(WHITE);
oled.setCursor(10,20);
oled.println("TEMP and HUMIDITY");
oled.setCursor(10,30);
oled.println("MONITORING DEVICE");
oled.display();
delay(2000);
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
oled.clearDisplay();
oled.setTextSize(1.8);
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.print("Temperature = ");
oled.println(temperature);
oled.print("Humidity = ");
oled.println(humidity);
oled.display();
delay(2000);
}