Real Time Clock Module

This a custom designed module for the DS1307 Real Time Clock. The module comes fully assembled and pre-programmed with the current time (ok, so it's * our current time - *MST). The included Lithium coin cell battery (CR1225 41mAh) will run the module for a minimum of 9 years (17 years typical) without external 5V power. The DS1307 RTC is accessed via the I2C protocol. We've written a test-bed to program the modules. This test-bed code should give you some insight on how to interface the module to any microcontroller using our example software I2C and BCD routines.

**Software: **

  • 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
  • 0.75x0.75" (20x20mm)

Real Time Clock Module Product Help and Resources

Core Skill: Soldering

This skill defines how difficult the soldering is on a particular product. It might be a couple simple solder joints, or require special reflow tools.

1 Soldering

Skill Level: Noob - Some basic soldering is required, but it is limited to a just a few pins, basic through-hole soldering, and couple (if any) polarized components. A basic soldering iron is all you should need.
See all skill levels

Core Skill: Programming

If a board needs code or communicates somehow, you're going to need to know how to program or interface with it. The programming skill is all about communication and code.

3 Programming

Skill Level: Competent - The toolchain for programming is a bit more complex and will examples may not be explicitly provided for you. You will be required to have a fundamental knowledge of programming and be required to provide your own code. You may need to modify existing libraries or code to work with your specific hardware. Sensor and hardware interfaces will be SPI or I2C.
See all skill levels

Core Skill: Electrical Prototyping

If it requires power, you need to know how much, what all the pins do, and how to hook it up. You may need to reference datasheets, schematics, and know the ins and outs of electronics.

2 Electrical Prototyping

Skill Level: Rookie - You may be required to know a bit more about the component, such as orientation, or how to hook it up, in addition to power requirements. You will need to understand polarized components.
See all skill levels


Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Neema20 / about 12 years ago / 4

    So that others might benefit, I am posting my recent experiences with this breakout board. At first, I thought I had a bad board, but after a day of troubleshooting I found the issue. The symptoms were that the board would accept commands, update the time and provide accurate time readings when 5V were applied to the board, but when the power was removed, all registers would zero out. I tested the battery and it was showing a nominal 3.2V, so looking further, only 20 to 40 mV were seen at pin 3 when the battery was in the holder. Seems as if the battery is shorting itself out on the + solder pads where the battery holder is soldered to the board.

    To rectify the problem, I inserted a piece of aluminum foil between the battery and the - battery contact on the board, this lifted the battery enough so that it would clear the + solder pads on the sides and prevent the short from occurring.

    I am currently debating on either leaving it as is or returning it for another unit, but since I soldered a header on the board and it is working, I may end up keeping this one.

    • Member #492383 / about 10 years ago / 1

      Same problem, same fix. If I was really good, I'd try to resolder the battery holder, using less solder. But the aluminum foil trick worked so well, why bother :)

    • cshutchinson / about 12 years ago / 1


      I had the exact same problem; the battery was shorting on the positive solder pads on the right and left. A piece of aluminum foil did the trick. The voltmeter read .05 volts from pin 3 of DS1307 to ground prior to the mod. After the mod, 3.05 volts. Great find and thanks for posting.

  • erickco / about 13 years ago / 2

    Sparkfun, why not put the pull-up resistors on the module for us with jumper to disconnect if necessary?

    • Erazmus / about 11 years ago / 1

      Just ran in to this problem today! I was using a Mikroelectronica DS1307 development module (they call it the RTC2). Transferring my design over to 'production' hardware, I decided to use the Sparkfun DS1307 module. It wouldn't work! After about 20 minutes of trying to measure signals on the pins, I finally figured out that there's no pull-up resistors.

      • TeeJayDub / about 10 years ago / 1

        Was just going to post this as well. Would make it convenient and help get it up and running without errors, which is what this board's about!

  • Fabien Royer / about 13 years ago / 2

    I wrote a C# driver targeting the netduino for this clock module. You can find the code and details here:

  • Member #156578 / about 13 years ago / 2

    For Arduino Uno users -
    I have built on the code John Vaughters included in his tutorial (nice job, btw). Created an RTC library and added the class accessors listed below. Plus, I have a test harness that exercises the library. This is a work in progress (still a little rough, a little light on comments), but if you are just getting started with this nice little 1307 breakout board, perhaps my work might be of some use. Plus, I could use the feedback.
    void getTimeDate(struct timeDateContainer* workingPtr);
    void printTimeDate(struct timeDateContainer* nowPtr);
    void setSeconds(int seconds);
    void setMinutes (int minutes);
    void setHours (int hours);
    void setDayOfWeek (int dayOfWeek);
    void setDayOfMonth (int dayOfMonth);
    void setMonthOfYear (int monthOfYear);
    void setYear (int year);
    bool is12HourModeEnabled(void);
    byte isItAMorPM (void);
    void setAmPm (int amPmDesignator);
    void set24HourMode (void);
    void set12HourMode (void);
    void turn1307On (void); - not yet implemented V 4.0
    void turn1307Off (void); - ditto
    void readMemoryBlock (byte destinationArray[],
    byte numberOfBytes,
    byte startingOffset);
    void clearMemoryBlock (void);
    byte bcdToDec(byte val);
    byte decToBcd(byte val);
    // should be able to use byte instead of unsigned char?
    void I2cWriteUtility (unsigned char newValue,
    unsigned char dataOffset,
    unsigned char dataMask);
    unsigned char I2cReadUtility (unsigned char dataOffset);

  • goaf / about 14 years ago / 2

    Is there any way you could create a module that runs on 3.3V as well?
    I found that the DS3231 to be a fantastic replacement. The DS3231 will function with a VCC ranging from 2.3V to 5.5V and has a battery backup. Unlike the DS1307, the DS3231 also has an integrated crystal (so no external crystal required), temperature sensor, 2 programmable time-of-day alarms, a 32.768 kHz output pin, and a reset button debounce circuit. And the DS3231 only costs a dollar more (DS1307 cost is $1.36/1k and the DS3231 is $2.55/1k).

  • airspoon / about 10 years ago / 1

    I see that the schematic is for v1.3 and I was wondering if its the same for v1.4? Also, is that a 0 ohm resistor? One last question, what size coin-cell battery holder is that? BOM? Any help would be greatly appreciated!

    • We haven't released v1.4 yet, but when we do, the new schematic and board files will be posted. The battery holder is available here.

  • Member #225064 / about 10 years ago / 1

    This module has the following: IC ($1.35), crystal ($0.27), holder ($0.27), 0.56 sq in pcb (~$0.15) capacitor ($0.04), CR1225 (~$0.20) and assembly (~$0.15) for a grand total of $2.43, this even before negotiating with suppliers on volume pricing. Does anyone else think this module is overpriced? For that matter, do all Sparkfun products have such ridiculous margin (approx. 515% margin in this case)? If the answer is yes, I see a real business opportunity here!

    • l0gikG8 / about 10 years ago / 1

      Go for it! Let us know how that business turns out for you.

  • Member #482575 / about 10 years ago / 1

    How can you use this item with the pcDuino or Raspberry Pi??

  • Member #410622 / about 10 years ago / 1


  • Member #463193 / about 10 years ago / 1

    Yes thanks indeed to John Vaughters. I'd have never got this running on my own. Comments below mentioned pull up resistors. There were none shown on the schematic? So now that I have the clock set, I want to read it as a time stamp for a logger. I'll have to use the libraries and whittle the code for my application. It feels like cheating but I'm still toddling along learning the code and the syntax

  • kert / about 11 years ago / 1

    Anyone seen a shield for MCP79410 or PCF85063 ? These are quite a bit cheaper than DSxxx clocks. Microchip has AC164140 and NXP has OM11059A,598 SKU for eval, but of course they arent as neat as ones here ..

  • Just hooked mine up. WOW so easy! I removed the battery to solder it, so the time was 1-1-12 0:0 (or whatever) when I tested it (as I expected). I read through all the comments on here but I liked this guy's example the best. Simple, easy, and got `er done. BTW, that link was

    The libraries are nice, but my project has more crap connected to it than anything I've seen anyone else do with an Arduino, so I didn't want yet another include file. The above was nicely KISS.

  • creation9 / about 11 years ago * / 1

    I wrote a dinky little GUI in java for this device if anyone wants to check it out. Its at my site:

  • Member #425531 / about 11 years ago / 1

    does this work at 3.3v?

  • tzq33tdq / about 11 years ago / 1

    Is there a serial RTC?

  • Member #373745 / about 11 years ago / 1

    Only up to year 2100? I excpect a new millenium crisis!

  • JohnGalt / about 11 years ago / 1

    Is it possible to get one of these preprogrammed to the time being transmitted from Fort Collins, Colorado By WWVB (and even better delivered before it gains or looses a full second....)?

  • Member #377811 / about 11 years ago / 1

    I like it

  • IanM / about 11 years ago / 1

    Sparkfun, the datasheet is also silent (or at least vague) on the issue of accuracy. Could you please provide a reasonable explanation as to how accurate we can expect this clock to be?

    • MikeGrusin / about 11 years ago / 1

      The datasheet is vague because the accuracy ultimately depends on the external crystal. You should expect these to gain or lose up to 30 seconds a month, the same as an average wristwatch.

    • Kamiquasi / about 11 years ago / 1

      I'm not at SparkFun, but judging from the comments above I'd say I wouldn't rely on this being particularly accurate at all. It'll be good enough for rough time keeping purposes, but if you want something better, check out DeadOn RTC - DS3234 Breakout, or even start looking into radio-signal or GPS controlled modules. That said, I'm not sure where the inaccuracy is coming from. This component relies on the crystal and its internal bias offset to get any level of accuracy. While crystals can and do swing (with temperature, for example), they're do pretty well in the hundreds of millions of watches out there. I'd be inclined to blame the internals and would almost thing that not having the bias - and instead relying on external capacitors where you can do some tuning yourself would give more accurate results than the solution they (Dallas) chose here.

  • Member #115584 / about 12 years ago / 1

    This thing is not very accurate, as others have noted. However, the one I have is very stable. Using this device to produce an accurate time requires a little software to remove the drift. If you do this, it's better to let the clock drift and compute a correction than to occasionally reset the clock. Two of the 56 ram bytes can be used to store a reference time. I have a clock that is working well with this approach.

  • jchalo99 / about 12 years ago / 1

    im having a problem with the module returning for hours minutes and seconds 165:165:85, intermittently... i think it is a power problem, because my arduino mega also freezes.

    • Member #344289 / about 11 years ago * / 1

      I am having the same problem. The ds1307 worked fine for several weeks, but then it started showing 165:165:85, etc. I've tried various sketches but it acts as though it has failed. Did you ever find an answer?

  • Member #305330 / about 12 years ago / 1

    hii guys..i also got a problem working with my case i got ds1307 working with atmega 8 and i get the correct time display..but when i use atmega shows 0:0:0...time is not getting display.... my hardware is working perfect.......can anyone help me with this????

  • pu241 / about 12 years ago / 1

    The DS1307 is a nice device, but it doesn't keep time very accurately. Its good for a out a minute a week. If you need better timekeeping try the DS3234, its good for about 1 second a week.

  • baum / about 12 years ago / 1

    While simple, the DS1307 was a bad choice: operating voltage 4.5-5.5V. There are TONS of other great (and cheaper) RTCs which operate as low down as 1V!!!!!

  • xplor / about 12 years ago / 1

    Hi guys, We have just purchased the RTC module from Sparkfun and we thought we could use the "Example 16F88 code" listed above to write it to our PIC16F88, but we have to use the pic basic pro compiler to get it there. We are really new to all of this so we are anxious to learn. Does anyone have code examples that we could use? Thank you for any suggestions.

  • sbright33 / about 13 years ago / 1

    I followed these directions using analog pins 4 and 5 with my Uno. Ran these 2 sketches:
    0/0/0 0:0:0
    0/0/0 0:0:0
    0/0/0 0:0:0
    0/0/0 0:0:0
    Please help!

    • MacJohnMcC / about 12 years ago /

      I found despite the claim that the clock would come preset with the time at Sparkfun that my clock also reported the time and date as zero's. Find an example (link above I think) that will show you how to set the time. Then once you do that it appears to keep the time just fine even with no power.

  • baum / about 13 years ago / 1

    Can you guys sell the DS1307 alone? I need it for a project and I don't want to solder this board to a PC board...

    • Microman / about 13 years ago / 1

      I second that! It is amazing that Sparkfun doesn't already have a simple, 8 pin, I2c chip.

  • Member #75914 / about 13 years ago / 1

    Wow, be aware, while this is a fine chip for learning purposes (i2C)at stable room temperature it looses about 60 seconds per week.
    BTW, this I2C buss chip works fine at 5VDC with the HMC Compass chip on the same I2C buss. I2C pull down resistors either 4.7k or 10K are part of the MHC compass chip.

    • We have a more accurate one here

      • Member #105031 / about 13 years ago / 1

        That's fine but there's nothing on the description of the module that indicates that the accuracy is poor. It's not ok to be selling a clock circuit that doesn't keep time fairly accurately without a big caveat on the product description page. Mine is losing a second every three hours and your reaction is "oh well, we have a better one" - not ok you guys.

  • Member #75914 / about 13 years ago / 1

    After modifying some simple code from the Revolution Ed PICAXE forum this little clock operated fine with a 20X2 C.1 firmware. My first I2C experience. Anyway, the draw back is setting the exact time to the second. I guess it would not take too long to write code to read a GPS and synch the time. Another night ...

  • davidhbrown / about 13 years ago / 1

    Yet another library:
    Includes example sketch that (via Serial monitor) allows you to set the clock, accurately toggle AM/PM, enable/disable the square wave generator, and read/write memory.
    I wanted to use the square wave output to trigger an interrupt and use the battery-backed RAM for a data logger project, so I needed a library that would do a little more than just read the time.

  • turicas / about 13 years ago / 1

    Hello guys,
    I wrote a library to make setting and getting date/time from DS1307 easier on Arduino.
    The code is available at:
    Please let me know what do you think and, if you want, put a link to this library in the product description.

    • weaver / about 13 years ago / 1

      Hi turicas, thankyou for writing the library. I guess you already know but the examples all hang after 120 reads. Probably easy to solve but I do not know how to do it !!

  • Wire54321 / about 13 years ago / 1

    can some write me some code or show me where to get it to reset the clock to UTC Time

  • davidhbrown / about 13 years ago / 1

    I'd like to use the 1Hz oscillator and the "open drain" SQW pin with an LED and resistor connected in series to the 5V supply.
    So far, I'm using a 3K-Ohm resistor to limit the LED to about 1mA (fairly dim). Is this sufficient as a pull-up resistor? A lower value / brighter LED would be nice. A 200-ohm resistor did also work, but I didn't leave it running for a long time. Should I be doing something else, like using SQW to drive my own transistor to switch the LED? Seems redundant, but I'd rather put in an extra part than kill the clock. I can't find anything in the datasheet that refers to allowable current on this pin; presumably it has no problem with the +5V it uses itself.
    All the online references to open drains (mostly talking about open collectors actually) I can find seem to be talking about using values up to hundreds of kohm to try to minimize current or dropping back maybe to 4.7kOhm for something like I2C running lots of parallel devices at 400kHz.
    The intended application is to help confirm running status of a data logger and so will be blinking away for months on end. I can also leave off the blinky without impairing the essential operation if I'm totally missing the intended use of the pin.

  • tecs / about 13 years ago / 1

    I have the sparkfun DS1307 module hooked to my Arduino Uno on analog pins 4 and 5 that same as this diagram When I start it up and use the code from the site above to read it reads noon Jan 1 1999. This works fine, however when I try to set the time using the other example sketch provided I get the right time until i close and reopen the serial monitor or turn off everything and turn it back on. If I do either of those things the the time goes back to 1999. Any ideas what could be wrong? Thanks

  • Bruggen / about 13 years ago / 1

    I want to connect several RTC's at once. Is there a way to change the slave address on a DS1307 and DS3234?

    • baum / about 13 years ago / 1

      Nope. Sorry. If you really need it, maybe you could bitbang a second i2c port in software...

  • Member #72967 / about 13 years ago / 1

    I wasn't paying attention, the battery holder is not a ground. You'll short the battery otherwise and loose time when the device is powered off :)
    This device costs more than Adafruit's, but is around a third of the PCB real estate (double sided, SOIC).
    John Boxall has some good example code and tutorial as well:

    • SomeGuy123 / about 13 years ago * / 1

      SparkFun's devices are better-designed than their competitions' devices, but they tend to cost a tad bit more.

  • Member #86097 / about 13 years ago / 1

    Is there any possibility to change default (0x68) address on this chip ? I have 4 devices on the I2C bus and they all 0x68.
    I am also trying to change the address on the other sensors (K22 Senseair) but without luck so far.
    Thank you !

    • Bruggen / about 13 years ago / 1

      I sent an email to MAXIM support and got the following reply:
      Our I2C clocks are all set for D0h, and there is no way to change that, except on the DS1372 (32-bit binary counter), where you can place 2 devices.
      The DS3234 uses SPI communications, which usually requires device-specific Chip Enable inputs from the Master. There is no Slave Address in SPI.
      DS3231 and DS3232 are I2C-formatted TCXOs.
      Alternatively, you might add an I2C mux to place multiple components of the same Slave address.

  • PavelS / about 13 years ago / 1

    I had troubles getting the example code working with Uno.
    I was successful with the RTC library ( connecting SDA - A4, SCL - A5.

  • Nakor / about 13 years ago / 1

    My watch uses an mbed as it's brain so if there is some drift in the time I don't much care. Compensation is easy. Especially if I implement wifi. It's conveniently already put together for me :)

  • SomeGuy123 / about 13 years ago * / 1

    One of the mounting holes isn't accessible due to the location of the battery holder.

  • Liio / about 13 years ago / 1

    If anyone had the same problem as me I found the solution, hope it saves you some googling time :) I am also unsure if the problem is connected to the UNO or not which I am using.<br />
    <br />
    Two issues:<br />
    Besides having to switch connectors from RX(0) and TX(1) to using A4 and A5 to get a read, I couldn't set the time with the commands provided, it would just randomly set the time. The TsomeNumbers.. did not work. The problem came with the code supplied in both the wiring example and in the bottom section of the Arduino tutorial.<br />
    <br />
    I found by using the less(more?) sophisticated code from it works a treat. just remember to comment out the set time line when the time is set :)<br />
    <br /><br />
    <br />
    Hope this helps!

  • I got my DS1307 displaying on my LCD module. Posted my code and wiring at
    Thank you Sparkfun!

  • tcconway / about 14 years ago / 1

    Can't wait! Any ETA? Thanks!

    • You should know by now our ETAs aren't great :-) It is in the works, that's the most reliable information we have.

  • This module is highly useful, especially with Arduino. We have a tutorial about it here:

  • numinit / about 14 years ago / 1

    Works great, but it was set to a junk time when I got it. It was something like 30:05:00 or something. Had to reset it. Silly Sparkfun :)

    • sethborders / about 13 years ago / 1

      Yeah! mine was preset to 1/1/0 0:0:80 and wouldn't increment.
      but once i set it to the right time it worked great

  • I wrote an arduino library to use this. It's available at but I don't really have 24 hour time working yet. The archive has a Readme.txt that covers how to use the library including how to wire it to the Arduino.

  • SlyVixsky / about 14 years ago / 1

    personally, i prefer the 24 hour version, so though it goes against sparkfun,

  • Ifor / about 14 years ago / 1

    Like the guy said 3.3V needed did not realise it was 5V only. Just ordered myself the 1338 hope my soldering ip up to it.

  • GB / about 14 years ago / 1

    codemonkey: Would love to see one of these for a 3.3v part, rather than 5v.
    What this guy said. 3.3v version please. Have a look at the DS1338 or DS1388. I don't think you even need to change the PCB!

  • kewakl / about 14 years ago / 1

    Kshatrya: OK, it's working now. The module I received had a faulty crystal. No clock, no increment. Who'd have thought? -G-
    Mine arrived with Register-0 Bit-7 SET! No Clocking.
    Hmmmmm. I guess that the date/time is wrong....
    Thanks for setting it at SparkFun;(

  • eXtreme / about 15 years ago / 1

    :) Hello, I have written a tutorial to interface DS1307 Chip with AVR MCUs. You can have a look at it here

  • Attie / about 15 years ago / 1

    Im thinking not... but just incase:
    Is this compatiable with a 3.3v arduino and other 3.3v I2C components?
    If not are there any plans for a 3.3v part? :)

  • Kshatrya / about 15 years ago / 1

    Nothing's incrementing.
    I can read from, and write to the RTC, but the time isn't incrementing. I've tried setting/clearing bit 7 of 0x00, running with/without ground and with/without 1K pull-up resisters. Still no action.
    I've tried the code from Combustory, as well as my own more abbreviated code.
    Heck! I even tried removing the B/U battery to reset everything to zero!
    Can anyone suggest something new to try?
    Victoria, BC

    • Kshatrya / about 15 years ago / 1

      OK, it's working now. The module I received had a faulty crystal. No clock, no increment. Who'd have thought? -G-

  • Japalan / about 15 years ago / 1

    Doc + schema + code in one page. Get it running in just the time of soldering the wires.
    One big difference with tzarcone, I must not plug the ground wire, otherwise reading is always the same.
    Hope this helps.

    • s / about 14 years ago / 1

      If you're using 5v (which the device requires), the pullup resistor values given are wrong. The very minimum should be 1.5k. This might be why it doesn't work with the ground pin connected (yes, that should be connected). If that doesn't work, you have other electrical problems in your system.

  • chrisspurgeon / about 15 years ago / 1

    I would love a bit more newbie help with this module. What do "SQW", "SCL", and "SDA" mean? I think I kinda understand how to run the Arduino tutorial, but I'm actually not clear on how to physically wire the thing up.

    • tzarcone / about 15 years ago / 1

      Since my last replay, I attached the bob 00099 to my arduino duemilanove 328.

      bob to Arduino

      SDA to Analog Pin 4
      SCL to Analog Pin 5
      5v to 5v
      Gnd to Gnd
      I'm able to program and read from it using
      RTC Control v.01
      by <> John Vaughters

    • tzarcone / about 15 years ago / 1

      I found some info on the Arduino Tutorial in Portuguese by Daniel Goncalaves under the "Software" heading.
      It shows a photo and diagram and provides some discriptions. I was able to read it in English by entering the URL into Google search and then use [translating this page] feature.
      I haven't connected my clock yet, so I don't know how accurate the info is.,681.0.html

  • Colin / about 15 years ago / 1

    What's the frequency stability on the crystal? +/-0.5% means that your date/time could be off by almost 2 whole days at the end of a year. 10ppm or less would be nice since that would cut the error to single digit minutes in a year.

    • MaartenC / about 14 years ago / 1

      You've got a point there ! If I knew before that the time-base of this device is not that stable I would of bought another type of RTC. Mine runs 9 seconds behind a day! ( that is about as much as the clock on my cell phone in a whole year ) Maybe I will look for a radio-based syncronisation with DCF-77. (europe system).
      At least then I will have an automatic switch of summer and winter time.

    • xyz / about 15 years ago / 1

      If you want reasonable time keeping I've had much better luck with a DS3231. The only downside is they are about twice the price of a DS1307.

  • codemonkey / about 15 years ago / 1

    Would love to see one of these for a 3.3v part, rather than 5v.

Customer Reviews

No reviews yet.