DS1307 Real-Time Clock (RTC)

DS1307 Real-Time Clock (RTC) image

View on Amazon

Overview

The DS1307 is a widely used real-time clock module with I2C communication. It supports leap year compensation, battery-backed operation, and 56 bytes of user-accessible SRAM, making it ideal for embedded systems and low-power applications.

About DS1307 Real-Time Clock (RTC)

The DS1307 is a widely used real-time clock (RTC) module designed to maintain accurate timekeeping, including automatic leap year compensation. Unlike the DS1302, it communicates via I²C, simplifying integration with ESP32, Arduino, and other microcontrollers.

Key Features

  • Real-Time Clock Functionality – Tracks seconds, minutes, hours, day, date, month, and year.
  • I²C Communication – Easier integration than 3-wire serial RTCs like the DS1302.
  • 56-Byte Battery-Backed SRAM – Stores small user data for embedded applications.
  • Battery Backup Support – Maintains timekeeping during power loss (no trickle charger like DS1302).

With its I²C interface and reliable backup capabilities, the DS1307 is an excellent choice for data loggers, automation systems, and real-time event tracking. 🚀

🔗 Looking for a different RTC? Check out the DS1302 for a 3-wire alternative with trickle charging.

Where to Buy

Get Your DS1307

DS1307 Real-Time Clock (RTC)

Starting from

2.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

DS1307 Specifications

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

📊 Technical Parameters

Timekeeping Range Seconds to Year (up to 2100)
Power Supply Voltage 4.5V to 5.5V (VCC), 2.0V to 3.5V (VBAT)
Backup Battery Current <500 nA at 3.0V
Interface I2C (400 kHz)
Data Storage 56 bytes of battery-backed SRAM
Clock Accuracy Determined by external crystal
Operating Temperature 0°C to +70°C (Commercial), -40°C to +85°C (Industrial)
Pin Configuration

DS1307 Pinout

The DS1307 pinout includes I2C communication pins (SDA, SCL), power supply (VCC, VBAT), ground, and crystal oscillator connections (X1, X2). It provides 56 bytes of battery-backed SRAM.

Visual Pinout Diagram

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

Pin Types

Power
1

Quick Tips

Real-time

clock: seconds, minutes, hours, day, date, month, year,Leap year compensation up to 2100,56 bytes of battery-backed SRAM for user data

I2C

interface with standard address 0x68,Operating voltage: 4.5V to 5.5V (VCC), 2.0V to 3.5V (VBAT),Low power consumption: <500nA in battery backup mode

Automatic

switchover to battery backup when VCC fails,Requires external 32.768 kHz crystal

Pin Descriptions

Pin NameTypeDescriptionNotes
1 VCC
Power

Primary power supply input (4.5V to 5.5V)

Typically 5V for normal operation

2 GND
Ground

Ground connection

Common ground

3 SDA
I2C Data

I2C Serial Data line

Bidirectional data line (requires pull-up)

4 SCL
I2C Clock

I2C Serial Clock line

Clock line (requires pull-up)

5 X1
Crystal

32.768 kHz crystal oscillator input

Crystal input

6 X2
Crystal

32.768 kHz crystal oscillator output

Crystal output

7 VBAT
Backup Power

Battery backup input (2.0V to 3.5V)

CR2032 battery for timekeeping during power loss

8 SQW/OUT
Output

Square wave/output driver

Programmable square wave output (optional)

Connection Guide

Wiring DS1307 to ESP32

Connect the DS1307 to your ESP32 via I2C (SDA and SCL pins). The module requires 5V power, a 32.768 kHz crystal, and optionally a CR2032 battery for backup. Pull-up resistors (typically 4.7kΩ) are required on SDA and SCL lines.

Visual Wiring Diagram

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

Connection Status

Required
4
Optional
2

Protocol

I2C

Pin Connections

DS1307 PinConnectionESP32 PinDescription
1 VCC Required
5V

Primary power supply (5V preferred)

2 GND Required
GND

Ground connection

3 SDA Required
GPIO21

I2C data line (with 4.7kΩ pull-up)

4 SCL Required
GPIO22

I2C clock line (with 4.7kΩ pull-up)

5 VBAT Optional
CR2032 Battery

Backup battery (3V)

6 SQW/OUT Optional
GPIO (optional)

Square wave output (optional)

I2C

address: 0x68 (fixed, not configurable)

DS1307

prefers 5V operation, but some modules work at 3.3V

Pull-up

resistors (4.7kΩ) required on SDA and SCL

Most

modules include pull-up resistors on board

VBAT

typically connected to CR2032 coin cell battery (3V)

32.768

kHz crystal usually included on module

Automatic

battery backup when main power fails

Use

RTClib or DS1307RTC library for Arduino/ESP32

Less

accurate than DS3231 (no temperature compensation)

Lower

cost alternative to DS3231

Help & Support

DS1307 Troubleshooting

Common issues and solutions to help you get your sensor working

Common Issues

Debugging Tips

Code Examples

DS1307 Programming Examples

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

Summary

Wrapping Up DS1307

The ESP32 DS1307 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 DS1307 into your ESP32 project and bring your ideas to life!

Similar Options

Explore Alternative Sensors

Looking for alternatives to the DS1307? Check out these similar sensors that might fit your project needs.

DS3231 / AT24C32 Real-Time Clock (RTC)

DS3231 / AT24C32 Real-Time Clock (RTC)

RTC I2C

The DS3231 is a highly accurate I²C real-time clock with an integrated temperature-compensated crystal oscillator, providing precise...

View Details
PCF8563 Real-Time Clock (RTC)

PCF8563 Real-Time Clock (RTC)

RTC I2C

The PCF8563 is a low-power real-time clock/calendar with I2C interface, offering timekeeping functions, programmable clock output, alarm and...

View Details
DS1302 Real-Time Clock (RTC)

DS1302 Real-Time Clock (RTC)

RTC 3-Wire

The DS1302 is a cost-effective real-time clock module designed for accurate timekeeping. It operates on a 3-wire serial protocol and...

View Details
iiq_pixel