Error on showing DS3231 clock on LCD

Hello.I need some help with an error that occur while I want to show a DS3231 clock on an LCD.
This is the error:

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\Ady\Documents\Arduino\protocol_udare\protocol_udare.ino:36:0:

C:\Users\Ady\Documents\Arduino\libraries\RTClib/RTClib.h:52:7: error: redefinition of 'class DateTime'

class DateTime {

^

In file included from C:\Users\Ady\Documents\Arduino\protocol_udare\protocol_udare.ino:34:0:

C:\Users\Ady\Documents\Arduino\libraries\arduino_865795/DS3231.h:27:7: error: previous definition of 'class DateTime'

class DateTime {

^

exit status 1
Error compiling for board Arduino/Genuino Uno.

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

And here is the code:(the relevant part because the whole program is from an automatic irrigation system based on a soil moisture sensor and real time clock)

#include <LiquidCrystal.h>
#include <DS3231.h>
#include<time.h>
#include <RTClib.h>
#include <Wire.h>

RTC_DS3231 rtc;

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

DateTime timp;

void setup()
{

Serial.begin(115200);
rtc.begin();
lcd.begin(16, 2);
}

void loop()
{

timp = rtc.now();
if( timp.hour() == 4)

afis_ora;

}

void afis_ora ( ){
int Day;
int Month;
int Minutes;
int Hours;
DateTime now = rtc.now();
lcd.clear();
Day = now.day();
Month = now.month();
Hours = now.hour();
Minutes = now.minute();
lcd.setCursor(0, 0);
lcd.write ("Ultima udare:");
lcd.setCursor(0, 1);
lcd.write(Day);
lcd.write(".");
lcd.write(Month);
lcd.write(" ");
lcd.write(Hours);
lcd.write(":");
lcd.write(Minutes);
}

You're using both the DS3231 library and the RTClib library. You only need one. You can't use both. Pick one and remove the #include directive for the other one.

1 Like

pert:
You're using both the DS3231 library and the RTClib library. You only need one. You can't use both. Pick one and remove the #include directive for the other one.

THANK U .PROBLEM SOLVED

You're welcome. I'm glad to hear it's working now. Enjoy!
Per