Electronics

Real Time Clock RTC Module DS1307

AED 19.95

1

Description

The Real Time Clock (RTC) Module DS1307 is a compact and reliable device designed to keep accurate track of time. With its advanced functionality, it serves as an essential component for various applications requiring precise timekeeping. The DS1307 module integrates a highly accurate crystal oscillator and a battery backup, ensuring uninterrupted timekeeping even during power outages. Its I2C interface enables seamless communication with microcontrollers and other devices, making it ideal for embedded systems. Equipped with a 56-byte non-volatile RAM, it offers storage capacity for critical time-related data. The DS1307 RTC Module is a dependable timekeeping solution that simplifies scheduling, data logging, and synchronization in a wide range of electronic projects.

 

Package Includes:

  • 1 x DS1307 module ( battery not included )

 

Features:

  • Accurate Timekeeping: The module utilizes a built-in crystal oscillator that provides precise timekeeping with low deviation.
  • Battery Backup: It includes a battery backup system that allows the module to retain accurate time even during power outages or when disconnected from the main power source.
  • I2C Interface: The DS1307 module communicates through the widely-used I2C (Inter-Integrated Circuit) protocol, enabling seamless integration with microcontrollers and other devices.
  • Non-Volatile RAM: It features a 56-byte non-volatile RAM, which can be used to store important time-related data or other user-defined information that needs to be retained during power cycles.
  • Programmable Square-Wave Output: The module can generate a programmable square-wave output signal with frequencies ranging from 1Hz to 32.768kHz, making it suitable for various timing applications.
  • Low Power Consumption: The DS1307 module operates at low power, ensuring efficient energy usage in battery-powered applications.
  • Alarm Functionality: It supports two programmable alarm settings, which can be used to trigger an interrupt signal or perform specific actions based on predefined time criteria.
  • 24-hour Format: The module supports the 24-hour time format, allowing for easy integration with systems that require standard time representation.
  • Easy Integration: With its compact size and standardized communication protocol, the DS1307 module can be easily integrated into a wide range of electronic projects and applications.

 

Description:

The DS1307 Real Time Clock (RTC) Module is a highly reliable and compact device specifically designed to ensure precise timekeeping in electronic systems. With its integrated crystal oscillator, it offers exceptional accuracy in maintaining the current time. Even in the event of a power outage, the module's battery backup system guarantees uninterrupted operation and prevents any loss of time data. The DS1307 module seamlessly communicates with other devices through the widely supported I2C interface. This allows for effortless integration with various microcontrollers and facilitates efficient data transfer for time synchronization purposes. Equipped with a 56-byte non-volatile RAM, the module provides ample storage capacity for storing critical time-related information. This feature proves invaluable in applications that require the retention of important data even during power cycles or system resets. Moreover, the DS1307 RTC Module offers additional functionalities that enhance its versatility. It includes a programmable square-wave output, enabling the generation of accurate timing signals for various applications. The module also supports the configuration of two alarms, allowing for the triggering of specific actions or events at predetermined times. The DS1307 module boasts low power consumption, making it suitable for energy-efficient designs, particularly in battery-powered systems where power conservation is crucial. With its compact size and user-friendly design, the DS1307 RTC Module can be effortlessly integrated into a wide range of electronic projects and applications. Whether it's for scheduling, data logging, or synchronization purposes, this reliable timekeeping solution simplifies and enhances the functionality of diverse electronic systems.

 

Principle of Work:

 

By combining the following internal components and functionalities, the DS1307 RTC Module provides accurate timekeeping capabilities, seamless communication with other devices, and flexible configuration options. Its battery backup ensures uninterrupted operation, and the non-volatile RAM allows for the retention of important time-related data:

  1. Crystal Oscillator: The module incorporates a crystal oscillator, typically a 32.768 kHz quartz crystal, to generate a precise clock signal. This signal serves as the fundamental timing reference for the module's operations.
  2. Counters and Registers: The DS1307 module contains internal counters and registers that keep track of time and date information. These counters maintain values for seconds, minutes, hours, days, months, and years.
  3. I2C Interface: The module communicates with other devices through the I2C (Inter-Integrated Circuit) protocol. It acts as a slave device, allowing microcontrollers or other master devices to read from and write to its internal registers.
  4. Battery Backup: To ensure continuous timekeeping, the DS1307 module includes a battery backup system. This backup power source, typically a small coin cell battery, maintains the module's internal counters and registers when the main power supply is disconnected or during power outages.
  5. Non-Volatile RAM: The module features a 56-byte non-volatile RAM (NVSRAM) that can be used for storing time-related data or other user-defined information. This NVSRAM retains its contents even when the module loses power.
  6. Control and Configuration Registers: The DS1307 module includes control and configuration registers that enable setting and adjusting various parameters, such as alarm settings, square-wave output frequency, and 12/24-hour time format.
  7. Square-Wave Generator: The module can generate a programmable square-wave output signal. The frequency of this square wave can be set to one of four different options, ranging from 1Hz to 32.768kHz, allowing for timing applications.
  8. Alarm Functionality: The DS1307 module supports two programmable alarms. These alarms can be set to trigger an interrupt or perform specific actions when the designated time criteria are met.

 

Pinout of the Board:

 

    • DS (Data select): This pin is used to output temperature readings if your module has a DS18B20 temperature sensor installed.
    • SCL (Serial Clock Pin): Serial clock pin for the I2C interface, used to synchronize data movement on the serial interface.
    • SDA (Serial Data Pin): Serial data pin for the I2C interface, used for bidirectional communication.
    • VCC (Chip Supply Voltage): Chip supply voltage pin.
    • GND (Ground): Ground pin for the module.
    • BAT (Backup supply input): Input for an external standard 3V lithium cell for backup power.
    • DS (Data select): This pin is used to output temperature readings if your module has a DS18B20 temperature sensor installed.
    • SQ (Square-Wave Output): Outputs one of four square-wave frequencies: 1Hz, 4kHz, 8kHz, or 32kHz.


Applications:

  1. Embedded Systems: The module is widely used in embedded systems where precise time tracking is required, such as industrial automation, robotics, and IoT devices.
  2. Data Logging: The DS1307 module is used for time-stamping data in data logging applications. It ensures accurate recording of events, measurements, or sensor readings.
  3. Real-Time Clocks: The module serves as a standalone real-time clock in devices that require a reliable timekeeping function, such as alarm clocks, timers, and digital watches.
  4. Security Systems: The DS1307 RTC Module is utilized in security systems for time-based event scheduling, access control, and synchronization of multiple security devices.
  5. Automotive Applications: The module can be integrated into automotive systems for tasks like time-stamping data, event logging, and synchronization of multimedia systems.
  6. Energy Management: It is employed in energy management systems for monitoring power consumption, energy usage scheduling, and tracking time-based energy-saving measures.
  7. Medical Devices: The DS1307 module is used in medical devices that require precise time synchronization, such as patient monitoring systems, drug dispensers, and healthcare equipment.
  8. Communication Systems: The module is utilized in communication systems for accurate time synchronization between network devices, ensuring efficient data transmission and synchronization.
  9. Home Automation: It is integrated into home automation systems to schedule and control various devices based on time, such as lighting, HVAC systems, and appliances.
  10. Educational Projects: The module is popular in educational projects to teach timekeeping concepts, data logging, and programming in microcontroller-based systems.

 

Circuit:

  1. Connect the VCC pin of the DS1307 module to the 5V pin of the Arduino Uno.
  2. Connect the GND pin of the DS1307 module to any GND pin on the Arduino Uno.
  3. Connect the SDA pin of the DS1307 module to the A4 (SDA) pin on the Arduino Uno.
  4. Connect the SCL pin of the DS1307 module to the A5 (SCL) pin on the Arduino Uno.

 

Library: 

  1. Open the Arduino IDE (Integrated Development Environment).
  2. Go to "Sketch" in the menu bar and select "Include Library" → "Manage Libraries...". The Library Manager window will open.
  3. In the Library Manager, you will find a search bar. Type "RTClib" in the search bar.
  4. Look for the "RTClib" entry in the search results. It should be the library developed by Adafruit. Click on it.
  5. On the right side of the library entry, you will see an "Install" button. Click on it to begin the installation process.
  6. Wait for the installation to complete. You will see a progress bar indicating the installation status.
  7. Once the installation is finished, you will see the "Installed" status next to the library entry.
  8. Close the Library Manager.

 

Code:

This example code initializes the DS1307 module, retrieves the current time, and prints it to the serial monitor:

#include "Wire.h"
#include "RTClib.h"

RTC_DS1307 rtc;

void setup() {
  Wire.begin();
  rtc.begin();

  // Uncomment the line below to set the initial time on the module:
  // rtc.adjust(DateTime(__DATE__, __TIME__));

  // Add any additional setup code here
}

void loop() {
  DateTime now = rtc.now();

  // Access the individual time components
  int year = now.year();
  int month = now.month();
  int day = now.day();
  int hour = now.hour();
  int minute = now.minute();
  int second = now.second();

  // Print the time to the serial monitor
  Serial.print(year);
  Serial.print("-");
  Serial.print(month);
  Serial.print("-");
  Serial.print(day);
  Serial.print(" ");
  Serial.print(hour);
  Serial.print(":");
  Serial.print(minute);
  Serial.print(":");
  Serial.println(second);

  // Add any additional code to be executed in the loop here

  delay(1000); // Delay for 1 second
}

  1. The first two lines include the necessary libraries: "Wire.h" for I2C communication and "RTClib.h" for interfacing with the RTC module.
  2. The line RTC_DS1307 rtc; declares an object named "rtc" of the RTC_DS1307 class from the RTClib library.
  3. In the setup() function, Wire.begin() initializes the I2C communication, and rtc.begin() initializes the RTC module.
  4. The commented line rtc.adjust(DateTime(__DATE__, __TIME__)); is used to set the initial time on the RTC module. If uncommented, it sets the time to the compilation date and time.
  5. The loop() function is where the main code execution takes place repeatedly.
  6. The line DateTime now = rtc.now(); retrieves the current date and time from the RTC module and assigns it to the "now" variable of the DateTime class.
  7. The following lines extract the individual time components (year, month, day, hour, minute, second) from the "now" variable.
  8. The time is then printed to the serial monitor in the format "YYYY-MM-DD HH:MM:SS" using Serial.print() and Serial.println().
  9. Additional code can be added within the loop to perform any desired tasks based on the current time.
  10. The delay(1000) pauses the execution for 1 second to provide a delay between each time reading.

 

Technical Details:

  • I2C Interface RTC IC
  • Operating Voltage: 5V
  • Less than 500nA current when operating with a battery
  • 56 bytes SVRAM
  • Operates in power or battery mode
  • Programmable square wave output pin
  • Available in PDIP and SO package
  • Optional industrial temperature range: -40°C to +85°C

 

Resources:

 

Comparisons:

The DS1307 and DS1302 are both popular Real-Time Clock (RTC) modules commonly used in electronic projects, The choice between the DS1307 and DS1302 modules depends on the specific requirements of the project. If higher clock accuracy, I2C communication, and additional features are desired, the DS1307 module would be a suitable choice. However, if a simpler interface and lower power consumption are priorities, the DS1302 module may be more appropriate:

  1. Clock Accuracy: The DS1307 module typically has a higher clock accuracy compared to the DS1302. The DS1307 utilizes an integrated crystal oscillator, providing more precise timekeeping.
  2. Interface: The DS1307 module communicates through the I2C (Inter-Integrated Circuit) interface, making it easier to integrate with microcontrollers and other devices. In contrast, the DS1302 module uses a simpler 3-wire interface (RST, DAT, CLK).
  3. RAM Capacity: The DS1307 module includes a 56-byte non-volatile RAM, allowing storage of time-related data or other user-defined information. The DS1302, on the other hand, has a larger RAM capacity of 31 bytes.
  4. Backup Power: The DS1307 module incorporates a battery backup system, enabling it to retain accurate timekeeping even during power outages. In contrast, the DS1302 module does not have built-in backup power and relies on an external power supply for timekeeping.
  5. Functionality: The DS1307 module provides additional features such as programmable square-wave output, alarm functionality, and support for 24-hour time format. The DS1302, while still capable of timekeeping, has a simpler feature set without the programmable square-wave output or alarms.
  6. Power Consumption: In terms of power consumption, the DS1307 module generally consumes slightly more power compared to the DS1302. This is due to the additional functionality and higher clock accuracy of the DS1307.