RTC

Hello,

sorry for probably a very beginner question lol. but i am trying to learn here so forgive me:)
so already thank you! if there is a information missing please let me know.

i was trying to program the DS3231 RTC time clock. i started with the arduino uno and uploaded my sketch for the RTC. i did that with the web creator. and had no problem.
because of a issue with my computer i am uploading a sketch now to a arduino mega via my raspberry pi 4. i downloaded the new verion from the arduino ide from the arduino page. the example sketches work fine. also rfid project and so on i did were ok. but the RTC won t work . it always shows me an error at the struct ts t;

i got that project from this page.

https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-real-time-clock-module-ds3231-bc90fe

i downloaded the libary from the page where they used the matching code. that code i used before like i said on the web creator and it worked fine. but when i do it with the raspberry it shows me this error. The code i will put on the bottom.

ERROR CODE

Arduino: 1.8.13 (Linux), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

mega_rfid:4:11: error: aggregate 'ts t' has incomplete type and cannot be defined
struct ts t;

THIS IS THE CODE I USE

[color=#444444][color=#95a5a6]#include <Wire.h>[/color]
[color=#95a5a6]#include <ds3231.h>[/color]
 
struct ts t; 
 
void setup[color=#434f54]()[/color] [color=#434f54]{[/color]
 Serial.begin[color=#434f54]([/color][color=#434f54]9600[/color][color=#434f54])[/color];
 Wire.begin[color=#434f54]()[/color];
 DS3231_init[color=#434f54]([/color]DS3231_INTCN[color=#434f54])[/color];
 /*----------------------------------------------------------------------------
 In order to synchronise your clock module, insert timetable values below !
 ----------------------------------------------------------------------------*/
 t.hour[color=#434f54]=[/color][color=#434f54]12[/color]; 
 t.min[color=#434f54]=[/color][color=#434f54]30[/color];
 t.sec[color=#434f54]=[/color][color=#434f54]0[/color];
 t.mday[color=#434f54]=[/color][color=#434f54]25[/color];
 t.mon[color=#434f54]=[/color][color=#434f54]12[/color];
 t.year[color=#434f54]=[/color][color=#434f54]2019[/color];
 
 DS3231_set[color=#434f54]([/color]t[color=#434f54])[/color]; 
[color=#434f54]}[/color]
 
void loop[color=#434f54]()[/color] [color=#434f54]{[/color]
 DS3231_get[color=#434f54]([/color]&t[color=#434f54])[/color];
 Serial.print[color=#434f54]([/color][color=#7f8c8d]"Date : "[/color][color=#434f54])[/color];
 Serial.print[color=#434f54]([/color]t.mday[color=#434f54])[/color];
 Serial.print[color=#434f54]([/color][color=#7f8c8d]"/"[/color][color=#434f54])[/color];
 Serial.print[color=#434f54]([/color]t.mon[color=#434f54])[/color];
 Serial.print[color=#434f54]([/color][color=#7f8c8d]"/"[/color][color=#434f54])[/color];
 Serial.print[color=#434f54]([/color]t.year[color=#434f54])[/color];
 Serial.print[color=#434f54]([/color][color=#7f8c8d]"\t Hour : "[/color][color=#434f54])[/color];
 Serial.print[color=#434f54]([/color]t.hour[color=#434f54])[/color];
 Serial.print[color=#434f54]([/color][color=#7f8c8d]":"[/color][color=#434f54])[/color];
 Serial.print[color=#434f54]([/color]t.min[color=#434f54])[/color];
 Serial.print[color=#434f54]([/color][color=#7f8c8d]"."[/color][color=#434f54])[/color];
 Serial.println[color=#434f54]([/color]t.sec[color=#434f54])[/color];
 
 delay[color=#434f54]([/color][color=#434f54]1000[/color][color=#434f54])[/color];
[color=#434f54]}[/color][/color]

where is the DS3231.h header file stored on your system?

The error you're getting is caused by your sketch using the wrong DS3231 library. This has two possible causes:

  • You installed the wrong library.
  • You installed the right library, but you also have another library with a header file named "ds3231.h" and that library is getting used instead of the right one.

Purely by chance, out of all the thousands of pre-installed Library Manager libraries, Arduino Web Editor picks a since-deleted fork of the library the sketch was written for. However, you don't have all those pre-installed Library Manager libraries on your computer, so you need to install it yourself.

Fortunately, the Arduino IDE can tell us some useful information about this. Please do this:

  • (In the Arduino IDE) click File > Preferences
  • Check the box next to "Show verbose output during: > compilation
  • Click "OK"
  • Sketch > Verify/Compile
  • After the compilation fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the compilation output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the length of the output exceeds the forum's 9000 character limit, save it in a .txt file and post it here as an attachment. If you click the "Reply" button you'll see the "Attachments and other options" link that will allow you to make the attachment.


I'm providing a note to myself because there's a good chance you'll hit yet another unrelated error after we resolve this one, and I'll have forgotten the ref by then if I don't write it down now. The compatible library version is here:

Make sure you have installed the library in the right directory, for example /usr /share /arduino/libraries/
. Or you can reinstall the library through the library manager. open the arduino IDE - select tools - select manage libraries - type "DS3231" in the search field - install ds3231FS by Petre Rodan.