DS1307 and DS3231: It's Time to Move On

by Bardia Alikhan Afshar in Circuits > Clocks

103 Views, 1 Favorites, 0 Comments

DS1307 and DS3231: It's Time to Move On

NanoRTC.jpg

The DS1307 and DS3231 are the two most popular real-time clock ICs in the hobbyist and maker world. They show up in every Arduino kit, every Raspberry Pi accessory store, every beginner tutorial. And for a lot of use cases, they're fine. But if you're building anything serious — a low-power sensor node, a precision data logger, a robotics system that needs accurate timestamps — there is a better alternative worth knowing about. It costs about the same. And it's been hiding in plain sight.


The DS1307: A 5V Relic

Hard to justify in any new design. It runs at 4.5–5.5V only — every modern MCU is 3.3V, so you're forced to add a level shifter just for the RTC. It has no temperature compensation, so your clock drifts with ambient temperature — easily several minutes per month in a real environment. No alarms, meaning your MCU can never deep sleep on a schedule. And it's locked to 100 kHz I²C.

The DS1307 was designed when 5V was standard and "low power" meant under 10 mA. That era is over.


The DS3231: Better, But Not Good Enough

The DS3231 earns its reputation. Integrated TCXO gives you ±2 ppm accuracy from 0°C to 40°C — roughly one minute of drift per year — without an external crystal. It's 3.3V compatible, supports 400 kHz I²C, has two alarms and a built-in temperature sensor.

Two real problems though.

Backup current. It draws ~840 nA in timekeeping mode on the backup cell. The RV-3028-C7 draws 45 nA — nearly 19× lower. Your coin cell will self-discharge long before the RTC drains it.

No Unix timestamp register. The DS3231 stores time in BCD across seven separate bytes. Every read means BCD decoding; every log entry means either storing seven bytes or converting in software. The RV-3028-C7 has a dedicated 4-byte Unix counter that auto-increments every second. You read 4 bytes, you have a 32-bit integer. Done.

Minimum voltage. The DS3231 works down to 2.3V on VCC. The RV-3028-C7 works down to 1.1V — relevant if you're powering directly from a supercapacitor at the end of its hold-up window, or from a heavily discharged energy harvesting source.


The RV-3028-C7: What a Modern RTC Looks Like

The Micro Crystal RV-3028-C7 is not a well-known chip in the hobbyist community. No off-the-shelf breakout boards, fewer bare-metal drivers, almost no beginner tutorials. That's the only reason people don't use it.

Here's what it actually offers:

  1. ±1 ppm accuracy at 25°C, up to ±3 ppm across the full −40°C to +85°C range. Unlike the DS3231, this is not a TCXO — it uses a factory-calibrated fixed offset. For typical indoor use the two chips perform comparably on accuracy; the RV-3028 wins on everything else.
  2. 45 nA backup current — nearly 19× lower than the DS3231. Low enough to run from a small supercapacitor instead of a coin cell. The built-in trickle charger handles charging it directly.
  3. 1.1V to 5.5V supply range. Works with anything.
  4. Unix timestamp register. Four bytes, auto-incrementing. Read it in one burst transaction, get a 32-bit integer. No BCD decoding, no multi-byte assembly.
  5. Event timestamping on the EVI pin. Connect a button, a power rail, a door sensor — the chip records the exact timestamp in hardware with an event counter. No MCU involvement, no missed events.
  6. Programmable CLKOUT from 32768 Hz down to 1 Hz, or driven by the countdown timer.
  7. Hardware backup switchover. Direct mode for coin cells, Level mode (switches below 2.0V) for supercapacitors. No external comparators needed.

And it costs about the same as a DS3231.

Supplies

Hardware:


  1. RV-3028-C7 module or Breakout board — Gerbers and BOM in the Hardware/ folder of the repo (if you want to build your own)
  2. CR1220 coin cell for backup power
  3. 2.2kΩ resistors × 2 for I²C pull-ups (if not using the breakout board)
  4. 100nF decoupling capacitor (if not using the breakout board)
  5. Any MCU with I²C running at 1.2V to 5.5V


Firmware:


  1. Bare-metal RTC driver — in the Firmware/ folder of the repo. Written for STM32 but designed to be easily ported to any MCU.
  2. Covers timekeeping, alarms, countdown timer, Unix timestamp, and EVI event timestamping. Annotated source makes porting to other platforms straightforward.


Click here to go to the full repo on GitHub.

Hardware

RV-3028-C7.jpg

Hardware

The RV-3028-C7 comes in a tiny 1.5mm × 3.2mm SMD package, which puts off a lot of people who are used to the DS1307's through-hole DIP or the DS3231's 16-pin SO. If you don't want to hand-solder it, I designed a breakout board that carries the RTC, decoupling capacitors, I²C pull-up resistors, and a CR1220 backup battery holder. Gerbers, BOM, and schematic are all in the Hardware/ folder of the repo.

If you're rolling your own PCB, here's what you need:

Minimum circuit:

  1. VDD to 3.3V (or anywhere from 1.2V to 5.5V)
  2. GND to ground
  3. SDA and SCL to your MCU's I²C pins, each with a 2.2kΩ pull-up to VDD
  4. VBACKUP to a CR1220 coin cell
  5. 100nF decoupling capacitor between VDD and GND, placed close to the chip

Pinout:

Pin 1 — VDD — connect to 3.3V

Pin 2 — GND — connect to ground

Pin 3 — SDA — connect to MCU SDA with a pull-up to VDD

Pin 4 — SCL — connect to MCU SCL with a pull-up to VDD

Pin 5 — VBACKUP — connect to coin cell or supercapacitor

Pin 6 — INT — connect to MCU GPIO for alarms and timer interrupts (optional)

Pin 7 — EVI — connect to external event signal for hardware timestamping (optional)

Pin 8 — CLKOUT — leave floating if unused


The I²C address is fixed at 0x52 (7-bit). No address pins, no jumpers, no configuration needed.

The INT pin is open-drain — if you're using alarms or the countdown timer to wake your MCU, connect it to a GPIO configured as input with internal pull-up and wire an EXTI interrupt to it. If you're not using interrupts at all, leave it floating.

Firmware

The driver is a single source/header pair — rv3028.c and rv3028.h — with a thin I²C abstraction layer underneath. Copy the files from the Firmware/Src/ folder into your project and include the header. The abstraction layer is what makes the driver portable — it isolates all platform-specific I²C calls in one place so the rest of the driver never touches hardware directly.

The driver targets STM32 HAL out of the box. If you're on a different STM32 series, change one include line to match your family. If you're on a different platform entirely, replace only the I²C implementation file with your own. Five functions need to be provided: I²C init, read, write, a millisecond tick counter, and a delay. Everything above that layer is platform-independent register logic and will compile without modification.

The driver covers the full feature set of the chip :

  1. Date and time
  2. UNIX timestamp
  3. Alarm
  4. Countdown timer
  5. Periodic update interrupt
  6. Event timestamping on the EVI pin
  7. CLKOUT configuration
  8. Backup switchover
  9. Trickle charger
  10. Crystal frequency offset calibration


A complete working example is included in the Firmware/Example_NanoRTC/ folder. It runs on a NUCLEO-G431KB, reads the RTC every second, and prints date, time, and UNIX timestamp over UART. It is a good starting point for getting familiar with the driver before integrating it into your own project.


Click here to go to the full repo on GitHub.

Downloads