Some problem about rtc3231

Hi guys ,
I'm just getting started to learning about Arduino cz my school project needs and yeah , i have faces some problem while doing this.

Actually my school project is about making clock using Arduino,but i have a little problem about it.

The codes is here :

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>
// Set the LCD address to 0x27 
LiquidCrystal_I2C lcd(0x3F, 16, 2);   
// Init the DS3231 using hardware interface
DS3231  rtc(SDA, SCL);

Time t;

void setup()
{
  lcd.begin();
  lcd.clear();
  Serial.begin(9600);

rtc.begin();
rtc.setDOW(THURSDAY);     // Set Day-of-Week to SUNDAY
rtc.setTime(20, 10, 10);     // Set the time to 12:00:00 (24hr format)
rtc.setDate(11, 7, 2024); // Set the year
}

void loop()
{
 rtc.getTime();
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");
  lcd.setCursor(0,0);
  lcd.print(rtc.getDateStr());
  Serial.println(rtc.getTimeStr());
  lcd.setCursor(0,1);
  lcd.println(rtc.getTimeStr());
  delay(1000);
}


在此处键入或粘贴代码

 DS3231  rtc(SDA, SCL);
                     ^
In file included from C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:4:0:
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:73:3: note: candidate: DS3231::DS3231(TwoWire&)
   DS3231(TwoWire & w);
   ^~~~~~
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:73:3: note:   candidate expects 1 argument, 2 provided
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:72:3: note: candidate: DS3231::DS3231()
   DS3231();
   ^~~~~~
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:72:3: note:   candidate expects 0 arguments, 2 provided
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:68:7: note: candidate: constexpr DS3231::DS3231(const DS3231&)
 class DS3231 {
       ^~~~~~
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:68:7: note:   candidate expects 1 argument, 2 provided
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:68:7: note: candidate: constexpr DS3231::DS3231(DS3231&&)
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:68:7: note:   candidate expects 1 argument, 2 provided
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:10:1: error: 'Time' does not name a type; did you mean 'time'?
 Time t;
 ^~~~
 time
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino: In function 'void setup()':
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:14:13: error: no matching function for call to 'LiquidCrystal_I2C::begin()'
   lcd.begin();
             ^
In file included from C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:3:0:
C:\Users\Admin\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:58:8: note: candidate: void LiquidCrystal_I2C::begin(uint8_t, uint8_t, uint8_t)
   void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS );
        ^~~~~
C:\Users\Admin\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:58:8: note:   candidate expects 3 arguments, 0 provided
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:18:5: error: 'class DS3231' has no member named 'begin'
 rtc.begin();
     ^~~~~
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:19:5: error: 'class DS3231' has no member named 'setDOW'; did you mean 'setDoW'?
 rtc.setDOW(THURSDAY);     // Set Day-of-Week to SUNDAY
     ^~~~~~
     setDoW
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:20:5: error: 'class DS3231' has no member named 'setTime'; did you mean 'setA1Time'?
 rtc.setTime(20, 10, 10);     // Set the time to 12:00:00 (24hr format)
     ^~~~~~~
     setA1Time
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:21:24: error: no matching function for call to 'DS3231::setDate(int, int, int)'
 rtc.setDate(11, 7, 2024); // Set the year
                        ^
In file included from C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:4:0:
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:109:8: note: candidate: void DS3231::setDate(byte)
   void setDate(byte Date);
        ^~~~~~~
C:\Users\Admin\Documents\Arduino\libraries\DS3231/DS3231.h:109:8: note:   candidate expects 1 argument, 3 provided
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino: In function 'void loop()':
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:26:6: error: 'class DS3231' has no member named 'getTime'; did you mean 'getA1Time'?
  rtc.getTime();
      ^~~~~~~
      getA1Time
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:27:20: error: 'class DS3231' has no member named 'getDOWStr'; did you mean 'getDoW'?
   Serial.print(rtc.getDOWStr());
                    ^~~~~~~~~
                    getDoW
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:29:20: error: 'class DS3231' has no member named 'getDateStr'; did you mean 'getDate'?
   Serial.print(rtc.getDateStr());
                    ^~~~~~~~~~
                    getDate
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:32:17: error: 'class DS3231' has no member named 'getDateStr'; did you mean 'getDate'?
   lcd.print(rtc.getDateStr());
                 ^~~~~~~~~~
                 getDate
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:33:22: error: 'class DS3231' has no member named 'getTimeStr'; did you mean 'getMinute'?
   Serial.println(rtc.getTimeStr());
                      ^~~~~~~~~~
                      getMinute
C:\Users\Admin\Downloads\Clock_LCD\Clock_LCD.ino:35:19: error: 'class DS3231' has no member named 'getTimeStr'; did you mean 'getMinute'?
   lcd.println(rtc.getTimeStr());
                   ^~~~~~~~~~
                   getMinute

exit status 1

Compilation error: no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'

Can any expert give some advice or guide ???
Thankyou for helping me :slight_smile:

Welcome to the forum

Please post your full sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

sorry for making some problem to you. I have changed that.
Thankyou :slight_smile:

There is a variety of DS3231 libraries; I suggest that you look at the examples of the DS3231 library that you have installed and base your code on that.

If you found some code on the web and randomly installed a library that supports the DS3231, you have the risk that you installed the wrong library. Same will apply to the LiquidCrystal_I2C library (based on your error that is already happening).

in case of conflict between code and comment, code always wins...

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