While trying to get the DS3234 work together with SD card on the ethernet shield, I have faced a problem. SD uses Mode0 of the SPI while DS3234 needs either Mode1 or Mode3. To get around the problem with a single hardware SPI on Arduio boards, I have decided to try to develop a software SPI interface for the real time clock. The library is fully functional and it allows to do the basic reading and setting the date and time, as well as it allows to read the temperature value from the temperature sensor built in the DS3234. Alarms functionality is not yet added but it will be availeble soon. I have tested the library with Arduino Duemilianowe and Mega 2560 and it works flawlessly together with ethernet shield and SD card reader.
The library can be downloaded from here.
After downloading simply unzip the library to the library folder of your arduino installation (by default it is in C:\arduino-1.0.3\libraries on windows machines).
To use the library you need to include it by placing the following line at the begining of your sketch:
Before you use the functions to read/set time or read the temperatre, you need to tell the library to which pins you have connected the RTC. To do that simply use:
where the CLKpin is often called clock pin or SCK. CSpin might be marked on the board as SS. If for any reason the pin assignemnt would change during execution of the program, you may change the pin assignment by using the function at any time. However in probably all the cases you want to use this function only once in the setup part of the program. When the library is initialized you can use the following functions:
after using this function, the indyvidual value are stored in internal variables which you can also read as integers using the functions:
Note that to update the results of the above functions you need to call the readDateTime(), otherwise you will only read the values saved by the last usage of readDateTime().
Serial.println(String("Current date/time: ")+RTC.readDateTime());