What you'll build: a desk clock that keeps accurate time with a coin-cell backup, displays HH:MM:SS + date on a crisp OLED, and stays accurate to better than 1 minute per year. No internet, no setup app, no apps to update.
Parts list
- Arduino Nano
- 0.96" SSD1306 OLED display (I²C version, white or yellow-blue)
- DS3231 RTC module with CR2032 coin cell
- 4 × Dupont jumpers
Why DS3231 over DS1307: the DS3231 has a temperature-compensated crystal oscillator (TCXO) built in. The DS1307 drifts by minutes per month; the DS3231 by seconds per year.
Wiring (everything is I²C, so just parallel them up)
- OLED + DS3231 VCC → Nano 5V (both modules have 3.3V regulators)
- OLED + DS3231 GND → Nano GND
- OLED + DS3231 SDA → Nano A4
- OLED + DS3231 SCL → Nano A5
Libraries (install from Library Manager)
- U8g2 by oliver — incredibly fast OLED library
- RTClib by Adafruit — clean DS3231 API
Sketch outline
1. In setup(), call rtc.begin(). On first upload, also call rtc.adjust(DateTime(F(__DATE__), F(__TIME__))) so the clock takes the compile time as initial time. Comment this line out and re-upload — otherwise every upload re-sets the clock.
2. In loop(), every 1 second: read rtc.now(), format HH:MM:SS, draw to OLED with a 24×24 font for hours/minutes and a smaller font for seconds + date.
Polishing touches
- Bottom row shows the day of week + date in dim text.
- A photoresistor on A0 can drive OLED brightness — bright in daytime, dim at night.
- Add a piezo + a button to make it an alarm clock.
Battery life on the CR2032: about 8 years for time-keeping alone. The Nano + OLED draws ~20mA, so a USB-C power source is the way to go for the display.