Home | Product Categories | Breakout Boards | BOB-10160

DeadOn RTC - DS3234 Breakout

sku: BOB-10160 RoHS Compliant In Fritzing Library

Description: Here is a real time clock based on the DS3234 Real Time Clock IC. The DS3234 is a low-cost, extremely accurate SPI bus real-time clock with an integrated temperature-compensated crystal oscillator and crystal.

The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections of leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided.

The underside of the board holds a 12mm coin-cell battery holder for battery backup.

Note: These do not include a battery. See the related products below for a battery.

Features:

  • +-2ppm accuracy
  • Two alarms
  • SPI output
  • Low power consumption
  • Accurate calendar up to year 2100
  • Battery backup included

Documents:

Pricing

In stock

19.95
17.96
15.96

45 in stock

price
10-99
100+



Add to Wish List


Comments 62 comments

  • I created an implementation of JeeLabs RTClib for this unit. It’s posted on github.

    • Hey just wanted to say thanks for the library you posted. I really appreciate it as i am new to all this and was having trouble getting this clock talking with the whole SPI thing then realized the RTClib i had was wrong and meant for a DS1307. After adding your RTClib everything worked perfect! Seeing the differences I now understand a lot more about the arduino environment. I can’t thank you enough!

    • Thanks for creating this library!! It helped a lot!!

      One thing I would add, is that you need to set the SPI data mode back to MODE0 after using this library if you are also using the SD card and the ethernet shield.

      Also, make sure you aren’t trying to access the clock while you have a file open on the SD card. I check the time, check for HTTP requests, and then serve a file. It seems you can get away with accessing the ethernet chip while files are open, but the RTC doesn’t work that way.

      I use the following functions:

      void set_time()
      
      {
      
      SPI.begin();
      
      RTC.begin();
      
      // RTC.adjust(DateTime(__DATE__, __TIME__));
      
      SPI.setDataMode(SPI_MODE0);
      
      }
      

      DateTime check_time()

      {

      DateTime now = RTC.now();
      
      SPI.setDataMode(SPI_MODE0);
      
      return now;
      

      }

  • Just to put things in perspective, +-2ppm is 2 seconds in 11.57 days or one minute in 347 days. Or just about one minute per year.
    For a simple crystal RTC, this is great. For a highly accurate timepiece it is marginal. If accurate time is your holy grail, then a GPS or radio time piece might be a better choice. In those cases you get tied back to the world time standard and will not suffer drift.

    • My math comes up with different numbers. +/-2ppm = 2E6, there are 60 sec/min, 3600 sec/hr and 86400 sec/day. 2E6 divided by 86400 sec = 23.148148 Days. Therefore if the error remained constant at plus or minus 2ppm it would take 23 days, 3 hrs, 33 min and 20 sec to gain or loose 1 sec repectively.

      • Sorry, I wasn’t pay attention to what I was reading. 2 seconds in 11.57 days = 1 second in 23.14 days, therefore my math does agree with your numbers. Can I chalk it up to a long day?

    • Yes – this great for small projects, or beginners though, and easier to use. It’s perfectly good for things that don’t need to be at an exact time, but around the same time.

    • I hope you agree with me that it is +– (plus or minus) 2ppm. this means that drift can occur in both directions, so what you are sketching is a worst case scenario.

    • Ive just got mine going, and I’m losing about 3 seconds per day right now… This is totally unacceptable! Has anyone else had an issue like this?

  • Are there any issues using this with a 3.3V micro? I have integrated this with a logomatic via the SSP1 and it works pretty well 99% of the time but sometimes I fail to clear the alarm flag – when this happens repeated writes don’t make much difference

  • Does this work with Arduino?
    And also, how specifically should I wire it up?

    • Yes this works with an Arduino, please see the Example Code. I just named it .c instead of .pde for display in notepad++. As for wiring please check http://www.arduino.cc/playground/Code/Spi. With the exception of SPI slave select which is pin 8 in the Example Code that page should help.

    • Yes.
      Just wired it up like this.
      Pin 13 SCK
      Pin 12 MISO
      Pin 11 MOSI
      Pin 8 SS
      Also i had to change a line in the example code to be able to set the time.
      SPI.setDataMode(SPI_MODE3); // Mode1 didnt work

      • I have mine wired as Pin 13 CLK (there’s no pin marked SCK on the RTC board) Pin 12 MISO, Pin 11 MOSI, and pin 8 SS. Using the example code, I tried MODE1 and MODE3 and both result in the following being displayed:
        45/25/165 18:85:85
        or
        0/0/0 0:0:0
        Any ideas? Thanks.

        • I am having the same issue.
          Wired the RTC up like above but neither MODE1 nor MODE3 are giving a different result from 0/0/0 0:0:0
          Also tried using RTClib as suggested in this thread.
          Possibly a defective part?

        • I was experiencing the 45/25/165 18:85:85 / 0/0/0 0:0:0 issue as well. Turns out I had the wiring wrong (I’m a beginner). I’m using the Mega 2560 and I have it wired up as follows:
          GND – GND
          VCC – 3.3v
          SQW – GND
          CLK – 52
          MISO – 50
          MOSI – 51
          SS – 8
          battery is attached
          It now works with both Sparkfun’s example and maniacbug’s library (which is awesome!).

        • Check on the second line of the example code, that the “cs” constant has the same number with the pin that you connect the “ss” pin on the DS3234

        • I would recommend soldering on some break away headers to make sure the connection to the chip and your breadboard is solid. I had the same issue but this solved it.

  • Cool product! This would go great with the LF radio clock receiver IC. Never set the time in your device again!
    http://www.sparkfun.com/products/10060

  • the decription confuses me abit. it has an temperature-compensated crystal oscillator AND crystal? is this a mistake in the description?
    also because this rtc does not come with a battery everybody will have to set the rtc to the right time/date themselves. right?

    • Yes, you will need to set the clock. I’ll check into the other thing, they claim that in the manual for the IC, and yes, it’s confusing.

  • i think they meant to place Sram instead of crystal.
    the headline of the datasheet says “Extremely accurate SPI bus RTC with integrated crystal and Sram”

  • Super lol. I just ordered the other RTC two days ago. FML.

  • This is ALMOST perfect for a project a friend is working on, but it doesn’t have the ability to output in granularity of 1/100s or 1/1000 of a second.. Does anyone know of an accurate time chip which would be able to output 1/1000s of a second? It doesn’t even have to be absolute time – Just knowing a duration is fine, but I need to be able to read the clock twice, and know accurately how many 1/1000s of a second have elapsed.
    Thanks!!

    • The datasheet speaks of a 32kHz (32768 Hz) output pin 3 and a square wave output on pin 5 with selectable frequency. Depending on register settings this can output 1024 Hz. You’d still need something to count those pulses though.

  • Does it compensate for DST?

    • From the absence of any DST information in the datasheet, it appears it does not. I would have suspected this as well considering governments are forever changing the rules on DST.

  • Sweet breakout board. If you don’t need the “256 bytes of battery-backed SRAM”, checkout the ChronoDot2.0 using a sister chip DS3231: http://macetech.com/store/index.php?main_page=product_info&products_id=8.
    Its bulbdial clock compatible: http://www.sparkfun.com/products/10021
    And a bargain at $15, battery included!

    • Somehow, the ChronoDot has been out of stock every time I’ve checked. I’d have bought several and recommended more by now if this wasn’t the case.

  • Is there any chance the next batch of these could be produced using the DS3234SN part instead of the DS3234S? This product would be much better if it could operate in the industrial (-40°C to +85°C) temperature range.

    • The macetech ChronoDot2.0 is made with the DS3231SN, which has the operational range of -40 to 85 deg C. See above post.
      http://macetech.com/store/index.php?mainpage=productinfo&products_id=8

      • Actually, I have been debating between the ChronoDot2.0 with it’s i2c interface, extended temp range and the lower cost, and the Sparkfun DS3234S based module with the sram and SPI interface. Either module would be excellent, but it would be nice if Sparkfun would produce two versions of 3.3volt RTC modules, one based on the DS3231SN for the i2c fans and a second version based on the DS3234SN for the SPI fans. ChronoDot, well, I guess I am a square person.. and I like the form factor Sparkfun is using. Also, my case, I am looking for a device with a bit of memory onboard since I will soon be working with a leaflabs maple board (STM32 based) which does not have eeprom onboard. While the STM32 can emulate eeprom, I would rather use sram external if I have a choice, thus my interest in the Sparkfun module. The DS3234S has a good all around set of features in one package. Also, I’m dealing with some very cold temps, thus the extended temp range request.

        • In that case solder it up yourself:
          http://www.sparkfun.com/products/496
          +
          http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=DS3234SN%23-ND
          You can trim the breakout board down to twenty pins and your set!

  • It would be great if there was a revision of this which broke out the 32kHz pin – since that can feed the async timer of an AVR for sub-second RTC on the AVR.
    (I hadn’t realised at all the CLK pin is the SPI clock. Yeah, kinda obvious now I look at it.)

  • Seriously, $20 and no battery included? Why?
    ALL the other RTC’s I’ve purchased from SFE included a battery. What’s different? My fault for not noticing… but really?

  • Some help, please. I intend to use the square wave output to trigger an interrupt on a uC. The datasheet says that this line needs a pullup resistor. The schematic for the board shows a 10K resistor and 22pf cap to ground from this pin. I presume that the 10k, since it is on the “high” side of the cap, is not an issue in terms of my pullup resistor.
    So… a couple of questions from this newbie. The reference diagram on the datasheet does not indicate a need for this circuitry. Why is it there? Second, any suggestions for a pullup? I was thinking in the 4.7K range.
    Thanks all.
    Ed

  • Cancel that question. Half asleep this morning. I figured it out.

  • One more post: I spent a couple of hours getting the interrupt to work this morning. Two pieces of info that may be of use— (1) The output of the square wave pin on the ds3234 cannot be tied directly to the input of an Arduino. A 4.7K resistor seemed to work fine. (2)You may need to build a delay into your code between detecting a square wave and reading the registers to let the update complete.

  • Perhaps a bit of help to a real new user. I bought the DS3234 and do have it running. I set the clock by entering it into the code supplied on this page. This only gets to clock close not exact. How can this clock be set to the current internet time? As a newcomer to C language coding, how can I reference the clock time in other programs? I need to trigger a camera during a specific time, as I photograph the space shuttle launches and need to listen for the sound of the launch during the time it may take place. I am using PLC’s to do this in the past but want to try an Arduino triggger for the next launch (Images at MarkWidick.com) Thanks in advance.

    • http://arduino.cc/playground/Main/InterfacingWithSoftware Start there. I believe something like Firmata or GoBetwino would help you out. You may be able to just script something up using serial transmissions only. Needing the type of accuracy one would desire for such a one time only event I would think that GPS or radio would be better for you. Get your GPS time, if it matches the desired set time, take the pic.

  • Any idea how to (easily) calculate duration using this RTC? I can’t track down a function that would let me subtract a start date and time from the retrieved date and time. I want something similar to:
    duration = millis() – startTime;
    Thanks!

    • I think maniacbug’s port of JeeLabs RTClib (grabbed link from comment above) would help with with date calculations.

    • With a little bit of string manipulation, you could change the date and time into seconds since a certain date (The standard is January 1, 1970) and then subtract your starting time in seconds since that date from the current time since that date in seconds. It is very similar to ctime.

      • Seems like that would be A LOT of string manipulation. There is no way of “easily” determining the the day number of the current year to be able to “easily” get to a unit of seconds. I would have to figure out what month it is, and then count, in a very specific way, to determine which day (0-364) it is. No? Am I missing something?

        • If your application is constantly active, you could optimize it by only changing the seconds when values change.

  • There is something wrong with the newest version of the arduino ide (0022) and this example code. It calls the ReadTimeDate() one time and outputs it to the serial monitor as expected and it never calls it again. I don’t have enough expertise to understand what is going wrong. I suggest someone with more know-how try compiling the example code in 0022 and note the results. I downgraded to 0021 in order to get this working. I don’t know if the problem is a bug in the 0022 IDE or the code provided here. I would be curious to know if anyone gets it working in 0022, I haven’t ruled out that the problem is exclusive to me/my system.

    • I had the same problem and did what you said, used 0021 and it works fine now.
      Although, the original sketch worked for me. I had problems when changing the numbers sent with the SetTimeDate function. Sometimes it would output the ReadTimeDate correctly until it got to a certain time and would lock up.

  • does the library work with the alarm?

  • Someone can tell me what is going wrong.
    I have used the DS1307 Engine for the propeller and now my dates don’t work correctly. It uses impossible dates like september 31 and then jumps to october 2 the next day. ?
    Any help is very appreciated !

  • Is there any way to make this work with a different coin cell battery? Because I don’t have a CR1225…
    I have 3x G8-A's
    I have 9x 357's
    I have 5x CR2032’s

  • Hello All
    I finally got this guy working. Ref http://www.l8ter.com/?p=375
    for wiring and use the Example sketch.
    Very weird. First the problem seemed to be the jumper wires I was using between my Uno and the breadboard were picking up “noise” – one wire in particular seemd to be most sensitive – the LOW tie down on the SQW pin – when I used a shorter wire it appeared to work ok but after 20 secs or so the output would appear to get corrupted and fix it self agian after another 20secs – I set SPI.setDataMode(SPI_MODE3) and it seemd to stabilze the o/p
    Good Luck

  • Must use 3.3v VCC, instead of 5.0v VCC used in the above Example Sketch, otherwise square wave output doesn’t work.
    Must use SPI_MODE3, instead of Mode 1, otherwise one line correct time, followed by one line 00/00….

  • PacMan reference in image 4!

  • I had been using a DS1307, but the timekeeping was not as good as I had hoped. The DS1307 can easily drift by a minute a week. The DS3234 has, so far, stayed within 1 second per week. If you are data logging, I highly recommend the DS3234 over the DS1307. Check out openlog as well if you are into data collection. Openlog makes saving data very simple. The DS3234 makes the time that data is saved very accurate.

  • Hey All —

    I got my DS3234 working, in that I can set the time and read the time, however, the battery back up does not appear to be working. I’ve got it hooked up to an arduino uno and when I remove the unos power and let the chip sit for, say, 24 hours the time is no longer correct.

    I’ve got a CR1225 battery that reads 2.9 V

    Here is how I’ve got it wired:

    *gnd –> gnd

    *vcc –> 3v

    *sqw –> gnd

    *clk –> pin13

    *miso –> pin12

    *mosi –> pin11

    *ss –> A0

    Any thoughts?

    • EOSC bit was set to 1, please read page 10 and 12 of DS3234 datasheet.

      You can alter EOSC bit by sending command to address 8Eh something like this:

      digitalWrite(cs, LOW); SPI.transfer(8Eh); SPI.transfer(00011100b);
      digitalWrite(cs, HIGH);

  • Working fine on mega2560: RTClib.cpp needed <arduino.h> replaced with <Arduino.h>

    50 (MISO), 51 (MOSI), 52 (CLK), 53 (SS), GND & SQK grounded, VCC to +5

    include <Wire.h>

    include <SPI.h>

    include <RTClib.h>

    include <RTC_DS3234.h>

    RTC_DS3234 RTC(53);

    void setup(){

    SPI.begin();

    RTC.begin();

    RTC.adjust(DateTime(DATE, TIME));

    SPI.setDataMode(SPI_MODE0);

    Serial.begin(9600);

    }

    void loop(){

    const int len = 32;
    static char buf[len];
    DateTime now = RTC.now();
    Serial.println(now.toString(buf,len));
    delay(1000);
    

    }