This is the code used with my Arduino watch development board fot the real time clock example. You will also need the OLED screen libraries and the DS3231 libraries so download those from below and install them before compiling the code. Download the code or copy it from below and uplaod it to the PCB.
#include <DS3231.h>
#include <DS3232RTC.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
DS3231 rtc(SDA, SCL);
#define OLED_RESET 9
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
rtc.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
delay(100);
display.clearDisplay();
display.display();
}
void loop() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.print(rtc.getDOWStr());
display.setCursor(0,17);
display.print(rtc.getTimeStr());
display.setCursor(0,34);
display.print(rtc.getDateStr());
display.setCursor(0,52);
display.print("Temp: ");
display.print(rtc.getTemp());
display.print(" deg");
display.display();
delay(500);
}