Interfacing with an RTC 3234

Hello all,
New to Arduino and electronics in general. Looking for some help figuring out how to get my shiny new RTC to work with my arduino (have a mega 2560).

Product: http://www.sparkfun.com/products/10160

Datasheet: http://www.sparkfun.com/datasheets/BreakoutBoards/DS3234.pdf

I have already made a simple project which uses the Time library to display a coloured LED depending on the time of day and the season. But since I have to hardcode the starting date it is not ideal.

So I bought this RTC without knowing much about them. I’ve tried to follow the sample code but I cannot even figure out how to attach it to my Arduino! (I know Im a big noob). Could someone give me a hand in figuring out how to do this?

It has 7 connectors:
GND - ground
VCC – voltage??
SQW – square wave??
CLK – clock??
MISO – master in, slave out
MOSI – master out, slave in
SS – slave selector

Ive learned some things about SPI but still am shaky on how that even works.

Any help you could provide would be greatly appreciated!

Thanks!

I haven't worked with this chip yet, but can tell you something about the used pins.

VCC should be connected to the +5volt connection on your arduino to power the RTC-chip.
CLK is the same as SCK pin, on the DS-board Clock is abbreviated to CLK, my best guess is Serial ClocK is Atmels/arduinos abbreviation, SCLK is sometimes also used, but they're all the same. When talking about time, Arduino uses it to signal the chip that it's time to send/receive the next bit of info, it's not related to time in hours/minutes/seconds.

The SQW-connector probably isn't very important to get started, it doesn't need to be connected.
You can do several things with it though.The 3234 can be programmed with 2 alarms in which case the pin responds, but
It can also be used to generate 4 different frequencies. You could program alarms on the arduino or have it generate a frequency, but the pin could be useful if you wanted to perform a task at a certain time without having an clock-routine running on the arduino.

Thanks for the reply Simpson_Jr!

I took your advice and wired the component as suggested in the RTClib library that I am using. Using 8 on my arduino as the slave selector.
Its making more sense how the SPI actually works, using the "clock" to regulate bits.

However, the RTC does not appear to be functioning as the test function outputs 00:00:00. Not sure what I can do to debug this as the circuit is quite simple.

Any ideas what could be wrong?

Any ideas what could be wrong?

How about you post the code and a schematic of you can.


Rob

Thanks for the reply Rob.

I tried using the example code from the sparkfun website found here
http://www.sparkfun.com/datasheets/BreakoutBoards/DS3234_Example_Code.c

Then I tried a library written specifically for this and other RTCs. That is found here:

I am unsure how to create a schematic but the wiring is quite simple

Connections on the board -> Arduino
GND -> Ground on Arduino
VCC -> 5V connector on arduino
SQW -> not used
CLK -> 12 on arduino (PWM)
MISO ->11 on arduino
MOSI -> 10 on ardunio
SS -> 8 on arduino (defined in code)

Hopefully someone can help me :frowning:

Where did you get the Arduino pins numbers from?

On 2009 it's

CLK -> 13
MISO -> 12
MOSI -> 11

On 2560

CLK -> 52
MISO -> 50
MOSI -> 51

Although in both cases you can get the signals from the ISP header as well.


Rob

Thanks Rob!

This pin configuration worked perfectly!
CLK -> 52
MISO -> 50
MOSI -> 51

Youre the man! :slight_smile:

Something more in the lines of DS1307 would be a more accurate choice; wasting 8 pins only for the RTC.. well.

Well it's only 3 pins for comms and the 1307 uses 2, so that's only 1 extra signal.

Also the 3234 has a TCXO and it is way more accurate than the 1307 which is not known for it's accuracy.


Rob

Thanks all for their feedback.
Got my project up and running and it works well when plugged into the USB port.
However, when I plug the 9V connector into battery port the device just flickers and turns off after a few seconds.
These are fresh batteries.

The device just lights one LED based on the time.