Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
We are hosting Hackster Cafe: Open Hardware Summit. Watch the stream live on Friday!We are hosting Hackster Cafe: Open Hardware Summit. Stream on Friday!
Electro BOY
Published © GPL3+

RTC based clock using Arduino and OLED

A small compact and easy to understand project for beginners. Get all the files including libraries and code from here.

BeginnerFull instructions provided1 hour1,489
RTC based clock using Arduino and OLED

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Real Time Clock (RTC)
Real Time Clock (RTC)
×1

Software apps and online services

EasyEDA
JLCPCB EasyEDA
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Breadboard, 400 Pin
Breadboard, 400 Pin
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Custom parts and enclosures

RTClib

RTC PCB GERBER

Schematics

Circuit

Open using Cirkit designer

Code

Code

Arduino
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_SSD1306.h>


#define OLED_RESET 4


Adafruit_SSD1306 display(OLED_RESET);


RTC_DS1307 RTC;

void setup () {
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(1500);
  display.clearDisplay();
  Wire.begin();
  RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
}

void loop () {
    DateTime now = RTC.now();
  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC); 
    Serial.println();
    delay(1000);


                            
  display.setTextSize(2);                            
  display.setTextColor(WHITE,BLACK);
  display.setCursor(20,4);                           
  display.print(now.hour(), DEC);
  display.print(':');
  display.print(now.minute(), DEC);
  display.print(':');
  display.print(now.second(), DEC);
  
  display.setTextSize(1);                            
  display.setTextColor(WHITE,BLACK);
  display.setCursor(35,22);
  display.print(now.year(), DEC);
  display.print('/');
  display.print(now.month(), DEC);
  display.print('/');
  display.print(now.day(), DEC);
  display.display();
  display.clearDisplay();
 
}

Credits

Electro BOY
57 projects • 59 followers
Electronics is my passion. I am not professional, Always learning something new. I am good at soldering, designing pcb, Arduino programing.
Contact

Comments

Please log in or sign up to comment.