10/30/2020
Arduino ile dijital saat yapımı. 3D yazıcı ve Arduino Saat.

3D Yazıcı ve Arduino ile Ayarlı Saat & Sıcaklık & Nem

3D yazıcı ile ahşap görünümlü saat kutusu. Sıcaklık ve Nem gösterebilen Arduino Pro Mini ile ayarlı dijital saat yapımı.
Projede 2 adet Arduino Pro Mini kullandım. Ayarlı saat kodu bir tanesine ve diğerine nem ve sıcaklık ölçerin kodunu yükledim. Bunun sebebi projemde iki adet oled ekran kullanmam.
Ekranların I2C adresleri aynı olduğundan tek bir kartta çalıştırmak direk olarak mümkün olmuyor.  Adres değişikliği yapılabilen Oled ekranlar mevcut ama benim ekranlarımda bu özellik yoktu.
Tek kart ile kullanabilmek için I2C çoklayıcı (multiplexer modül) kullanılabilir. Ama bu kart Arduino Pro Mini den daha ucuz ve daha küçük değil. Bu yüzden iki Arduino kullanmak çok daha mantıklı ve kolay bir çözüm oldu benim için.

3D yazıcı için saat kutusu basım dosyaları:
Gövde (Body) dosyası govde-body.stl
Arka kapak (Back) dosyası arka-kapak-back.stl

Ayarlı Saat Kodu:

// DS3231 RTC modülü ve 1.3 inc Oled Ekranlı Saat

#include <Wire.h>                                    // Include Wire library (required for I2C devices) .. (I2C cihazlar için gerekli kütüphane)
#include <Adafruit_GFX.h>                            // Include Adafruit graphics library .. (Adafruit grafik kütüphanesi)
#include <Adafruit_SH1106.h>                         // Adafruit oled screen library for SH1106 .. (SH1106 çipli Oled ekran kütüphanesi)
 
#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);
 
#define button1    7                                 // Button 1 is connected to Arduino pin 7 .. (Buton 1 Arduino 7 nolu pininde)
#define button2    8                                 // Button 2 is connected to Arduino pin 8 .. (Buton 1 Arduino 8 nolu pininde)

// Kendiyap Kanal Logo (KendinYap Channel Logo)
const unsigned char KendinYap_Logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x00, 0x00,
0x00, 0x18, 0xE0, 0x03, 0x83, 0x80, 0x00, 0x00, 0x07, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0xE0, 0x01,
0xC3, 0x00, 0x00, 0x00, 0x07, 0x1C, 0x00, 0x00, 0x00, 0x18, 0xE0, 0x01, 0xC3, 0x00, 0x00, 0x00,
0x07, 0x38, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x01, 0xE7, 0x00, 0x00, 0x00, 0x07, 0x30, 0x1C, 0x09,
0x81, 0xB8, 0x82, 0x60, 0xE6, 0x1C, 0x09, 0x80, 0x0E, 0x70, 0x7E, 0x1F, 0xC3, 0xF8, 0xE6, 0xF8,
0xFE, 0x3F, 0x1F, 0xE0, 0x07, 0x70, 0x7F, 0x1F, 0xE7, 0xBC, 0xE7, 0xF8, 0x7C, 0x7F, 0x8F, 0xE0,
0x07, 0xF0, 0xE3, 0x9C, 0xE7, 0x38, 0xE7, 0x38, 0x7C, 0x63, 0x9C, 0x70, 0x07, 0xF0, 0xE3, 0x98,
0xC7, 0x1C, 0xE7, 0x38, 0x38, 0x03, 0x9C, 0x70, 0x0F, 0xF8, 0xDF, 0x9C, 0xE7, 0x18, 0xE7, 0x18,
0x38, 0x1F, 0x9C, 0x70, 0x07, 0xB8, 0xFF, 0x9C, 0xE7, 0x1C, 0xC7, 0x38, 0x38, 0x7F, 0x8C, 0x70,
0x07, 0x3C, 0xC0, 0x98, 0xE7, 0x18, 0xE6, 0x18, 0x38, 0x73, 0x9C, 0x70, 0x07, 0x1C, 0xE2, 0x1C,
0xE7, 0x3C, 0xE7, 0x38, 0x38, 0xE3, 0x9C, 0x70, 0x07, 0x1C, 0xE3, 0x98, 0xE7, 0x18, 0xE7, 0x38,
0x38, 0xE3, 0x8C, 0x70, 0x07, 0x1E, 0x7F, 0x1C, 0xE7, 0xFC, 0xC7, 0x38, 0x38, 0xFF, 0x9E, 0xE0,
0x07, 0x0E, 0x7F, 0x38, 0xE3, 0xD8, 0xE7, 0x38, 0x38, 0x7B, 0x9F, 0xE0, 0x04, 0x06, 0x1C, 0x08,
0x01, 0x90, 0x40, 0x08, 0x30, 0x29, 0x1D, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x38,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0xFE, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xC0, 0x00, 0x00, 0x01, 0xEF, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00,
0x00, 0x03, 0xC7, 0x38, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0x87, 0x1F,
0xC3, 0xF1, 0xDE, 0x37, 0x83, 0xE1, 0xC0, 0x00, 0x00, 0x03, 0x87, 0x3F, 0xC7, 0xF8, 0xFE, 0x3F,
0xC3, 0xF1, 0xC0, 0x00, 0x00, 0x03, 0x80, 0x1D, 0xE7, 0x39, 0xFE, 0x3F, 0xC7, 0xB9, 0xC0, 0x00,
0x00, 0x03, 0x80, 0x3C, 0xC6, 0x38, 0xC7, 0x39, 0xCE, 0x39, 0xC0, 0x00, 0x00, 0x03, 0x80, 0x18,
0xE0, 0x39, 0xCE, 0x38, 0xCE, 0x29, 0x80, 0x00, 0x00, 0x07, 0x80, 0x38, 0xC3, 0xF8, 0xC7, 0x31,
0xCF, 0xF9, 0xC0, 0x00, 0x00, 0x03, 0x87, 0x3C, 0xE7, 0xB9, 0xC6, 0x39, 0xCF, 0xF9, 0xC0, 0x00,
0x00, 0x03, 0x87, 0x19, 0xC7, 0x38, 0xE7, 0x39, 0xCE, 0x01, 0xC0, 0x00, 0x00, 0x01, 0xC7, 0x38,
0xEE, 0x39, 0xC6, 0x30, 0xCE, 0x19, 0xC0, 0x00, 0x00, 0x01, 0xFF, 0x1C, 0xCF, 0x78, 0xC7, 0x39,
0xC7, 0x31, 0x80, 0x00, 0x00, 0x00, 0xFE, 0x38, 0xE7, 0xF9, 0xE6, 0x39, 0xC7, 0xF1, 0xC0, 0x00,
0x00, 0x00, 0x7C, 0x18, 0xC7, 0x39, 0xC7, 0x38, 0xC3, 0xF1, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

const unsigned char KendinYap_Logo2 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7F, 0xFF, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x0F, 0xC0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x0F, 0x00, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x1F, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7F, 0xFF, 0x1F, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x1F, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x0F, 0x9F, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x1F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3F, 0xFE, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFC, 0x3F, 0xFC,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x3F, 0x40, 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0xF1, 0xFF, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xF9, 0xFF, 0xA1, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFD, 0x71,
0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x3F, 0xE1, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x3F, 0xF7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, 0xF1, 0xF6, 0x3C,
0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDD, 0xEE, 0xFE, 0x78, 0x1E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xDD, 0xEF, 0xFB, 0xF8, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xBE, 0x1F, 0xFF, 0xF0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFF, 0xFF, 0x77, 0xF0,
0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x00, 0x78, 0x1F, 0xE0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x00, 0x78, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0xF8, 0x1F, 0xFC, 0x3C, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x0F, 0xFC, 0x7F,
0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x0F, 0xF9, 0xFF, 0xFE, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xE0, 0x07, 0xF1, 0xFF, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xE0, 0x07, 0xE1, 0xC7, 0xCE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x07, 0xC0, 0x07,
0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x07, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3F, 0xF0, 0x0F, 0xC0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F,
0xF8, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xF0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xF0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Logo sonu (END)
 
void setup(void) {
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  delay(500);
 
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);          // initialize with the I2C addr 0x3C (for the 128x64) .. (Oled Ekranın I2C için başlatma adresi)

  // KendinYap Logo Yazdırma (Logo print to display)
  display.clearDisplay();
  display.drawBitmap(15, 5, KendinYap_Logo, 96, 48, 1); 
  display.display();
  delay(2000);
  display.clearDisplay();
  display.drawBitmap(17, 10, KendinYap_Logo2, 96, 48, 1); 
  display.display();
  delay(2000);
  // Logo yazdırma sonu (Logo print end)
  
  // Saat için dikdörtgen çerçevenin çizdirilmesi (rectangle frame)
  display.clearDisplay(); 
  display.display();
  display.setTextColor(WHITE, BLACK);
  display.drawLine(0, 39, 127, 39, WHITE);
  display.drawLine(0, 63, 127, 63, WHITE);
  display.drawLine(0, 39, 40, 1890, WHITE);
  display.drawLine(127, 39, 40, 4100, WHITE);
  // End
}
 
char time[]     = "  :  :  ";
char calendar[] = "  /  /20  ";

byte i, second, minute, hour, day, date, month, year, temperature_lsb;
 
void display_day(){
  switch(day){
    case 1:  write_text(40, 2, "  PAZAR  ", 1); break;         // SUNDAY
    case 2:  write_text(40, 2, "PAZARTESI", 1); break;         // MONDAY
    case 3:  write_text(40, 2, "   SALI  ", 1); break;         // TUESDAY
    case 4:  write_text(40, 2, " CARSAMBA", 1); break;         // WEDNESDAY
    case 5:  write_text(40, 2, " PERSEMBE", 1); break;         // THURSDAY
    case 6:  write_text(40, 2, "   CUMA  ", 1); break;         // FRIDAY
    default: write_text(40, 2, "CUMARTESI", 1);                // SATURDAY 
  }
}
 
void RTC_display(){
  // Convert BCD to decimal
  second = (second >> 4) * 10 + (second & 0x0F);
  minute = (minute >> 4) * 10 + (minute & 0x0F);
  hour   = (hour >> 4)   * 10 + (hour & 0x0F);
  date   = (date >> 4)   * 10 + (date & 0x0F);
  month  = (month >> 4)  * 10 + (month & 0x0F);
  year   = (year >> 4)   * 10 + (year & 0x0F);
  // End conversion
 
  time[7]     = second % 10 + 48;
  time[6]     = second / 10 + 48;
  time[4]     = minute % 10 + 48;
  time[3]     = minute / 10 + 48;
  time[1]     = hour   % 10 + 48;
  time[0]     = hour   / 10 + 48;
  calendar[9] = year   % 10 + 48;
  calendar[8] = year   / 10 + 48;
  calendar[4] = month  % 10 + 48;
  calendar[3] = month  / 10 + 48;
  calendar[1] = date   % 10 + 48;
  calendar[0] = date   / 10 + 48;

  write_text(4,  18, calendar, 2);                   // Tarihin görüntülenmesi ... Display the date (format: dd/mm/yyyy)
  write_text(16, 45, time, 2);                       // Saatin görüntülenmesi ... Display the time 

}
 
void blink_parameter(){
  byte j = 0;
  while(j < 10 && digitalRead(button1) && digitalRead(button2)){
    j++;
    delay(25);
  }
}
 
byte edit(byte x_pos, byte y_pos, byte parameter){
  char text[3];
  sprintf(text,"%02u", parameter);
  while(!digitalRead(button1));                     
  while(true){
    while(!digitalRead(button2)){                     
      parameter++;
      if(i == 0 && parameter > 31)                    
        parameter = 1;
      if(i == 1 && parameter > 12)                    
        parameter = 1;
      if(i == 2 && parameter > 99)                   
        parameter = 0;
      if(i == 3 && parameter > 23)                    
        parameter = 0;
      if(i == 4 && parameter > 59)                    
        parameter = 0;
      sprintf(text,"%02u", parameter);
      write_text(x_pos, y_pos, text, 2);
      delay(200);                                     
    }
    write_text(x_pos, y_pos, "  ", 2);
    blink_parameter();
    write_text(x_pos, y_pos, text, 2);
    blink_parameter();
    if(!digitalRead(button1)){                    
      i++;                                            
      return parameter;                              
    }
  }
}
 
void write_text(byte x_pos, byte y_pos, char *text, byte text_size) {
  display.setCursor(x_pos, y_pos);
  display.setTextSize(text_size);
  display.print(text);
  display.display();
}
 
void loop() {
 
  if(!digitalRead(button1)){                         
    i = 0;
    while(!digitalRead(button1));                    
    while(true){
      while(!digitalRead(button2)){                 
        day++;                                     
        if(day > 7) day = 1;
        display_day();                              
        delay(200);                               
      }
      write_text(40, 2, "         ", 1);
      blink_parameter();                             
      display_day();                                
      blink_parameter();                             
      if(!digitalRead(button1))                      
        break;
    }
 
    date   = edit(4, 18, date);                   
    month  = edit(40, 18, month);                   
    year   = edit(100, 18, year);                    
    hour   = edit(16, 45, hour);                   
    minute = edit(52, 45, minute);                
 
    // Convert decimal .. (Ondalık dönüştürme)
    minute = ((minute / 10) << 4) + (minute % 10);
    hour = ((hour / 10) << 4) + (hour % 10);
    date = ((date / 10) << 4) + (date % 10);
    month = ((month / 10) << 4) + (month % 10);
    year = ((year / 10) << 4) + (year % 10);
    // 
 
    // Write data to RTC .. (Bilgilerin DS3231 RTC modulüne yazdırılması)
    Wire.beginTransmission(0x68);               
    Wire.write(0);                             
    Wire.write(0);                              
    Wire.write(minute);                         
    Wire.write(hour);                          
    Wire.write(day);                           
    Wire.write(date);                           
    Wire.write(month);                         
    Wire.write(year);                           
    Wire.endTransmission();                     
    delay(200);                                
  }
 
  Wire.beginTransmission(0x68);                
  Wire.write(0);                              
  Wire.endTransmission(false);                
  Wire.requestFrom(0x68, 7);                   
  second = Wire.read();                        
  minute = Wire.read();                        
  hour   = Wire.read();                        
  day    = Wire.read();                         
  date   = Wire.read();                        
  month  = Wire.read();                         
  year   = Wire.read();                         
  Wire.beginTransmission(0x68);                 
  Wire.write(0x11);                             
  Wire.endTransmission(false);                 
  Wire.requestFrom(0x68, 2);                    

  display_day();                                // Display day .. (Gün bilgisinin gösterilmesi)
  RTC_display();                                // Display date & time (Tarih ve saatin görüntülenmesi) 
  delay(50);                                    
}

 

DHT22 ile Sıcaklık ve Nem Ölçümü ve 0.91 inc Ekranın KODU: (İkinci Arduino Pro Mini ye yüklenecek):

BİLİGİ: Bu kod yüklenmeden önce SSD1306 kütüphanesinde ekran çözünürlüğü Oled ekrana uygun seçeneğe getirilmeli. Yani .091 inc Oled 128×32 çözünürlüktedir. Kütüphane kodu bir text editör ile açılarak 128×64 pasif yapılmalı. 128×32 aktif yapılmalı. Aksi takdirde görüntü sorunları yaşanabilir.

// DHT22 Sıcaklık ve Nem değerlerinin 0.91 inc Oled Ekran ile kullanılması
// KendinYap Youtube Channel

#include <DHT.h>                               // include DHT Sensor library (DHT sıcaklık ve nem sensörü kütüphanesi)
#define DHTPIN 7
DHT dht(DHTPIN, DHT22);
 
#include <Wire.h>                              // Include Wire library (required for I2C devices) .. (I2C cihazlar için gerekli bağlantı kütüphanesi)
#include <Adafruit_GFX.h>                     // Include Adafruit graphics library .. (Adafruit grafik kütüphanesi)
#include <Adafruit_SSD1306.h>                 // Iclude SSD1306 Oled library .. (SSD1306 çipli Oled ekran kütüphanesi)
 
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

void setup() { 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // I2C address 0x3C for the 128x32 oled (Oled ekranın adresinin belirtilmesi)
  display.display();
  display.clearDisplay();                    
  display.setTextColor(WHITE); 
dht.begin();
}

void loop() {

  float t = dht.readTemperature();          // DHT22 Temperature .. (Sıcaklık)
  float h = dht.readHumidity();             // DHT22 Hummidy .. (Nem) 

  display.drawRect(92, 1, 4, 6, WHITE);     // Put degree symbol ( ° ) .. (Derece sembolünün eklenmesi)
  display.setCursor(100,0);
  display.setTextSize(2);
  display.print("C");
  display.setCursor(100,19);
  display.setTextSize(2);
  display.print("%");
 
  display.setCursor(19,0);
  display.setTextSize(2);
  display.print(t);
  display.setCursor(19,19);
  display.setTextSize(2);
  display.print(h);
  display.display();
  display.clearDisplay();

  delay(500);
}

Gerekli Arduino kütüphaneleri:

Adafruit SSD1306.h
Adafruit_GFX.h
Adafruit SH1106.h
DHT22.h
Wire.h