IntermediateDisplays and Timekeeping
OLED Real-Time Clock
Combine a DS3231 clock module and OLED to display the time while learning I²C and timekeeping backup.
Parts from the database
- DS3231SN × 1Real-time clock IC; use on a breakout
- SSD1306 × 1OLED display controller
- Raspberry-Pi-Pico × 1Microcontroller board
Other supplies
- DS3231 breakout with coin cell holderCommon build supply
- SSD1306 128×64 I²C OLED breakoutCommon build supply
- Raspberry Pi PicoCommon build supply
- USB cableCommon build supply
- jumper wiresCommon build supply
Amazon links may be affiliate links. As an Amazon Associate, Electronics Hobby Hub earns from qualifying purchases.
Connections
- On the Pico, connect both breakouts' SDA to GP4 and SCL to GP5; share GND.
- Power modules from 3V3 unless their documentation explicitly says otherwise.
- Check I²C addresses; if both default to 0x68, the DS3231 and OLED normally differ (0x3C for common SSD1306 modules).
Build steps
- Install RTClib and Adafruit SSD1306/ GFX libraries.
- Run an I²C scanner and confirm the clock and display addresses.
- Set the RTC once to the current time using the library's set-adjust example; remove that line after setting.
- Render date and time on the OLED and unplug USB briefly to confirm the coin cell keeps time.
Software and firmware setup
Firmware is required, but a complete combined clock/display sketch is not included yet. Install RTClib, Adafruit SSD1306, and Adafruit GFX; run each library's example separately, then combine the RTC time read with an OLED text update. Set the RTC once, then remove the set-time line before normal use.
Test your build
The clock should advance once per second and preserve time across a short USB power-off when its backup cell is installed.
Troubleshooting
- A blank OLED may have a different address or 128×32 geometry; check the module listing.
- If the time resets, check coin-cell orientation and whether the module has a good cell.
- Do not leave a set-to-compile-time line active after initial setup; it resets the clock on every boot.
Safety and limitations
Use a coin cell only in the intended holder and keep it away from children; do not charge a non-rechargeable coin cell.
Manufacturer and platform documentation
Community Notes for This Project
These are unverified visitor contributions, separate from the build guide and manufacturer specifications. Verify technical advice against the linked datasheets before relying on it.
Set up the comments service to load community notes.