Creative Commons images are CC BY-NC-SA 3.0

Description: This is the SparkFun Real Time Clock (RTC) Module, this little breakout that uses the DS1307 to keep track of the current year, month, day as well as the current time. The module comes fully assembled and includes a small CR1225 Lithium coin cell battery that will run the RTC for a minimum of 9 years (17 years typical) without an external 5V power supply.

The DS1307 RTC is accessed via the I2C protocol. We’ve written a test-bed to program the modules, this code should give you some insight on how to interface the module to any microcontroller using our example software I2C and BCD routines.

This rev of the Real Time Clock module finally adds I2C resistors and a larger battery pad to fix the problems with the battery shorting to the board.

Get Started with the RTC Module Hookup Guide


  • Two wire I2C interface
  • Hour : Minutes : Seconds AM/PM
  • Day Month, Date - Year
  • Leap year compensation
  • Accurate calendar up to year 2100
  • Battery backup included
  • 1Hz output pin
  • 56 Bytes of Non-volatile memory available to user
  • 0x68 I2C Address

Dimensions: 0.75x0.75" (20x20mm)


Recommended Products

Customer Comments

  • Tech Support Tips/Troubleshooting/Common Issues

    There are two options to display the clock as a 12-hour mode using an Arduino:

    Using Condition Statements

    Through this method, you would just need to process the received values from the DS1307 to display as a 12 hour value without needing to change the hour register. Using condition statements [ ], you can display the data in “12-hour” mode. Just write the code to subtract 12 hours using an if/else statement if the value is greater than 11:59am in order to display the time as 12 hours. I would write an additional variable to show that the time is either AM or PM. You can write this statement around the line 48 in the first block of code from the bildr tutorial where the data is outputting to the serial monitor similar to this:

    //if less than or equal to 12 hours, display 12 hour
    //if greater than 12 hours, subtract before displaying the hour variable
    hour = hour - 12;//subtract variable

    Setting Bit 6 for the Hour Timekeeper Register 0x02

    Through this method, it is a little bit more complicated to set DS1307 to 12-hour mode. Looking at the datasheet [ ] for the breakout board, there is an option to set the mode as either 12 hour or 24 hours. This is explained on page 8 of the datasheet. Looking at the example code from the bildr tutorial provided, it does not show how to set it. They are just using the DC1307 in 24-hour mode. To set the breakout board to 12-hour mode, you would just send a logic HIGH for bit 6 for the hour timekeeping register. I would probably add it to line 35 of the second block of code where it is sending the hour value to the DS1307. This is the section that says “RUNNING THE FOLLOWING CODE WILL RESET THE TIME” :


    Since the hour is already converted to a binary from the function decToBcd(), I would just use a logical bitwise operator [ ]. Using the binary value B01000000 and the bitwise OR operator, this should set the clock to output in 12-hour mode while also setting the original defined hour at the beginning of that example code. This modified function should work:

    Wire.write((B01000000  | decToBcd(hour) ));
  • The DS1307 also gives weekday (Mon, Tues, etc); see the data sheet. I needed that for a sprinkler control system that operates in a district that allows sprinkling only on certain days. Hate to say it but ebay is MUCH cheaper.

  • Tacroy / last year * / 1

    Well this is kinda weird -

    I didn’t realize that these were 5 volt devices, but I figured since I was prototyping on an Uno I could get the systems working together and then worry about getting 3.3V components.

    I set it up so that this was running off of the Uno’s 5V pin, and everything worked fine.

    Then I decided, “What the heck, I’ll put it on 3.3V and see what happens”. Apparently, it works ok - the time seemed correct - so I guess that’s nice.

    The particularly strange part, though, is that the thing I’m working on is time-critical, so I had code timing my communication with the RTC. At 5V it took ~1060 microseconds, but with the RTC running off the 3.3V pin it took ~290 microseconds - more than 3x faster.

    I figure hey, the RTC has its own battery, maybe it’s ignoring the 3.3V line and just using its internal reserves to talk? Nope, if you don’t provide it with anything it’ll refuse to chat.

    So that’s weird I guess. The datasheet says that the min for Vcc should be 4.5V, but it actually seems to work faster at 3.3V. It might be slowly breaking on the inside or something.

    edit: aha, found the downside - when you cut power at 3.3V, the RTC forgets what time it was despite the backup battery being present and charged. There had to be a catch!

  • For just 5 dollars more you can get an Arduino shield with the same (lousy) RTC, but with also a breadboarding area and SD socket at Adafruit. Maybe this breakout board could be made cheaper if you’d use the PCF85263A instead of the DS1307. New breakout board please!

  • I found the more recent NXP PCF85263A, which is superior to the DS1307 in every way, yet costs 70% less! How about a breakout board for the 85263A?

    The DS1307 and PCF85263A compared:

  • According to DS1307’s datasheet, it needs a minimum voltage of 4.5V to work. How can a 3V battery (CR1225) work at all?

    • Because the battery doesn’t run the module. The battery is there just to keep time when the unit is powered off, but you can’t communicate with the module at all when its just powered via the battery.

      • I found it so hard to believe that it really needed 5V that I had to check the datasheet. And it’s true! Next I checked the calendar, and we’re indeed in the 21st century! Maybe you should make a breakout board with an NXP PCF2123. This can communicate at Vdd from 1.8V to 5V, operates down to 1.1V and consumes only 100nA. That’s the 21st century! :-)

        (BTW, the PCF2123 is SPI. The I2C version is the PCF8523)

  • How accurate is this chip over long periods of time? If I set it correctly now, how far can I expect it to have drifted after 6-12 months?

    • The accuracy of an RTC depends on the crystal and load capacitors used, not the IC. The DS1307 has its load capacitors integrated, so there’s no way of tuning it there, then everything depends on the crystal tolerance. There are RTC ICs with calibration registers which let you tune the frequency, like the Microchip MCP7940 and the NXP 85263A, to name a few. I guess that a couple of seconds per month is possible, provided temperature doesn’t vary much. The DS1307 can’t be calibrated.

  • Awesome! Just got mine in the mail! For some reason, it thought it was 2011, but I took out the battery and put it back in and it fixed the problem.

  • Does this compensate for DST (Daylight Savings Time)? Is it possible to reset the clock to a different time?

    • It does not compensate for U.S. DST or any other system. You are able to set the time to whatever you want and then the lock steps forward in minutes/hours/days/months/years automatically as time wears on. It’s possible to set it to a random date in 2004 if that’s what you send it.

  • Is it possible to run this board at the 3.3v needed for a FLORA device?

    • Possible yes. Reliable no, since you’ll be operating the RTC out-of-spec. So it may work, but don’t count on it. Most RTC ICs nowadays can operate from, say, 1.7V up to 5V. Maxim RTCs are exceptions.

  • Is the 1 Hz square wave synced with the clock on the chip. I.E. Does the second roll over during the transition of the square wave?

    If I query the chip right before the 1 Hz pulse and right after. Will the seconds have incremented. I have looked through the datasheet and it is not clear on this.

  • Does this module include the crystal oscillator? I see that sparkfun has a 32.768kHz crystal available for sale, but it is not listed in “Also Purchased” ——-> so it doesn’t appear that people are buying them with this module.

    • Yes - it’s a complete module built around the RTC and includes the board with all the components on it as shown.

  • I confirm DS1307 work well on 3.3V GPIO with 1K pullup resistors on SDA/SCL, dont forget to unsold SJ2 jumper and supply 5V power. For information my board got 4.7K on SDA/SCL,it’s too much and dont work well. START falling edge on SDA pin is not clear with 4.7K, with 1K signal is perfect on 3.3 V GPIO.

  • So if I remove the solder jumpers on SDA/SCL it will bypass the pull up resistors. Could this then be used on a BBB using a 3.3v I2C bus instead of 5v (using the BBB pull-ups on the I2C clock and data pins)?

    Sorry for the nob question, but took so long to get a ‘bone that I don’t want to fry it by being a moron.

  • The link to the Arduino code is broken……

    • which link specifically, they all work for me.

      • The [English] Arduino Tutorial doesn’t work. I just got an error that they’re experiencing technical difficulties. The specific error message I got was this:

        (Can’t contact the database server: Can’t connect to MySQL server on ‘larry’ (111) (larry))

        I do live in the Central US, if that might somehow help, and ATT is my ISP.

        • Yeah, their site is having issues. I would just check the Bildr tutorial instead, it’s pretty good.

  • The pad says 5V but the coin cell is 3V. Can I run this on 3.3VDC if everything else on the i2c bus is 3.3VDC?

  • why would you put the SQW right in the middle of 4 primary I2C pins? shouldnt it be on one of the ends?

  • You can check out my RTCC library for the DSXXXX it has functions for setting, LCD update, display of time and temperature.

    C Sample Code

  • Is that a 0-ohm resistor and does anyone know what size coin-cell battery holder and the crystal? Any help would be much appreciated!

    • The schematic should help you derive that the two black components are 4.7kOhm resistors, the light brown one a 0.1uF capacitor, the crystal a common watch crystal (32.768kHz), and the description states “includes a small CR1225 Lithium coin cell battery”.

  • I was trying to figure out what the jumpers were for, so I tried to take a look at the schematic and eagle files, but both appear to be the older version (V1.3). Do you plan to post the ones for this revision? At the very least, do you mind saying what the apparent jumpers are for?

Customer Reviews

4.3 out of 5

Based on 6 ratings:

5 star
4 star
3 star
2 star
1 star

2 of 2 found this helpful:

something you need

NOBODY told me you had to SET THE CLOCK !!!! There was a lot about it was set at the factory and would go for 17 years, but nothing about that I had to set the clock. I found it in an obscure tutorial on the use of PICAXE and the I2C serial communication protocol. Please note on your SPARKFUN data spec that the breakout board has to have the data SET with a HI2COUT instruction !

1 of 1 found this helpful:

Good clock!

Easy to use, I needed to set the clock too but it is easily accomplished with one line from RTClib (google it)!

Very small RTC, which is great.

Almost the smallest I’ve found. However, I’m designing a board that could use any available RTC. Adafruit, Ebay finds, etc. They mostly have similar pin configurations, except for this one. I’ll have to include two header options, because the small size outweighs the inconvenience.

Awesome Product, but Lacking the Awesome SparkFun HookUp Guide

Preferred this over the “Dead On RTC”, as the I2C is easier to connect than the SPI on the ICSP for the boards i use. The product worked as intended out of the box. The clock may have been programmed, but i didn’t check. Piece of cake!

Being a thickheaded lout, the (typically awesome) SparkFun hookup guide would have been helpful to me. Still, i muddled through. I did use the AdaFruit branch of the JeeLabs library. (So i owe those folks.)

Great RTC breakout

Worked right out of the box! All I had to do is solder on a header and unsolder the solder jumpers that pulled up the SDA and SCL to +5V since the Raspberry Pi I was connecting to already has pullups to +3.3V on-board. A bit of code, 4 wires to connect, and I could read and write the time registers to set and read the time.

Great timesaver for one-off project

This module was exceptionally easy to hook up with an Arduino. Breakout board made it easy to test on a breadboard and then solder directly into the completed project. A minor improvement would be to add a non-connected hole and pad opposite the primary header holes to allow and additional header pin to be installed and make permanent installation onto another PCB sturdier.

Related Tutorials


Real Time Clock Module Hookup Guide

October 6, 2016

A quick introduction to the DS1307 RTC module and a hookup guide for the SparkFun Breakout.