Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use DS1302: Examples, Pinouts, and Specs

Image of DS1302
Cirkit Designer LogoDesign with DS1302 in Cirkit Designer

Introduction

The DS1302 is a real-time clock (RTC) chip manufactured by Maxim Integrated. It is designed to keep track of the current time (hours, minutes, seconds) and date (day, month, year, and day of the week). The chip communicates with microcontrollers via a simple serial interface and features a battery backup to maintain timekeeping during power outages. Additionally, the DS1302 includes 31 bytes of static RAM for general-purpose data storage.

Explore Projects Built with DS1302

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO Based Touch-Controlled Bluetooth Time Display
Image of smart diary: A project utilizing DS1302 in a practical application
This circuit features an Arduino UNO microcontroller connected to a DS1302 Real Time Clock (RTC) module, a touch sensor, an HC-05 Bluetooth module, and an I2C LCD 16x2 display. The Arduino facilitates communication between the Bluetooth module and the touch sensor, maintains time using the RTC, and outputs information to the LCD display. The provided code skeleton suggests that the Arduino is programmed to perform tasks in a loop, but specific functionality is not detailed in the code.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO Real-Time Clock with DS1307 RTC Module
Image of rrtc: A project utilizing DS1302 in a practical application
This circuit interfaces an Arduino UNO with a DS1307 Real-Time Clock (RTC) module. The Arduino communicates with the RTC module using the I2C protocol, with connections from A4 to SDA and A5 to SCL.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino-Based Real-Time Clock with DS1307 RTC
Image of DS1307 RTC Simulation Demo: A project utilizing DS1302 in a practical application
This circuit integrates an Arduino UNO with a DS1307 Real-Time Clock (RTC) module to keep track of the current date and time. The Arduino communicates with the RTC via I2C (SDA and SCL lines) and displays the time on the serial monitor, ensuring accurate timekeeping even during power outages.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP8266 NodeMCU Based Water Quality Monitoring System with Solar Charging
Image of SISTEMA DE ALIMENTACION Y CARGA PARA EL PROYECTO HUMEDALES CONSTRUIDO UT MATAMOROS: A project utilizing DS1302 in a practical application
This circuit features an ESP8266 NodeMCU microcontroller interfaced with a DS18B20 temperature sensor and a turbidity module to monitor water quality. The NodeMCU reads temperature data from the DS18B20 sensor and turbidity levels from the turbidity module's analog output. Power management is handled by a 18650 Li-ion battery connected to a solar panel and a Do solara charge controller, with voltage regulation provided by an XL6009 module to ensure stable operation of the microcontroller and sensors.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with DS1302

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of smart diary: A project utilizing DS1302 in a practical application
Arduino UNO Based Touch-Controlled Bluetooth Time Display
This circuit features an Arduino UNO microcontroller connected to a DS1302 Real Time Clock (RTC) module, a touch sensor, an HC-05 Bluetooth module, and an I2C LCD 16x2 display. The Arduino facilitates communication between the Bluetooth module and the touch sensor, maintains time using the RTC, and outputs information to the LCD display. The provided code skeleton suggests that the Arduino is programmed to perform tasks in a loop, but specific functionality is not detailed in the code.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of rrtc: A project utilizing DS1302 in a practical application
Arduino UNO Real-Time Clock with DS1307 RTC Module
This circuit interfaces an Arduino UNO with a DS1307 Real-Time Clock (RTC) module. The Arduino communicates with the RTC module using the I2C protocol, with connections from A4 to SDA and A5 to SCL.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of DS1307 RTC Simulation Demo: A project utilizing DS1302 in a practical application
Arduino-Based Real-Time Clock with DS1307 RTC
This circuit integrates an Arduino UNO with a DS1307 Real-Time Clock (RTC) module to keep track of the current date and time. The Arduino communicates with the RTC via I2C (SDA and SCL lines) and displays the time on the serial monitor, ensuring accurate timekeeping even during power outages.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of SISTEMA DE ALIMENTACION Y CARGA PARA EL PROYECTO HUMEDALES CONSTRUIDO UT MATAMOROS: A project utilizing DS1302 in a practical application
ESP8266 NodeMCU Based Water Quality Monitoring System with Solar Charging
This circuit features an ESP8266 NodeMCU microcontroller interfaced with a DS18B20 temperature sensor and a turbidity module to monitor water quality. The NodeMCU reads temperature data from the DS18B20 sensor and turbidity levels from the turbidity module's analog output. Power management is handled by a 18650 Li-ion battery connected to a solar panel and a Do solara charge controller, with voltage regulation provided by an XL6009 module to ensure stable operation of the microcontroller and sensors.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications

  • Digital clocks and timers
  • Data loggers
  • Home automation systems
  • Embedded systems requiring timekeeping
  • Alarm systems and scheduling devices

Technical Specifications

The DS1302 is a low-power RTC chip with the following key specifications:

Parameter Value
Operating Voltage 2.0V to 5.5V
Backup Battery Voltage 2.0V to 3.5V
Operating Temperature -40°C to +85°C
Timekeeping Accuracy ±1 minute per month (at 25°C)
Communication Interface Serial (3-wire)
Static RAM 31 bytes
Maximum Clock Frequency 2 MHz
Package Types 8-pin DIP, SOIC

Pin Configuration and Descriptions

The DS1302 has an 8-pin configuration. Below is the pinout and description:

Pin Name Description
1 VCC1 Primary power supply (2.0V to 5.5V).
2 X1 Oscillator input. Connect to a 32.768 kHz crystal.
3 X2 Oscillator output. Connect to a 32.768 kHz crystal.
4 GND Ground.
5 RST Reset/Enable pin. Used to initiate communication with the chip.
6 I/O Data input/output pin for serial communication.
7 SCLK Serial clock input. Used to synchronize data transfer.
8 VCC2 Backup battery input (2.0V to 3.5V). Maintains timekeeping during power loss.

Usage Instructions

How to Use the DS1302 in a Circuit

  1. Power Supply: Connect the primary power supply to VCC1 and ground to GND. For backup power, connect a 3V coin cell battery to VCC2.
  2. Crystal Oscillator: Attach a 32.768 kHz crystal between the X1 and X2 pins. No external capacitors are required.
  3. Microcontroller Interface: Connect the RST, I/O, and SCLK pins to the corresponding GPIO pins on your microcontroller.
  4. Pull-Up Resistor: Use a pull-up resistor (typically 10kΩ) on the I/O line to ensure proper communication.

Important Considerations

  • Ensure the crystal oscillator is of high quality to maintain accurate timekeeping.
  • Avoid excessive noise on the power supply lines, as it may affect the RTC's performance.
  • Use a decoupling capacitor (e.g., 0.1 µF) near the VCC1 pin to stabilize the power supply.

Example: Connecting DS1302 to Arduino UNO

Below is an example of how to interface the DS1302 with an Arduino UNO and set the time.

Circuit Connections

DS1302 Pin Arduino UNO Pin
RST Digital Pin 7
I/O Digital Pin 6
SCLK Digital Pin 5
VCC1 5V
GND GND

Arduino Code Example

#include <DS1302.h>

// Define DS1302 pins
const int RST_PIN = 7;  // Reset pin
const int IO_PIN = 6;   // Data I/O pin
const int SCLK_PIN = 5; // Serial clock pin

// Create DS1302 object
DS1302 rtc(RST_PIN, IO_PIN, SCLK_PIN);

void setup() {
  Serial.begin(9600);

  // Set the time (Year, Month, Day, Hour, Minute, Second)
  rtc.setTime(2023, 10, 15, 14, 30, 0); // Example: 15th Oct 2023, 14:30:00

  Serial.println("DS1302 RTC Initialized");
}

void loop() {
  // Get the current time
  Time t = rtc.getTime();

  // Print the time to the Serial Monitor
  Serial.print("Time: ");
  Serial.print(t.hour);
  Serial.print(":");
  Serial.print(t.min);
  Serial.print(":");
  Serial.println(t.sec);

  // Print the date
  Serial.print("Date: ");
  Serial.print(t.date);
  Serial.print("/");
  Serial.print(t.mon);
  Serial.print("/");
  Serial.println(t.year);

  delay(1000); // Update every second
}

Troubleshooting and FAQs

Common Issues

  1. RTC Not Keeping Time

    • Ensure the backup battery is properly connected to VCC2.
    • Verify the crystal oscillator is functioning correctly and is of the correct frequency (32.768 kHz).
  2. Communication Failure

    • Check the connections between the DS1302 and the microcontroller.
    • Ensure the RST, I/O, and SCLK pins are correctly assigned in the code.
  3. Incorrect Time or Date

    • Verify that the time and date are set correctly in the code.
    • Ensure the microcontroller's clock speed matches the expected frequency.

FAQs

Q: Can the DS1302 operate without a backup battery?
A: Yes, but it will lose the time and date information if the primary power supply is disconnected.

Q: What is the purpose of the 31 bytes of RAM?
A: The RAM can be used to store user-defined data that needs to be retained during power outages.

Q: Can I use a different crystal oscillator frequency?
A: No, the DS1302 is designed to work specifically with a 32.768 kHz crystal for accurate timekeeping.

Q: How long does the backup battery last?
A: The backup battery can last several years, depending on its capacity and the DS1302's low power consumption.

By following this documentation, you can effectively integrate the DS1302 RTC into your projects for reliable timekeeping functionality.