RTCzero library problem

Hi, problems I have encountered are more than one. Hardware, to use the internal clock which could also be convenient but forces to keep the 3.3 volt line powered with a buffer battery + diode powered by the whole circuit to which it gives power to sensors, various hardware and therefore with high battery consumption. As if that were not enough it seems inaccurate (he lost about ten minutes in a day), if I try to return to the external i2c card with ds1307 it doesn't work, with the ds3231 it does not compile the IDE 2.0. How do I solve the problem?

Hi @kangoo59. Which Arduino board are you using?

You mention the RTCZero library, but you also mention external RTC components. This is confusing to me because the RTCZero library uses the internal RTC peripheral in the ATSAMD21G18 microcontroller used by boards like the Arduino Zero, MKR boards, and Nano 33 IoT.

I'm going to ask you to post some additional information that might help us to identify the problem.


:exclamation: NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.


Please do this:

  1. There should be an error notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  2. Open a forum reply here by clicking the Reply button.
  3. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  4. Press Ctrl+V.
    This will paste the compilation output into the code block.
  5. Move the cursor outside of the code tags before you add any additional text to your reply.
  6. Click the Reply button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the Reply button.
  5. Click the "Upload" icon (image) on the post composer toolbar:
    image
  6. Select the .txt file you saved.
  7. Click the Open button.
  8. Click the Reply button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:16:8: error: 'DS3231 clock' redeclared as different kind of symbol
 DS3231 clock;
        ^~~~~
In file included from c:\users\franco\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdlib.h:11:0,
                 from c:\users\franco\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\c++\7.2.1\cstdlib:75,
                 from c:\users\franco\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\c++\7.2.1\stdlib.h:36,
                 from C:\Users\franco\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.13\cores\arduino/api/Interrupts.h:5,
                 from C:\Users\franco\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.13\cores\arduino/api/ArduinoAPI.h:29,
                 from C:\Users\franco\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.13\cores\arduino/Arduino.h:23,
                 from C:\Users\franco\AppData\Local\Temp\arduino-sketch-7A8AE8FCA36A24FDE6E6D557A07D2CA7\sketch\DS3231_test.pde.cpp:1:
c:\users\franco\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\time.h:56:12: note: previous declaration 'clock_t clock()'
 clock_t    _EXFUN(clock,    (void));
            ^
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde: In function 'void loop()':
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:41:21: error: request for member 'getYear' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getYear(), DEC);
                     ^~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:45:21: error: request for member 'getMonth' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getMonth(century), DEC);
                     ^~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:49:21: error: request for member 'getDate' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getDate(), DEC);
                     ^~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:53:21: error: request for member 'getDoW' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getDoW(), DEC);
                     ^~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:57:21: error: request for member 'getHour' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getHour(h12Flag, pmFlag), DEC);
                     ^~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:59:21: error: request for member 'getMinute' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getMinute(), DEC);
                     ^~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:61:21: error: request for member 'getSecond' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getSecond(), DEC);
                     ^~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:76:21: error: request for member 'getTemperature' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  Serial.print(clock.getTemperature(), 2);
                     ^~~~~~~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:79:12: error: request for member 'oscillatorCheck' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  if (clock.oscillatorCheck()) {
            ^~~~~~~~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:86:12: error: request for member 'checkIfAlarm' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  if (clock.checkIfAlarm(1)) {
            ^~~~~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:90:12: error: request for member 'checkIfAlarm' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  if (clock.checkIfAlarm(2)) {
            ^~~~~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:99:8: error: request for member 'getA1Time' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  clock.getA1Time(alarmDay, alarmHour, alarmMinute, alarmSecond, alarmBits, alarmDy, alarmH12Flag, alarmPmFlag);
        ^~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:120:12: error: request for member 'checkAlarmEnabled' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  if (clock.checkAlarmEnabled(1)) {
            ^~~~~~~~~~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:127:8: error: request for member 'getA2Time' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  clock.getA2Time(alarmDay, alarmHour, alarmMinute, alarmBits, alarmDy, alarmH12Flag, alarmPmFlag);
        ^~~~~~~~~
C:\Users\franco\Downloads\DS3231-1.1.0\DS3231-1.1.0\examples\DS3231_test\DS3231_test.pde:146:12: error: request for member 'checkAlarmEnabled' in 'clock', which is of non-class type 'clock_t() {aka long unsigned int()}'
  if (clock.checkAlarmEnabled(2)) {
            ^~~~~~~~~~~~~~~~~

exit status 1

Compilation error: 'DS3231 clock' redeclared as different kind of symbol

My board is Arduino nano IOT 33

DS1307 from example, on this board serial do nothing, other Arduino UNO perfect.
DS3231 compilation error IDE 2.0

The cause of the error is a name collision between the clock object created at line 16 of the example sketch:

 DS3231 clock;

and another occurrence of the clock name in the toolchain of the Nano 33 IoT board.

The solution is to give the clock object in the sketch a unique name like DS3231clock:

 DS3231 DS3231clock;

Make sure to also update all the references to that name in your sketch to use the new name.

you have to excuse me but translation fault or not practical, I did not understand how I can solve.
I have to substitute "DS3231clock" for what? and where ?

/*
DS3231_test.pde
Eric Ayars
4/11

Test/demo of read routines for a DS3231 RTC.

Turn on the serial monitor after loading this to check if things are
working as they should.

*/

#include <DS3231.h>
#include <Wire.h>

DS3231 clock;
bool century = false;
bool h12Flag;
bool pmFlag;
byte alarmDay, alarmHour, alarmMinute, alarmSecond, alarmBits;
bool alarmDy, alarmH12Flag, alarmPmFlag;

void setup() {
	// Start the I2C interface
	Wire.begin();
 
	// Start the serial interface
	Serial.begin(57600);
}

void loop() {
	// send what's going on to the serial monitor.
	
	// Start with the year
	Serial.print("2");
	if (century) {			// Won't need this for 89 years.
		Serial.print("1");
	} else {
		Serial.print("0");
	}
	Serial.print(clock.getYear(), DEC);
	Serial.print(' ');
	
	// then the month
	Serial.print(clock.getMonth(century), DEC);
	Serial.print(" ");
  
	// then the date
	Serial.print(clock.getDate(), DEC);
	Serial.print(" ");
  
	// and the day of the week
	Serial.print(clock.getDoW(), DEC);
	Serial.print(" ");
  
	// Finally the hour, minute, and second
	Serial.print(clock.getHour(h12Flag, pmFlag), DEC);
	Serial.print(" ");
	Serial.print(clock.getMinute(), DEC);
	Serial.print(" ");
	Serial.print(clock.getSecond(), DEC);
 
	// Add AM/PM indicator
	if (h12Flag) {
		if (pmFlag) {
			Serial.print(" PM ");
		} else {
			Serial.print(" AM ");
		}
	} else {
		Serial.print(" 24h ");
	}
 
	// Display the temperature
	Serial.print("T=");
	Serial.print(clock.getTemperature(), 2);
  
	// Tell whether the time is (likely to be) valid
	if (clock.oscillatorCheck()) {
		Serial.print(" O+");
	} else {
		Serial.print(" O-");
	}
 
	// Indicate whether an alarm went off
	if (clock.checkIfAlarm(1)) {
		Serial.print(" A1!");
	}
 
	if (clock.checkIfAlarm(2)) {
		Serial.print(" A2!");
	}
 
	// New line on display
	Serial.println();
	
	// Display Alarm 1 information
	Serial.print("Alarm 1: ");
	clock.getA1Time(alarmDay, alarmHour, alarmMinute, alarmSecond, alarmBits, alarmDy, alarmH12Flag, alarmPmFlag);
	Serial.print(alarmDay, DEC);
	if (alarmDy) {
		Serial.print(" DoW");
	} else {
		Serial.print(" Date");
	}
	Serial.print(' ');
	Serial.print(alarmHour, DEC);
	Serial.print(' ');
	Serial.print(alarmMinute, DEC);
	Serial.print(' ');
	Serial.print(alarmSecond, DEC);
	Serial.print(' ');
	if (alarmH12Flag) {
		if (alarmPmFlag) {
			Serial.print("pm ");
		} else {
			Serial.print("am ");
		}
	}
	if (clock.checkAlarmEnabled(1)) {
		Serial.print("enabled");
	}
	Serial.println();
 
	// Display Alarm 2 information
	Serial.print("Alarm 2: ");
	clock.getA2Time(alarmDay, alarmHour, alarmMinute, alarmBits, alarmDy, alarmH12Flag, alarmPmFlag);
	Serial.print(alarmDay, DEC);
	if (alarmDy) {
		Serial.print(" DoW");
	} else {
		Serial.print(" Date");
	}
	Serial.print(" ");
	Serial.print(alarmHour, DEC);
	Serial.print(" ");
	Serial.print(alarmMinute, DEC);
	Serial.print(" ");
	if (alarmH12Flag) {
		if (alarmPmFlag) {
			Serial.print("pm");
		} else {
			Serial.print("am");
		}
	}
	if (clock.checkAlarmEnabled(2)) {
		Serial.print("enabled");
	}
 
	// display alarm bits
  Serial.println();
	Serial.print("Alarm bits: ");
	Serial.println(alarmBits, BIN);

	Serial.println();
	delay(1000);
}

Change this line:

To this:

DS3231 DS3231clock;

Now you must go through your sketch and update all the references to clock. For example:

Change this line:

To this:

	Serial.print(DS3231clock.getYear(), DEC);

Ok thank you

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.