Skip to content
ANANDHAKRISHNAN AJITH edited this page Jun 26, 2024 · 3 revisions

Welcome to the RTC-CLOCK- wiki!

OLED Clock with DS1307 RTC

This project uses an SSD1306 OLED display and a DS1307 Real-Time Clock (RTC) module to display the current date and time. The date and time can be updated via serial input.

Components Required

  1. MICROCONTROLLER board (e.g., Arduino Uno , Esp8266, esp32)
  2. DS1307 RTC module
  3. SSD1306 OLED display
  4. Breadboard and connecting wires

Libraries Used

  • Wire.h
  • RTClib.h
  • Adafruit_GFX.h
  • Adafruit_SSD1306.h

Circuit Diagram

Refer to the Connection Guide below for detailed connections.

Setup and Installation

  1. Install Libraries:

    • Open the Arduino IDE.
    • Go to Sketch -> Include Library -> Manage Libraries.
    • Search for and install the following libraries:
      • RTClib
      • Adafruit GFX Library
      • Adafruit SSD1306
  2. Upload Code:

    • Connect your Arduino board to your computer.
    • Open the provided Arduino sketch.
    • Select the appropriate board and port from the Tools menu.
    • Click on the upload button.
  3. Setting the Time:

    • Open the Serial Monitor (set baud rate to 115200).
    • Enter the time in the format YYYY MM DD HH MM SS to set the RTC.

How It Works

  • The RTC module keeps track of the current date and time.
  • The OLED display shows the current day, date, month, year, and time.
  • The time is displayed in 12-hour format with AM/PM indication.

Functions

  • setup(): Initializes the display and RTC module.
  • loop(): Continuously updates the display with the current date and time.
  • displayTimeDate(): Calculates and displays the current date and time on the OLED.
  • setTimeFromSerial(): Reads and sets the time from the serial input.

Example Output

makefile
Copy code
MON 28 Jun 2023 11:59:59 AM

Troubleshooting

  • If the display doesn't turn on, check the connections and the I2C address.
  • Ensure the RTC module is properly connected and the battery is installed.

Connection Guide

Connecting the Components

1. SSD1306 OLED Display

OLED Pin AND RTC Pin -- | -- VCC | 5V GND | GND SCL | A5 [arduino] gpio105[esp8277] gpio22[esp32] SDA | A4 [arduino] gpio104[esp8277] gpio21[esp32]

Circuit Diagram

Connect the components as shown below:

circuit

Final Setup

After connecting all components, upload the provided code to the Arduino. Open the Serial Monitor to set the initial time, and the current time and date should display on the OLED screen.