šŸŽ‰
ESPBoards Store is Now Open! Find the best ESP32, ESP8266 boards & accessories

DS1302 Real-Time Clock (RTC)

DS1302 Real-Time Clock (RTC) image

View on Amazon

Overview

The DS1302 is a cost-effective real-time clock module designed for accurate timekeeping. It operates on a 3-wire serial protocol and supports dual power supplies with a programmable trickle charger, making it suitable for embedded systems, IoT devices, and battery-backed applications.

About DS1302 Real-Time Clock (RTC)

The DS1302 is a low-power real-time clock (RTC) chip capable of maintaining accurate time and date, including leap year compensation up to 2100. It features built-in SRAM storage and a 3-wire serial interface, making it easy to integrate into time-sensitive applications.

⚔ Key Features

  • Real-Time Clock Functionality – Tracks seconds, minutes, hours, day, month, and year.
  • Integrated 31-Byte SRAM – Provides small data storage for system use.
  • Dual Power Supply with Trickle Charger – Supports battery backup for continuous operation.
  • 3-Wire Serial Interface – Ensures efficient communication with ESP32, Arduino, and other microcontrollers.

With its battery-backed operation and compact design, the DS1302 is perfect for low-power embedded systems, data loggers, and real-time event tracking. šŸš€

Where to Buy

Get Your DS1302

DS1302 Real-Time Clock (RTC)

Starting from

1.50$ per unit

Amazon com
Amazon.com Ships worldwide
Amazon de
Amazon.de Ships to EU
Aliexpress
AliExpress Best value option

šŸ’” Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.

Technical Specs

DS1302 Specifications

Complete technical specification details for DS1302 Real-Time Clock (RTC)

šŸ“Š Technical Parameters

Timekeeping Range Seconds to Year (up to 2100)
Power Supply Voltage 2.0V to 5.5V
Backup Battery Voltage 2.0V to 5.5V
Power Consumption <300 nA at 2.5V (battery backup mode)
Interface 3-wire serial
Clock Accuracy Determined by external crystal
Data Storage 31 bytes of static RAM
Operating Temperature 0°C to +70°C (Commercial), -40°C to +85°C (Industrial)
Pin Configuration

DS1302 Pinout

The DS1302 pinout includes power supply pins (VCC1 for primary, VCC2 for backup), a 3-wire serial interface (SCLK, I/O, RST), ground, and crystal oscillator connections (X1, X2).

Visual Pinout Diagram

Pinout Diagram Primary
DS1302 Real-Time Clock (RTC) pinout
8
Total Pins

Pin Types

Power
1
Control
1

Quick Tips

Real-time

clock with seconds, minutes, hours, day, month, year,Leap year compensation up to 2100,31 bytes of SRAM for data storage

Programmable

trickle charger for backup battery/capacitor,3-wire serial interface (simpler than I2C),Operating voltage: 2.0V to 5.5V

Low

power consumption: <500nA in standby,Requires external 32.768 kHz crystal

Pin Descriptions

Pin NameTypeDescriptionNotes
1 VCC1
Power

Primary power supply input (2.0V to 5.5V)

Main power source for normal operation

2 VCC2
Backup Power

Backup power supply input

Battery or capacitor for timekeeping during power loss

3 GND
Ground

Ground connection

Common ground

4 SCLK
Serial Clock

Serial clock input

Clock signal for 3-wire communication

5 I/O
Data

Bidirectional data input/output

Data line for 3-wire communication

6 RST
Control

Reset input (Chip Enable)

Must be HIGH to enable communication

7 X1
Crystal

32.768 kHz crystal oscillator connection

Crystal input

8 X2
Crystal

32.768 kHz crystal oscillator connection

Crystal output

Connection Guide

Wiring DS1302 to ESP32

Connect the DS1302 to your ESP32 using three GPIO pins for the 3-wire serial interface. The module requires a 32.768 kHz crystal and optionally a backup battery (e.g., CR2032) for continuous timekeeping during power loss.

Visual Wiring Diagram

Wiring Diagram Recommended
DS1302 Real-Time Clock (RTC) wiring with ESP32
6
Connections

Connection Status

Required
5
Optional
1

Protocol

3-Wire Serial

Pin Connections

DS1302 PinConnectionESP32 PinDescription
1 VCC1 Required
3.3V or 5V

Primary power supply

2 VCC2 Optional
CR2032 Battery

Backup power (battery or capacitor)

3 GND Required
GND

Ground connection

4 SCLK Required
GPIO18

Serial clock input

5 I/O Required
GPIO23

Bidirectional data line

6 RST Required
GPIO5

Reset/Chip Enable (active HIGH)

VCC1

can be 3.3V or 5V (ESP32 uses 3.3V)

VCC2

typically connected to CR2032 coin cell battery (3V)

RST

pin must be HIGH to enable communication

32.768

kHz crystal required (usually included on module)

Trickle

charger can charge backup battery/supercapacitor

Configure

trickle charger carefully to avoid battery damage

Use

DS1302 library (e.g., ThreeWire + RtcDS1302)

Disable

write protection before setting time

Lower

cost alternative to I2C RTCs like DS1307/DS3231

Help & Support

DS1302 Troubleshooting

Common issues and solutions to help you get your sensor working

Common Issues

Debugging Tips

Code Examples

DS1302 Programming Examples

Ready-to-use code examples for different platforms and frameworks

Summary

Wrapping Up DS1302

The ESP32 DS1302 Real-Time Clock (RTC) is a powerful RTC sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.

Best Practices

For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.

Safety First

Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.

Ready to Start Building?

Now that you have all the information you need, it's time to integrate the DS1302 into your ESP32 project and bring your ideas to life!