Skip to content

Raspberry Pi 5

Understanding real-time clocks (RTC) and Raspberry Pi 5

Raspberry Pi 5 is the first Raspberry Pi model with a built-in, battery-backed real-time clock (RTC). Learn what an RTC does, how to power it with a battery, and when it's useful for your projects.

IntermediateHardware · TimekeepingBy Vilros

What is a real-time clock (RTC)?

A real-time clock (RTC) is a specialized clock device that keeps track of the current time even when the main device is powered off. Unlike a regular system clock, an RTC operates on its own power source—typically a small battery—allowing it to maintain accurate time over extended periods.

RTCs are found in modern devices like smartphones, laptops, washing machines, and cars. They're crucial for applications that require precise timekeeping: data logging, scheduled tasks, and accurate timestamps.

Raspberry Pi 5 is the first Raspberry Pi model to include a built-in RTC. Previous models could only keep time while powered on or connected to the internet (via NTP time synchronization). With Pi 5's RTC, your system maintains the correct time even when unplugged.

Why RTC matters for Raspberry Pi 5

Without an RTC, Raspberry Pi models rely on internet connectivity to set the time when they boot. If your Pi isn't connected to the internet, it defaults to a fixed date/time (often January 1, 1970), which causes problems for:

  • Data logging: Timestamps are wrong, making it impossible to track when events occurred
  • Scheduled tasks: Cron jobs and timers don't run at the correct times
  • File timestamps: Files appear to be created decades in the past
  • SSL certificates: Secure connections may fail due to incorrect system time

With a battery-powered RTC, Raspberry Pi 5 maintains accurate time even when:

  • Powered off or unplugged
  • Disconnected from the internet
  • Running offline projects (weather stations, remote sensors, embedded systems)

Battery options

To power the RTC, you connect a battery to the Pi 5's dedicated RTC battery port (a two-pin JST connector on the board). You have two battery options:

Option 1: ML2020 rechargeable battery (official)

The official Raspberry Pi RTC battery is a Panasonic ML2020 lithium manganese dioxide rechargeable battery with a pre-fitted two-pin JST plug.

  • Pros: Rechargeable, officially supported, includes adhesive pad for mounting inside a case
  • Cons: Slightly more expensive than coin cells

The ML2020 is rechargeable, so it charges from the Pi's power when the Pi is running, then powers the RTC when the Pi is off.

Option 2: LIR2032 battery with connector

Alternatively, you can use a LIR2032 rechargeable coin cell battery with a compatible battery connector (sold separately or as an add-on).

  • Pros: Widely available, easy to replace
  • Cons: Requires purchasing a separate connector with JST plug

The connector includes a short cable (typically 11mm) with a two-pin JST plug that connects to the Pi 5's RTC port.

Installing the RTC battery

  1. Power off your Raspberry Pi 5 and disconnect the power supply
  2. Locate the RTC battery port on the Pi 5 board (a small two-pin JST connector near the GPIO header)
  3. Connect the battery:
    • For ML2020: Plug the pre-fitted JST connector into the RTC port
    • For LIR2032: Insert the coin cell into the battery holder, then plug the connector into the RTC port
  4. Mount the battery securely inside your case using the adhesive pad (ML2020) or holder clip (LIR2032)
  5. Power on your Pi 5 and set the correct time (it will now remember the time when powered off)

Once installed, the RTC charges automatically when the Pi is powered on and maintains time when the Pi is off.

When to use RTC

Consider adding an RTC battery if your Pi 5 project:

  • Runs offline: Weather stations, remote sensors, or embedded devices without internet
  • Logs data: Accurate timestamps are critical for understanding when events occurred
  • Runs scheduled tasks: Cron jobs, backups, or automated scripts that depend on time
  • Needs reliable time on boot: Systems that must have correct time immediately after powering on

If your Pi 5 is always connected to the internet and rarely powered off, the RTC battery is optional—your Pi will sync time via NTP on boot. But for offline, portable, or mission-critical projects, the RTC is invaluable.

Need an RTC battery?

Shop Raspberry Pi 5 RTC batteries at Vilros or explore Raspberry Pi 5 kits.