DS1307 is a low-power Full Binary (BCD) Real Time Clock (RTC) IC with 56 bytes of SVRAM that communicates via I2C Protocol.
This blog provides you a detailed introduction to DS1307 RTC, including its pinout, application, how does it work in a circuit, what's its difference between DS3231 and more, hope this blog helps and thank you for reading!
This is a tutorial video teaching people how to connect DS1307 with Arduino.
Catalog
DS1307 Description
The DS1307 serial real-time clock (RTC) is a low-power, full binary coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus.
The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator.
The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply. Timekeeping operation continues while the part operates from the backup supply.
The DS1307 can operate in the following two modes:
-
Slave Receiver Mode (Write Mode): Serial data and clock are received through SDA and SCL.
-
Slave Transmitter Mode (Read Mode): The first byte is received and handled as in the slave receiver mode. However, in this mode, the direction bit will indicate that the transfer direction is reversed.
DS1307 Pinout
|
|
DS1307 RTC |
DS1307 RTC Pinout |
Pin Number |
Pin Name |
Description |
1,2 |
X1 , X2 |
Crystal Oscillator should be connected to these pins |
3 |
V-Bat |
Connected to Positive terminal of the battery |
4 |
Ground |
Ground pin of the IC |
5,6 |
SCL and SDA |
Pins for I2C communication with CPU |
7 |
SQW / Out |
Square wave output driver pin to obtain square wave frequencies. |
8 |
Vcc |
Powers the IC typically 5V |
DS1307 Features
-
I2C Interface RTC IC
-
Operating Voltage: 5V
-
Less than 500nA current when operating with battery
-
56bytes SVRAM
-
Operates in power or battery mode
-
Programmable square wave output pin
-
Available in PDIP and SO package
DS1307 Parameter
Type: |
Clock/Calendar |
Features: |
Leap Year NVSRAM Square Wave Output |
Base Product Number: |
DS1307 |
Interface: |
I²C 2-Wire Serial |
Memory Size: |
56B |
Time Format: |
HH |
Date Format: |
YY-MM-DD-dd |
Voltage - Supply Battery: |
2V ~ 3.5V |
Current - Timekeeping (Max): |
200µA @ 5V |
What is I2C Protocol
I2C is a serial protocol that transfers data bit by bit.
I2C combines the best characteristics of SPI and UART. We can control many slave devices by using it with a single microcontroller.
Data is transferred in the form of messages in I2C, and the messages are then converted into data. Each message contains an address frame containing a binary address of the devices under control.
The I2C protocol is less expensive to implement than the SPI protocol. SPI controls a single slave device, whereas I2C controls multiple devices.
Let's take a look at the I2C protocol diagram for a better understanding.
DS1307 Working Principle
Let's look at a circuit that uses the DS1307 to get a better understanding of how it works.
In this simple circuit, we connect the chip's first two pins, X1 and X2, to a 32.768 kHz crystal oscillator as the source.
The third pin is linked to a 3V battery.
We provide a 5v supply at Vcc, which can be provided by a microcontroller. If Vcc is not supplied, the read and write conditions are disabled.
When using the I2c protocol, a device must have start and stop conditions in order to communicate with other devices.
We provide a specific identification and address register to a device in order to obtain the start condition.
For a better understanding of stop and start condition lets have a look at clock figure.
How to Use DS1307
The DS1307 is an 8-pin IC that runs on 5V and communicates with the CPU via the I2C protocol. A typical application circuit for the DS1307 is shown below, taken from the DS1307 datasheet.
As you can see, the IC has SCL (Serial Clock) and SDA (Serial Data) pins that it uses to communicate with the CPU; both of these pins must be pulled high using a resistor. The IC can be powered by applying 5V to the Vcc pin; if the power fails, it will automatically switch to battery mode, obtaining power from a Lithium cell connected to pin Vbat and ground.
Pins X1 and X2 are used to connect the crystal oscillator, which is typically a 32.7KHz Quartz crystal. The SQW pin generates a PWM square wave with programmable frequencies of 1Hz, 4KHz, 8KHz, or 32KHz. This pin also necessitates the use of a pull-up resistor. Only the I2C protocol is used to exchange data between the CPU and the RTC IC. This communication facilitates both reading and writing.
The IC can provide information such as a Real-Time Clock that counts seconds, minutes, hours, the date of the month, the month, the day of the week, and the year, with Leap-Year Compensation Valid Up to 2100.
DS1307 vs DS3231
DS3231
The DS3231 is also a low-cost, extremely accurate I2C real- time clock (RTC). But it is a RTC with an integrated temperature- compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accu- rate timekeeping when main power to the device is inter- rupted.
The main distinction between the DS3231 and the DS1370 is the accuracy of time-keeping.
The DS1307 includes an external 32kHz crystal for timekeeping, the frequency of which is easily affected by external temperature. As a result, the clock is usually off by about five or so minutes per month.
The DS3231, on the other hand, is much more accurate because it includes an internal Temperature Compensated Crystal Oscillator (TCXO) that is unaffected by temperature, allowing it to be accurate to a few minutes per year at most.
DS1307 is still a great value RTC that will serve you well, but DS3231 is recommended for projects that require more accurate time-keeping.
DS1307 Application
-
Robotics
-
Gaming
-
Servers
-
Computer Peripherals
-
GPS
-
Utility power meters
DS1307 Manufacturer
Maxim Integrated develops innovative analog and mixed-signal products and technologies to make systems smaller and smarter, with enhanced security and increased energy efficiency. We are empowering design innovation for our automotive, industrial, healthcare, mobile consumer, and cloud data center customers to deliver industry-leading solutions that help change the world.
DS1307 Package
Component Datasheet
FAQ
The DS1307 is a low power Full Binary (BCD) Real Time Clock (RTC) IC with 56 bytes of SVRAM that communicates through I2C Protocol. The IC can work from directly supply on Vcc and switch to Battery automatically when required.
|
- How do I know if DS1307 is working?
If you had a Master I2C/SMBus Engine tool built up, you could connect just it and the DS1307 together (with pull-ups and other essentials of course) and quickly see if you can communicate with the DS1307 in a few minutes. If you can, then you know that your DS1307 is working and it could be your C code.
|
- How do I reset my RTC DS1307?
So to start, remove the battery from the holder while the Arduino is not powered or plugged into USB. Wait 3 seconds and then replace the battery. This resets the RTC chip.
|
A real-time clock (RTC) is an electronic device (most often in the form of an integrated circuit) that measures the passage of time. Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time.
|
- How many bytes of NV SRAM is the DS1307 serial real-time clock?
56 bytes
|
- In what format does the DS1307 clock operate?
24-hour or 12-hour
|
- What does the DS1307 have a built-in power-sense circuit that detects?
Power failures
|
- What does the DS1307 operate in?
Slave Receiver Mode (Write Mode)
|