ok so im trying to integrate a DS3234 into my project, using a mega 2560 with an ITDB02-5 and I missing something in the set up. using a DS3234 library that I will link bellow. but here is the section of code…

#include <UTouch.h>
#include <avr/pgmspace.h>
#include <UTFT.h>
#include <tinyFAT.h>
#include <UTFT_tinyFAT.h>
#include <EEPROM.h>
#include <RTClib.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <DS3234.h>

//********    Declare Touch/LCD/RTC    **********
UTFT  myGLCD(ITDB50, 38, 39, 40, 41);   //sets LCD pins - change to your screen pin-out and aspect
UTouch  myTouch(6,5,4,3,2);            //sets touch pins - change to your set up (default is usually 6,5,4,3,2)
UTFT_tinyFAT myFiles(&myGLCD);
DS3234 RTC(8);
//********   Call Fonts    **********
extern uint8_t arial_bold[];
extern uint8_t Sinclair_S[];
extern uint8_t SevenSegmentFull[];

void Draw_Clock(int clock_x, int clock_y){
  DateTime now = rtc.getTimeStr();
  Hours = now.hour();
  Minutes = now.minute();
  Seconds = now.second();
  Day = now.day();
  Month = now.month();
  Year = now.year();
  Weekday = now.dayOfWeek();
  Current_time = (Hours +  ":"  + Minutes);                             

and the error for that section

.ino: In function 'void Draw_Clock(int, int)':
.ino:864:18: error: 'rtc' was not declared in this scope

DS3234.cpp (8.96 KB)

DS3234.h (2.8 KB)

Or is there an easier way / better lib to use?

Hi, Please post your complete code. Have you tried to write a code just using the DS3234 and serail terminal to debug?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom.... :)

the whole code is to big to post, ill see if I can attach. ok its there. and right now the circuit is fairly simple. the itdb02-5 is on the mega with a mega shield from itead. the ds3234 is as follows…
mosi - pin 51
moso - pin 50
sclk - pin 52
ss - pin 8
vcc - 5v
ground and sqw are grounded

AquaPorn.ino (124 KB)

If this is your object instantiation,

DS3234 RTC(8);

then it should be in lower case to match

  DateTime now = rtc.getTimeStr();

K I matched it so now its DateTime = RTC.getTimeStr(); and this is the new error code for that line

Arduino: 1.6.1 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

AquaPorn.ino: In function 'void Draw_Clock(int, int)':

AquaPorn.ino:864:33: error: invalid conversion from 'char*' to 'uint32_t {aka long unsigned int}' [-fpermissive]

In file included from AquaPorn.ino:34:0:

C:\Program Files (x86)\Arduino\libraries\RTClib/RTClib.h:7:5: error: initializing argument 1 of 'DateTime::DateTime(uint32_t)' [-fpermissive]

DateTime (uint32_t t =0);

Well, that is a straightforward type mismatch, so look at the method’s return type and what type you are assigning it to. Actually, not just the type, but what it “is”.

Im sorry but I don't understand...

jlyman28: Im sorry but I don't understand...

does rtc.getTimeStr() return a DateTime data type? Look at the documentation and/or function prototype.

My understanding was that it gets the time from the rtc and stores it as a string

jlyman28: My understanding was that it gets the time from the rtc and stores it as a string

Then why are you expecting it to return a DateTime type? Because, that is what type you are making the variable "now". If you want a string, make "now" a string type.

I did have it as DateTime now = RTC.now();

And the error showed up saying now is not defined. Sorry I can't post actual error for that one I'm on my phone at the moment.

Ok so on a reconsideration I decided to take a step back and just try to get this to work on its own and receive either garbage...all zeros for time and date or random numbers that don't work. Anyone have a reliable library with example sketch to load the time?

Here is one that I downloaded and used. I didn't need to make any changes to it.

thanks that work great, its keeping track of the time now, just need to set the correct time and date lol

FWIW, instead of including Hennings library as attachments in post 1, you could just have said, using this library http://www.rinkydinkelectronics.com/library.php?id=71.

Doing it this way, in 6 months time when somebody else has the same problem you did, they will always be downloading the LATEST version from Henning, not the outdated version you attached.



I have tried may libraries and Im not sure what im doing wrong. I cant get the time to load on to this thing. the code I just tried is

#include <Time.h>  
#include <DS3234.h>

//This section retrieves the system time (unix) in a more manageable h,m,s... format

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by Unix time_t as ten ASCII digits
#define TIME_HEADER  'T'   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message 

// T1262347200  //noon Jan 1 2010

void setup()  {

void loop(){    
  if(Serial.available() ) 
  if(timeStatus() == timeNotSet) 
    Serial.println("waiting for sync message");

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  if(digits < 10)

void processSyncMessage() {
  // if time sync available from serial port, update time and return true
  while(Serial.available() >=  TIME_MSG_LEN ){  // time message consists of header & 10 ASCII digits
    char c = Serial.read() ; 
    if( c == TIME_HEADER ) {       
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){   
        c = Serial.read();          
        if( c >= '0' && c <= '9'){   
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
      setTime(pctime);   // Sync Arduino clock to the time received on the serial port

/* Then the user needs to open terminal and run the following command:

  sudo echo "T$(($(date +%s)+60*60-5))" >/dev/tty.usbmodem1421

where -5 is the time zone adjustment from GMT and tty.usbmodem1421 is your serial port

/* This was the original way to manually set the RTC time:


how ever all I get back in the serial moniter is waiting for sync message. for some reason it looks like im not talking to the rtc.

In the serial monitor, you need to send T1428167490 which is approximately about now.

Regardless of if you are ACTUALLY talking to the RTC, the sync message should go away once you send a string like the one suggested.



this is confusing the hell out of me...that code did work and message went away, date was right but was 4 hours ahead of time. then running a different sketch the time was no longer there. I installed the above library you linked to and ran the sample sketch for easy and get this

xxxxxxxxx 00.00.200 -- 00:00:00 -- Internal temp: 0.00c

4hours ahead means you are not in the UK !! :P

just remove (4*60*60) from the number.....

But down to the ACTUAL problem you are having...... Do you have a battery connected to your module?

What I would suggest is change the time print routine to explicitly use the rtc components of time.


void digitalClockDisplay(){
  // digital clock display of the time
//  Serial.print(hour());
//  printDigits(minute());
//  printDigits(second());
//  Serial.print(" ");
//  Serial.print(day());
//  Serial.print(" ");
//  Serial.print(month());
//  Serial.print(" ");
//  Serial.print(year()); 
//  Serial.println(); 

I am thinking you have 'borrowed' the DS1307 set time example, and substituted DS3234.h in the include?? ;) I am not sure the syntax are the same.

But let me know what happens with this? Also, is there any chance you crossed your miso/mosi wires? Or might I suggest you do. We WILL fix this, I have no doubt ;)