no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'
You need to provide more information ! No idea what you are doing . Have a look at the forum guidelines , submitt all your code etc
Have you installed the library for the clock and run the examples provided ?
#include <DS3231.h>
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Keypad.h>
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = { 2, 3, 4, 5 };
byte colPins[COLS] = { 6, 7, 8, 9 };
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
DS3231 rtc(SDA, SCL);
Servo servo_test;
LiquidCrystal lcd(A0, A1, A2, 11, 12, 13);
int t1, t2, t3, t4, t5, t6;
boolean feed = true;
char key;
int r[6];
void setup()
{
servo_test.attach(10);
rtc.begin();
lcd.begin(16,2);
servo_test.write(55);
Serial.begin(9600);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
}
I've already installed the libraries but still the error is like that
This is my sample code , but I can't upload it in my arduino uno because of the said error
@tala_123, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project See About the Installation & Troubleshooting category.
Please edit your post #3, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.
Have you had a look at the examples that come with the DS3231 library that you use? Is theree a difference in the way DS3231 rtc(SDA, SCL)
is used?
The Library Manager does install DS3231.h Library and offers some examples where nothing such as DS3231 rtc(SDA, SCL) exits. For example: DS3231_test program.
#include <DS3231.h>
#include <Wire.h>
DS3231 clock1;
bool century = false;
bool h12Flag;
bool pmFlag;
byte alarmDay, alarmHour, alarmMinute, alarmSecond, alarmBits;
bool alarmDy, alarmH12Flag, alarmPmFlag;
void setup()
{
Wire.begin();
Serial.begin(57600);
}
void loop()
{
Serial.print("2");
if (century)
{ // Won't need this for 89 years.
Serial.print("1");
}
else
{
Serial.print("0");
}
Serial.print(clock1.getYear(), DEC);
Serial.print(' ');
// then the month
Serial.print(clock1.getMonth(century), DEC);
Serial.print(" ");
// then the date
Serial.print(clock1.getDate(), DEC);
Serial.print(" ");
// and the day of the week
Serial.print(clock1.getDoW(), DEC);
Serial.print(" ");
// Finally the hour, minute, and second
Serial.print(clock1.getHour(h12Flag, pmFlag), DEC);
Serial.print(" ");
Serial.print(clock1.getMinute(), DEC);
Serial.print(" ");
Serial.print(clock1.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(clock1.getTemperature(), 2);
// Tell whether the time is (likely to be) valid
if (clock1.oscillatorCheck())
{
Serial.print(" O+");
}
else
{
Serial.print(" O-");
}
// Indicate whether an alarm went off
if (clock1.checkIfAlarm(1)) {
Serial.print(" A1!");
}
if (clock1.checkIfAlarm(2))
{
Serial.print(" A2!");
}
// New line on display
Serial.println();
// Display Alarm 1 information
Serial.print("Alarm 1: ");
clock1.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 (clock1.checkAlarmEnabled(1))
{
Serial.print("enabled");
}
Serial.println();
// Display Alarm 2 information
Serial.print("Alarm 2: ");
clock1.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 (clock1.checkAlarmEnabled(2))
{
Serial.print("enabled");
}
// display alarm bits
Serial.println();
Serial.print("Alarm bits: ");
Serial.println(alarmBits, BIN);
Serial.println();
delay(1000);
}
Output:
2166 14 2 0 20 30 37 24h T=33.75 O+
Alarm 1: 41 Date 5 29 0
Alarm 2: 43 Date 9 1
Alarm bits: 100010
yes, I've looked at the example provided by the library, and there is nothing such DS3231 rtc(SDA, SCL) exits. What do you think should I do?
You ran the example programs and learn the instructions/functions until you are equipped enough to build your project yourself with minimum help from the Forum.
There is more than one library for the DS3231, you are using the wrong one for the constructor in your code. Either find the correct library, or modify the code.
I've installed many libraries related with DS3231, but still the error is like that.
That is because the IDE picks the wrong one. Delete all but one, look at the examples and base your code on that.
Yes delete all the libraries you have installed for this . Install one and run the example codes provided with that library .
Do not install more than one !
Then move on .
Upload the following sketch which uses RTClib.h and the DS3231 RTC Module.
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 rtc;
DateTime myDT;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
byte lastReadSecond = 0;
void setup ()
{
Serial.begin(9600);
rtc.begin();
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// rtc.adjust(DateTime(2021, 12, 31, 01, 59, 57));//set date-time manualy:yr,mo,dy,hr,mn,sec
}
void loop ()
{
myDT = rtc.now();
if (lastReadSecond != myDT.second())//wait 1-sec as long as they are equal = 1s has not gones
{
showTime();
}
}
void showTime()
{
//update to the new second
myDT = rtc.now();
lastReadSecond = myDT.second();
//------------------------------
Serial.print(myDT.year(), DEC);
Serial.print('/');
//-----------------------------
Serial.print(myDT.month(), DEC);
Serial.print('/');
Serial.print(myDT.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[myDT.dayOfTheWeek()]);
Serial.print(") ");
//-----------------------------
byte myHour = myDT.hour();
if (myHour < 10)
{
Serial.print('0'); //show leading zero
}
Serial.print(myHour, DEC);
Serial.print(':');
//-----------------------------
byte myMin = myDT.minute();
if (myMin < 10)
{
Serial.print('0'); //show leading zero
}
Serial.print(myMin, DEC);
Serial.print(':');
//--------------------------
byte mySec = myDT.second();
if (mySec < 10)
{
Serial.print('0'); //show leading zero
}
Serial.print(mySec, DEC);
//----------------------------
Serial.println();
}
Output:
2022/5/19 (Thursday) 19:07:04
2022/5/19 (Thursday) 19:07:05
2022/5/19 (Thursday) 19:07:06
RTClib-master.zip (53.3 KB)
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.