Skip to main content

RTC Module interfacing with Raspberry Pi 4

A real-time clock (RTC) is a piece of electronic equipment that measures the passage of actual time and is constructed in the shape of an IC. Even if the external power source is cut, embedded systems with real-time clocks continue to provide precise time readings. It keeps track of minutes, seconds, days, months, and even years. These modules are present in almost every piece of electronic equipment, especially those that need precise timekeeping.

The key benefit of RTC is that it has a battery backup system that keeps the clock and calendar working even during a power outage. The RTC needs a minimal amount of current to stay animated. These RTCs are used in many systems, including computer motherboards, embedded systems, and so on. This article will examine one real-time clock (RTC), specifically the DS1307.

What Are Real-Time Clocks?

Real-Time Clock Module

A real-time clock (RTC) is a computer clock primarily constructed as an integrated circuit and used for timekeeping. Of course, it keeps track of the seconds, minutes, hours, days, months, and years. Any electronic equipment that needs to retain the correct time will have a real-time clock (RTC) built into it. It includes desktop computers, embedded devices, and servers. The ability to continue operating while the computer is shut down by a battery or without the assistance of the main power supply is essential.

You need RTCs to maintain accurate time even when the gadget isn't active as they're usually utilized as triggers for turning them on or starting events like alarm clocks. A different source power's the RTC ICs, allowing for continuous operation at low power or when the PC gets turned off. When it comes to powering its ICs, older systems rely on lithium batteries, while newer ones use backup batteries or supercapacitors. The rechargeable and solderable RTC ICs utilize supercapacitors. Although, RTC is usually powered by one battery in consumer motherboards, which upon removal makes RTC restart.

RTC ICs control time using a crystal oscillator rather than clock signals. They keep the system's clock accurate and guarantee that all of its functions run in lockstep with one another. Despite various claims to the contrary, the system clock is not wholly accountable for synchronization because it depends on the RTC.

Pin Description of DS1307

Pin Description of DS1307

Pin 1, 2: The connections for quartz crystals tuned to 32.768 kHz. The 12.5pF crystal load capacitance is required for use with the integrated oscillator circuits. The oscillator's input, X1, can also be wired to an external device producing a frequency of 32.768 kHz. If an external oscillator is attached to X1 while the internal oscillator, X2, is off, the output of X2 drifts.

Pin 3: An alternative power supply or typical 3V lithium cell's battery input. For optimal performance, the voltage for the battery should range from 2 to 3.5V. Access to the Real Time Clock and user RAM is disabled at a voltage of 1.25 times VBAT nominal, as determined by the internal circuitry. If there is no power at 25oC, a lithium battery with 48mAhr or more will keep the DS1307 running for over ten years. When used alongside a lithium battery, the device is UL-recognized to protect against reverse charging current.

Pin 4: The Ground pin.

Pin 5: The pin for serial data input/output. The Inter-Integrated Circuit serial interface uses the SDA input/output pair. It's an open drain and needs a pull-up resistor with a maximum pull-up voltage of 5.5V. No matter what the VCC voltage is.

Pin 6: The serial clock input. An I2C interface clock input and typically utilized in data synchronization.

Pin 7: The square wave/output driver. Setting the SQWE bit to 1 causes the SQW/OUT pin to emit one of four possible square-wave frequencies. The square-wave frequencies are 1Hz, 4 kHz, 8 kHz, and 32 kHz. It is an open drain and needs an extra pull-up resistor. Either Vb or Vcc can power SQW/OUT at a maximum draw-up voltage of 5.5V. It could be kept floating while not in use.Pin 8: The primary power supply pin. Data can be read from and written to the device without restriction when voltage is delivered within the standard range. Reads and writes are disabled once the backup supply and VCC power of the device is lower than VTP. Nevertheless, the timekeeping feature still works at low voltages.

Features of the RTC Module

RTC Module

  • A programmable square wave output signal
  • Circuitry for automatic power-fail detection and switching
  • It uses no more than 500nA when the oscillator operates in battery backup mode.
  • UL-approved and offered in both 8-pin DIP and Small Outline Integrated Circuit (SOIC) packages.
  • A real-time clock (RTC) counts hours, seconds, minutes, days of the week, months, and years with leap-year adjustments that are good through 2100.
  • Data storage using 56 bytes of non-volatile RAM
  • Two-wire interface (I2C)

Conclusion

This article explains the workings of a real time clock with Raspberry Pi 4 and some of its most significant applications. You may easily use this module in most of your projects that call for timed actions, including robot movements. If you experiment with the RTC more, you'll also learn how it functions.

LindaWelsh has not written a bio yet…
DesignSpark Electrical Logolinkedin