Nano + DS3231 cannot compile simple sampel-code

I am a new participant in the Arduino forum and need your help.
I downloaded a simple code for an aquarium-controller (Timer with Light etc.) that just doesn’t want to run on my Ardunio-Nano + DS3231.
When compiling, the error messages come right away
“no matching function for call to ‘DS3231::DS3231(const uint8_t&, const uint8_t&)’” ,
even though the libraries etc. are installed.

Since I’m a beginner, I don’t know what I’m doing wrong.
Please, can someone help me ?
Best regards Carsten


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

DS3231 rtc(A4, A5);
Time t;

int mosfet = 3;
int Hor;
int Min;
int Sec;

const int Speed = 155;
const int OnHour1 = 22;
const int OnMin1 = 25;
const int OffHour1 = 22;
const int OffMin1 = 26;

void setup() {
analogWrite (mosfet, Speed);
pinMode (mosfet, OUTPUT);

// The following lines can be uncommented to set the date and time
// rtc.setDOW(TUESDAY); // Set Day-of-Week to Tuesday
// rtc.setTime(22,23,00); // Set the Time to 22:23:00 (24hrs format)
// rtc.setDATE(14, 1, 2020); // Set Date to the Jan 14. in 2020
// delay(2000);

void loop() {
t = rtc.getTime();
Hor = t.hour;
Min = t.min;
Sec = t.sec;
if(Hor == (OnHour1) && (Min == OnMin1)) {
analogWrite(mosfet, HIGH);
else if (Hor == (OffHour1) && (Min == OffMin1)) {
analogWrite(mosfet, LOW);

Doesn’t the Wire library already know which pins to use for I2C?

Please remember to use code tags when posting code

According to the error, a function in the library calledDS3231 is thinking that the A4 and A5 values are in const uint8_t format which is incorrect, but they aren't meant to. You should use SDA and SCL instead of A4 and A5. If yet not fixed, then update the DS3231 library to the latest version and try the code.


. You should use SDA and SCL instead of A4 and A5.

They’re the same pins.

a function in the library calledDS3231

We call it a constructor.

They're the same pins.
We call it a constructor.

Yes it is a constructor, but it thinks that the A4 and A5 values are in const uint8_t format. But they should not be in that format. The SDA and SCL are inbuilt Arduino variables and they are in proper format that the DS3231 constructor accepts.

Use the SDA and SCL instead of typing A4 and A5 there. This could help.


All pins numbers will (should) be defined as “const uint8_t” - it is nonsense to write about “proper format”

Why don’t we just wait for the OP to tell us which library they’re using?

If we’re very lucky, the solution may be as simple as not having any arguments to the constructor, or just having a reference to the Wire object.

If this won't work for the OP, he/she should uninstall and install the original latest version of the library. The problem might be in the library as it could be older.