//

PROJECT CLOCK // I2C OVERVIEW

Minimalist and high-contrast documentation focusing on hardware wiring and core logic.

Component List & Sourcing

I2C Wiring Matrix

I2C uses only two data lines (SDA/SCL) plus power. Multiple I2C devices (like the OLED and RTC) **share** these four pins by connecting them in parallel.

**GND** (Grey) β†’ **GND** (OLED, RTC)
**5V** (Red) β†’ **VCC** (OLED, RTC)
**A5** (Blue) β†’ **SCL** (OLED, RTC)
**A4** (Green) β†’ **SDA** (OLED, RTC)

Core Code Snippet (RTC Clock)

This code reads the time from the RTC module and displays it on the OLED. Libraries needed: **Wire, RTClib, Adafruit\_GFX, Adafruit\_SSD1306**.

#include <Wire.h>
#include <RTClib.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

RTC_DS3231 rtc;
Adafruit_SSD1306 display(128, 64, &Wire);

void setup() {
  Wire.begin();
  
  // Check if RTC is available and running
  if (! rtc.begin()) {
    // Optionally display an error message here
  }

  // Zeit einmalig setzen (danach auskommentieren!)
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
}

void loop() {
  DateTime now = rtc.now();

  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 20);

  // HH:MM:SS
  if (now.hour() < 10) display.print("0");
  display.print(now.hour());
  display.print(":");

  if (now.minute() < 10) display.print("0");
  display.print(now.minute());
  display.print(":");

  if (now.second() < 10) display.print("0");
  display.print(now.second());

  display.display();
  delay(500);
}
        

Wiring Diagram (OLED & RTC) πŸ—ΊοΈ

Vector diagram showing the parallel I2C connection from the Arduino Nano to the OLED Display and the RTC DS3231 Module. Wires are color-coded: **Grey (GND)**, **Red (5V)**, **Blue (SCL)**, **Green (SDA)**.

Arduino nano OLED display RTC DS3231 Module GND 5V A5/SCL A4/SDA GND VCC SCL SDA GND VCC SCL SDA