#include <dht.h>
#include <TinyWireM.h>
#include <Tiny4kOLED.h>
#define DHT22_PIN PB1
const unsigned char img_thermometer[] PROGMEM = {
0x00, 0xfe, 0x03, 0xfe, 0x50,
0x00, 0xff, 0x00, 0xff, 0x55,
0x60, 0x9f, 0x80, 0x9f, 0x65,
};
dht DHT;
void setup() {
pinMode(DHT22_PIN, INPUT);//recieve data from sensor
oled.begin(128, 64, sizeof(tiny4koled_init_128x64br), tiny4koled_init_128x64br);
// Two fonts are supplied with this library, FONT8X16 and FONT6X8
oled.setFont(FONT6X8);
// To clear all the memory
oled.clear();
oled.on();
oled.begin();
oled.setCursor(0, 0);
oled.print("Temperature|Humidity");
oled.bitmap(105, 4, 110, 7, img_thermometer);
}
void loop() {
DHT.read22(DHT22_PIN);//get data for DHT object
float temperature = DHT.temperature;//get T from DHT object
// Set cursor
oled.setCursor(57, 4);
// Print to display
oled.print(temperature);
oled.print("C ");
// Update humidity
float humidity = DHT.humidity;
// Set cursor
oled.setCursor(57, 5);
// Print to display
oled.print(humidity);
oled.print("% ");
delay(3000);
}