12/24/2024
Arduino ile dijital saat yapımı. 3D yazıcı ve Arduino Saat.

Adjustable Digital Table Clock. Temperature and Humidity Meter with 3D Printer and Arduino.

Making a wooden effect table clock box using 3D printer.
Adjustable digital clock structure with Arduino Pro Mini, which can show temperature and humidity.
I used 2 Arduino Pro Mini in the project. I installed the code of the humidity and temperature meter on one. I installed the code of the clock on the other arduino. Because I want to use two oled screens in my project.
Since the displays have the same I2C addresses, it was not possible to work directly on a single card. There are Oled screens that can be replaced, but my screens did not have this feature.
It is possible to use 2 screens with a single card with the I2C multiplexer module. However, this module is not cheaper and not smaller than the Arduino Pro Mini. Using two Arduino was a much more logical and easy solution for me.

3D files:
Body govde-body.stl
Back door arka-kapak-back.stl

Two schema for Different 5V regulator version….

Adjustable clock code:

// DS3231 RTC modülü ve 1.3 inc Oled Screen Table Watch

#include <Wire.h>                                    // Include Wire library (required for I2C devices) 
#include <Adafruit_GFX.h>                            // Include Adafruit graphics library 
#include <Adafruit_SH1106.h>                         // Adafruit oled screen library for SH1106 
 
#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);
 
#define button1    7                                 // Button 1 is connected to Arduino pin 7 
#define button2    8                                 // Button 2 is connected to Arduino pin 8 

// 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, 0x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1C, 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)

  // 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 print end
  
  // Srectangle 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, "  SUNDAY  ", 1); break;
    case 2:  write_text(40, 2, "  MONDAY", 1); break;
    case 3:  write_text(40, 2, " TUESDAY  ", 1); break;
    case 4:  write_text(40, 2, "WEDNESDAY", 1); break;
    case 5:  write_text(40, 2, " THURSDAY", 1); break;
    case 6:  write_text(40, 2, "  FRIDAY  ", 1); break;
    default: write_text(40, 2, " SATURDAY", 1);
  }
}
 
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);                   // Display the date (format: dd/mm/yyyy)
  write_text(16, 45, time, 2);                       // 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
    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
    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
  RTC_display();                                // Display date & time
  delay(50);                                    
}

 

HT22 & 0.91 inc Display CODE: (to be installed on the second Arduino Pro Mini):

NOTE: Before installing this code, the screen resolution in the SSD1306 library must be set for the appropriate option. The .091 inc Oled is 128×32 resolution. The library code should be opened with a text editor and should be made 128×64 passive. 128×32 should be made active. Otherwise, display problems may occur.

// DHT22 & 0.91 inc Oled Screen
// KendinYap Youtube Channel

#include <DHT.h>                               // include DHT Sensor library 
#define DHTPIN 7
DHT dht(DHTPIN, DHT22);
 
#include <Wire.h>                              // Include Wire library (required for I2C devices)
#include <Adafruit_GFX.h>                     // Include Adafruit graphics library 
#include <Adafruit_SSD1306.h>                 // Iclude SSD1306 Oled library 
 
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

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

void loop() {

  float t = dht.readTemperature();          // DHT22 Temperature
  float h = dht.readHumidity();             // DHT22 Hummidy

  display.drawRect(92, 1, 4, 6, WHITE);     // Put degree symbol ( ° )
  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);
}

Required Arduino libraries:

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