Skip to main content

Real Time Clock

There are several Real Time Clock (RTC) modules available for the Raspberry Pi, which can be used to keep track of the current time even when the Pi is powered off. These modules typically use I2C communication and can be easily integrated into your projects.

Be sure when connecting a RTC module to use the pinout guide on your compute blade along with the pinout from the RTC modules data sheet to ensure correct wiring.

Available RTC Modules

The Adafruit PiRTC is a reliable and well-documented RTC module.

Features:

  • Built-in battery backup
  • Easy I2C interface
  • Compatible with all Raspberry Pi models
  • Excellent documentation and support

Installation

Hardware Setup

  1. Power down your Compute Blade before connecting any modules
  2. Connect the RTC module to your Compute Blade using I2C pins:
    • VCC → 3.3V or 5V (check your module's requirements)
    • GND → Ground
    • SDA → GPIO2 (Pin 3)
    • SCL → GPIO3 (Pin 5)
  3. Insert the backup battery (usually CR2032) into the RTC module

Software Configuration

# Enable I2C interface
sudo raspi-config
# Navigate to: Interfacing Options > I2C > Enable

# Reboot to apply changes
sudo reboot

# Install I2C tools
sudo apt update
sudo apt install i2c-tools

# Detect the RTC module
sudo i2cdetect -y 1

Testing Your RTC

# Check if RTC is detected
sudo hwclock -D -r

# Set system time to RTC
sudo hwclock -w

# Read time from RTC
sudo hwclock -r

Benefits

  • Persistent timekeeping: Maintains accurate time when the system is powered off
  • Low power consumption: Uses minimal power from backup battery
  • Easy integration: Standard I2C interface works with existing projects
  • Essential for logging: Critical for applications requiring accurate timestamps
  • Network independence: No need for NTP when network is unavailable

Troubleshooting

Common Issues

  • Module not detected: Check wiring connections and I2C enable status
  • Time drift: Ensure backup battery is properly installed and charged
  • Boot issues: Verify correct device tree overlay for your RTC chip