Errors with DS3231 Libraries

I have read all the posts here and found a lot of usefull stuff. I am using IDE 1.0.1 on a Modern Devices RBBB.
However, I still can't get any of the DS3231 examples to compile and run. I keep getting the following errors;

ds3231_set:128: error: redefinition of 'DS3231 Clock'
ds3231_set:14: error: 'DS3231 Clock' previously declared here
ds3231_set:130: error: redefinition of 'byte Year'
ds3231_set:16: error: 'byte Year' previously declared here
ds3231_set:131: error: redefinition of 'byte Month'
ds3231_set:17: error: 'byte Month' previously declared here
ds3231_set:132: error: redefinition of 'byte Date'
ds3231_set:18: error: 'byte Date' previously declared here
ds3231_set:133: error: redefinition of 'byte DoW'
ds3231_set:19: error: 'byte DoW' previously declared here
ds3231_set:134: error: redefinition of 'byte Hour'
ds3231_set:20: error: 'byte Hour' previously declared here
ds3231_set:135: error: redefinition of 'byte Minute'
ds3231_set:21: error: 'byte Minute' previously declared here
ds3231_set:136: error: redefinition of 'byte Second'
ds3231_set:22: error: 'byte Second' previously declared here
DS3231_set.cpp: In function 'void GetDateStuff(byte&, byte&, byte&, byte&, byte&, byte&, byte&)':
ds3231_set:139: error: redefinition of 'void GetDateStuff(byte&, byte&, byte&, byte&, byte&, byte&, byte&)'
ds3231_set:25: error: 'void GetDateStuff(byte&, byte&, byte&, byte&, byte&, byte&, byte&)' previously defined here
DS3231_set.cpp: In function 'void setup()':
ds3231_set:188: error: redefinition of 'void setup()'
ds3231_set:74: error: 'void setup()' previously defined here
DS3231_set.cpp: In function 'void loop()':
ds3231_set:196: error: redefinition of 'void loop()'
ds3231_set:82: error: 'void loop()' previously defined here

Would appreciate any help..........Thanks

Looks like the sketch contains everything twice. Perhaps if you showed your sketch it would be easier to figure out what's wrong.

Sure, it's the example sketch from the DS3231 Library

/*
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 h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;

byte year, month, date, DoW, hour, minute, second;

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(h12, PM), DEC);
	Serial.print(' ');
	Serial.print(Clock.getMinute(), DEC);
	Serial.print(' ');
	Serial.print(Clock.getSecond(), DEC);
	// Add AM/PM indicator
	if (h12) {
		if (PM) {
			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.print('\n');
	// Display Alarm 1 information
	Serial.print("Alarm 1: ");
	Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);
	Serial.print(ADay, DEC);
	if (ADy) {
		Serial.print(" DoW");
	} else {
		Serial.print(" Date");
	}
	Serial.print(' ');
	Serial.print(AHour, DEC);
	Serial.print(' ');
	Serial.print(AMinute, DEC);
	Serial.print(' ');
	Serial.print(ASecond, DEC);
	Serial.print(' ');
	if (A12h) {
		if (Apm) {
			Serial.print('pm ');
		} else {
			Serial.print('am ');
		}
	}
	if (Clock.checkAlarmEnabled(1)) {
		Serial.print("enabled");
	}
	Serial.print('\n');
	// Display Alarm 2 information
	Serial.print("Alarm 2: ");
	Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);
	Serial.print(ADay, DEC);
	if (ADy) {
		Serial.print(" DoW");
	} else {
		Serial.print(" Date");
	}
	Serial.print(' ');
	Serial.print(AHour, DEC);
	Serial.print(' ');
	Serial.print(AMinute, DEC);
	Serial.print(' ');
	if (A12h) {
		if (Apm) {
			Serial.print('pm');
		} else {
			Serial.print('am');
		}
	}
	if (Clock.checkAlarmEnabled(2)) {
		Serial.print("enabled");
	}
	/* display alarm bits
	Serial.print('\n');
	Serial.print('Alarm bits: ');
	Serial.print(ABits, DEC);
	*/

	Serial.print('\n');
	Serial.print('\n');
	delay(1000);

	// Display the time once more as a test of the getTime() function
	Clock.getTime(year, month, date, DoW, hour, minute, second);
	
        Serial.print(year, DEC);
        Serial.print("/");
	Serial.print(month, DEC);
        Serial.print("/");
	Serial.print(date, DEC);
        Serial.print("day of the week :");
	Serial.println(DoW, DEC);
	Serial.print(hour, DEC);
        Serial.print(":");
	Serial.print(minute, DEC);
        Serial.print(":");
	Serial.println(second, DEC);
}

Which library? Does it contain both PDE and INO example sketches? Do you have two tabs showing in the IDE?

It's the DS3231 Library, and the examples are in .pde ..................

It's the DS3231 Library

Which you got from where?

From the Eric Ayers Web site. Hardware Hacks: DS3231 Real-Time Clock

It compiles ok under IDE 023. The library, as downloaded, isn't compatible with 1.0+. What changes have you made?

I haven't made any changes! I tried all 3 examples included with the download, and get numerous errors each time.

Well, that library isn't compatible with IDE 1.0 or later. You have a number of options.

  1. Use a different library that is compatible.
  2. Contact the author, and see if they will update it.
  3. Update it yourself.

For some reason, the 'WProgram.h missing' error that you get if you try a to compile this under 1.0 is hidden under 1.0.1.

Hi,

Is this link helpful?
http://arduino.cc/forum/index.php/topic,57642.0.html
Ric

Tried all those tips and still no joy!

Then try a different library. arduino ds3231 library - Google Search

This now compiles ok under 1.0.1

DS3231.zip (9.29 KB)

To fix the Eric Ayers DS3231 library:

In DS3231.h:
Change <Wprogram.h> to <Arduino.h>

In DS3231.cpp:
Replace all "Wire.send" with "Wire.write".
Replace all "Wire.receive" with "Wire.read".

After that the DS3231_test example compiles without error.

Thanks to all, I finally got my code to run, with IDE0023.............

heffnerm:
Thanks to all, I finally got my code to run, with IDE0023.............

I'm confused now (something that can easily happen :D) as I thought you wanted the library to compile and work under 1.0.1 as it was originally written for 0.23