I can't get the DS3231 library to work...

I tried out this code (from this website):

#include <DS3231.h>
DS3231  rtc(SDA, SCL);

void setup(){  
  rtc.begin();
  rtc.setDOW(WEDNESDAY);     
  rtc.setTime(12, 0, 0);     
  rtc.setDate(1, 1, 2014);

  Serial.begin(9600);
  rtc.begin();  
  pinMode(lm35_pin, INPUT);
  pinMode(chip_select_pin, OUTPUT);
  if (SD.begin()){
    Serial.println("Initialization Successful. Ready to use");
  } 
  else{
    Serial.println("Initialization failed. Check your pin connections or change your SD card");
    return;
  }  
}

#include <SD.h>
#include <SPI.h>
#include <DS3231.h>

File data_file;
DS3231  rtc(SDA, SCL);

const int lm35_pin = A0; 
int temperature;  
int chip_select_pin = 10;

void loop() {
  temperature = analogRead(lm35_pin);
  temperature = (temperature*500)/1023;
  data_file = SD.open("test.txt", FILE_WRITE);
  if (data_file) {    
    Serial.print(rtc.getTimeStr());
    data_file.print(rtc.getTimeStr());
    Serial.print(",");
    data_file.print(",");    
    Serial.println(temperature);
    data_file.println(temperature);
    data_file.close();
  }
  else {
    Serial.println("error opening your SD card file. Try again");
  }
  delay(3000);
}

and got these error messages:

Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Uno"

WARNING: Category 'Real-time clock' in library DS3231 is not valid. Setting to 'Uncategorized'
sketch_dec19a:2: error: no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'

 DS3231  rtc(SDA, SCL);
                     ^

C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino:2:21: note: candidates are:

In file included from C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino:1:0:

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:64:3: note: DS3231::DS3231()

   DS3231();

   ^

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:64:3: note:   candidate expects 0 arguments, 2 provided

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note: constexpr DS3231::DS3231(const DS3231&)

 class DS3231 {

       ^

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note:   candidate expects 1 argument, 2 provided

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note: constexpr DS3231::DS3231(DS3231&&)

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:60:7: note:   candidate expects 1 argument, 2 provided

C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino: In function 'void setup()':

sketch_dec19a:5: error: 'class DS3231' has no member named 'begin'

   rtc.begin();

       ^

sketch_dec19a:6: error: 'class DS3231' has no member named 'setDOW'

   rtc.setDOW(WEDNESDAY);     

       ^

sketch_dec19a:6: error: 'WEDNESDAY' was not declared in this scope

   rtc.setDOW(WEDNESDAY);     

              ^

sketch_dec19a:7: error: 'class DS3231' has no member named 'setTime'

   rtc.setTime(12, 0, 0);     

       ^

sketch_dec19a:8: error: no matching function for call to 'DS3231::setDate(int, int, int)'

   rtc.setDate(1, 1, 2014);

                         ^

C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino:8:25: note: candidate is:

In file included from C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino:1:0:

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:94:8: note: void DS3231::setDate(byte)

   void setDate(byte Date); 

        ^

C:\Users\cnagel\Documents\Arduino\libraries\DS3231/DS3231.h:94:8: note:   candidate expects 1 argument, 3 provided

sketch_dec19a:11: error: 'class DS3231' has no member named 'begin'

   rtc.begin();  

       ^

sketch_dec19a:12: error: 'lm35_pin' was not declared in this scope

   pinMode(lm35_pin, INPUT);

           ^

sketch_dec19a:13: error: 'chip_select_pin' was not declared in this scope

   pinMode(chip_select_pin, OUTPUT);

           ^

sketch_dec19a:14: error: 'SD' was not declared in this scope

   if (SD.begin()){

       ^

C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino: At global scope:

sketch_dec19a:28: error: redefinition of 'DS3231 rtc'

 DS3231  rtc(SDA, SCL);

             ^

C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino:2:9: note: 'DS3231 rtc' previously declared here

 DS3231  rtc(SDA, SCL);

         ^

C:\Users\cnagel\AppData\Local\Temp\arduino_modified_sketch_121604\sketch_dec19a.ino: In function 'void loop()':

sketch_dec19a:39: error: 'class DS3231' has no member named 'getTimeStr'

     Serial.print(rtc.getTimeStr());

                      ^

sketch_dec19a:40: error: 'class DS3231' has no member named 'getTimeStr'

     data_file.print(rtc.getTimeStr());

                         ^
exit status 1
no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'

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

I'm really new to Arduino, but it seems like most of the problems come from the library. Does anyone know how to fix this? Thank you!

Also, I looked on some other forums and found that someone had a similar problem that was fixed by adding the DS3231 file to the library folder. I had the file in the library folder, and am still having problems.

Use this library:
Make sure you install the library properly.

Please review this discussion:

Thank you!

Does anyone know how to fix this? Thank you!

You may exercise the tasks of this document on DS3231 RTC, which has not used DS3231 Library; it has used only the Wire.h Library for the High Level TWI Bus Commands. You may also find this link useful!

Hi ppl, well im very noob on arduino and codes and im very happy to find a new arduino famaly, im try to use some elaborated code about 16x2 Big Number Clock, but something rong on my libraries i think.... this is the error log...

teste16x2:7: error: no matching function for call to 'DS3231::DS3231()'

DS3231 rtc;

^

C:\Users\Oficina\Documents\Arduino\teste16x2\teste16x2.ino:7:9: note: candidates are:

In file included from C:\Users\Oficina\Documents\Arduino\teste16x2\teste16x2.ino:3:0:

C:\Users\Oficina\Documents\Arduino\libraries\DS3231/DS3231.h:80:3: note: DS3231::DS3231(uint8_t, uint8_t)

DS3231(uint8_t data_pin, uint8_t sclk_pin);

^

C:\Users\Oficina\Documents\Arduino\libraries\DS3231/DS3231.h:80:3: note: candidate expects 2 arguments, 0 provided

C:\Users\Oficina\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: constexpr DS3231::DS3231(const DS3231&)

class DS3231

^

C:\Users\Oficina\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided

C:\Users\Oficina\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: constexpr DS3231::DS3231(DS3231&&)

C:\Users\Oficina\Documents\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided

C:\Users\Oficina\Documents\Arduino\teste16x2\teste16x2.ino: In function 'void show_clock()':

teste16x2:213: error: 'DateTime' was not declared in this scope

DateTime now = RTC.now(); //get the current date-time

^

teste16x2:215: error: 'now' was not declared in this scope

if (sec != now.second()){

^

C:\Users\Oficina\Documents\Arduino\teste16x2\teste16x2.ino: In function 'void show_date()':

teste16x2:241: error: 'DateTime' was not declared in this scope

DateTime now = RTC.now(); //get the current date-time

^

teste16x2:243: error: 'now' was not declared in this scope

if (date != now.second()){

^

C:\Users\Oficina\Documents\Arduino\teste16x2\teste16x2.ino: In function 'void setup()':

teste16x2:282: error: 'RTC' was not declared in this scope

RTC.begin();

^

Foram encontradas múltiplas bibliotecas para «LiquidCrystal.h»
Utilizado: C:\Users\Oficina\Desktop\arduino-1.8.0\libraries\LiquidCrystal
Não utilizado: C:\Users\Oficina\Documents\Arduino\libraries\NewliquidCrystal
exit status 1
no matching function for call to 'DS3231::DS3231()'

can someone help me please??

can someone help me please??

The class does not have a no argument constructor. So, you MUST supply some values, in parentheses, after the instance name.

DS3231  rtc(onePin, anotherPin);

I haven't a clue what pins you wish to use or why there isn't a no argument constructor that uses the hardware I2C pins.