Real time clock on the arduino ZERO

Hello I’m still learning how to use the arduino zero /m0 pro and i pretty much got all my stuff for my project working on it but one thing i can not get to compile is the RTC3232 real time clock module I’m getting errors from it. I guess it’s not compatible with the 32bit processor on it and i need help the library is loaded below and i’ll try to post the sketch in here.

/*
 * TimeRTC.pde
 * Example code illustrating Time library with Real Time Clock.
 * This example is identical to the example provided with the Time Library,
 * only the #include statement has been changed to include the DS3232RTC library.
 */

#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time  
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)

void setup(void)
{
    Serial.begin(9600);
    setSyncProvider(RTC.get);   // the function to get the time from the RTC
    if(timeStatus() != timeSet) 
        Serial.println("Unable to sync with the RTC");
    else
        Serial.println("RTC has set the system time");      
}

void loop(void)
{
    digitalClockDisplay();  
    delay(1000);
}

void digitalClockDisplay(void)
{
    // 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(); 
}

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

can someone please help me out?

This is the error I’m getting

Arduino: 1.7.6 (Windows 7), Board: "Arduino M0"

In file included from TimeRTC.ino:8:0:

C:\Users\Big Bleu\Documents\Arduino\libraries\DS3232RTC/DS3232RTC.h:136:26: error: 'tmElements_t' has not been declared

         static byte read(tmElements_t &tm);

                          ^

C:\Users\Big Bleu\Documents\Arduino\libraries\DS3232RTC/DS3232RTC.h:137:20: error: 'tmElements_t' has not been declared

         byte write(tmElements_t &tm);

                    ^

In file included from C:\Users\Big Bleu\Desktop\arduino-1.7.6/hardware/tools/CMSIS/Device/ATMEL/samd21/include/samd21.h:47:0,

                 from C:\Users\Big Bleu\Desktop\arduino-1.7.6/hardware/tools/CMSIS/Device/ATMEL/samd.h:79,

                 from C:\Users\Big Bleu\Desktop\arduino-1.7.6/hardware/tools/CMSIS/Device/ATMEL/sam.h:603,

                 from C:\Users\Big Bleu\Desktop\arduino-1.7.6\hardware\arduino\samd\cores\arduino/Arduino.h:42,

                 from C:\Users\Big Bleu\Documents\Arduino\libraries\DS3232RTC/DS3232RTC.h:43,

                 from TimeRTC.ino:8:

C:\Users\Big Bleu\Desktop\arduino-1.7.6/hardware/tools/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:478:38: error: expected ')' before '*' token

 #define RTC               ((Rtc      *)0x40001400U) /**< \brief (RTC) APB Base Address */

                                      ^

C:\Users\Big Bleu\Documents\Arduino\libraries\DS3232RTC/DS3232RTC.h:155:18: note: in expansion of macro 'RTC'

 extern DS3232RTC RTC;

                  ^

C:\Users\Big Bleu\Desktop\arduino-1.7.6/hardware/tools/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:478:38: error: expected ')' before '*' token

 #define RTC               ((Rtc      *)0x40001400U) /**< \brief (RTC) APB Base Address */

                                      ^

C:\Users\Big Bleu\Documents\Arduino\libraries\DS3232RTC/DS3232RTC.h:155:18: note: in expansion of macro 'RTC'

 extern DS3232RTC RTC;

                  ^

TimeRTC.ino: In function 'void setup()':

TimeRTC.ino:15:25: error: request for member 'get' in '1073746944u', which is of pointer type 'Rtc*' (maybe you meant to use '->' ?)

TimeRTC.ino:15:28: error: 'setSyncProvider' was not declared in this scope

TimeRTC.ino:16:19: error: 'timeStatus' was not declared in this scope

TimeRTC.ino:16:24: error: 'timeSet' was not declared in this scope

TimeRTC.ino: In function 'void digitalClockDisplay()':

TimeRTC.ino:31:23: error: 'hour' was not declared in this scope

TimeRTC.ino:32:24: error: 'minute' was not declared in this scope

TimeRTC.ino:33:24: error: 'second' was not declared in this scope

TimeRTC.ino:35:22: error: 'day' was not declared in this scope

TimeRTC.ino:37:24: error: 'month' was not declared in this scope

TimeRTC.ino:39:23: error: 'year' was not declared in this scope

Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

I think you need to use the following library to provide support for the RTC on the ZERO
https://github.com/MarkusLange/RTCZero

What’s the point of having a RTC in board if hasn’t any holder to (at least) connect a coin cell??

Did you finally solve this compilation error?, how did you do it?

Hi Osqui,

You're right: the board should be powered at all times to prevent the RTC from resetting its time.

This is quite simple to realize, though...

As The reference Arduino - RTC states: "A button sized lithium battery or any battery in the 3V range, connected through a diode to the 3.3V pin, is enough to keep RTC alive if the CPU is put in sleep mode before the standard USB or VIN power is disconnected"

As basic boards like Uno are consuming too much power during sleep, it's quite useless to keep them powered from a coincell or even a small Lipo to do datalogging over more than jus a few days.
But for M0 processors like Zero and my favourite Feather M0-boards from Adafruit, it's really worth soldering a coincell holder on a shield. Feather-boards have the cool advantage of being powered all time through the optional (but unmissable) Lipo at their onboard JST-connector.

The RTCZero library is really the unmissable solution !

Hello i know this is a old post of mine and sorry i haven't updated it. that is because a family member at the time passed away and i had a lot to do with other family members getting his house together for sale and clean up. But i just wanted to update this post with a new comment and say i did forget about this RTC project and i didn't realize it into actually a day ago when i was reading old Post of mine.

So my plan is to make this onboard RTC clock with no external RTC modules. because i have been working on a project recently that requires a RTC module i will be adding this to that project and giving a update in this post.

again sorry. I was reading over the comment that q2dg made. And i found out is that I can put the zero board to sleep and still have the Onboard clock RTC still run it only takes micro amps which is nothing if you are running coin cells. or some type of lipo battery. Now the zero chip which is the D21 chip only takes a min of 8ma to run or less. So running this board and the clock i think in my opinion maybe i'm wrong but should be okay. However running a Zero board fully you have Led's that take power, Programming chip the Debugging chip that takes power even if not doing anything. I'm just talking about the D21 chip it's self which only takes very little power to run.

I'm going to again run this RTC later today my time and see how the clock works and run it on batteries then see how long it would last. Now here is the other side of things. I didn't say anything about LCD's or Oleds which takes a lot more power. But I'm going to run a Nokia5110 screen for test. Becuase i found out even in sleep mode of the zero board the Nokia screen can keep it's information on the screen and take very little to no power to display it's information. I will be disabling the Leds on the nokia screen to save more power.

I hope everything should be okay. Take care and i'll be posting a update on this screen.