DS3231 library choices

Apart from their names, these two libraries have identical descriptions. Are they actually different?
Can users of the DS3231 RTC recommend their choice for getting a first module set up and running please?

Also, in my \SKETCHES\libraries folder I had a few dozen libraries with names like 'arduino_345904', 'arduino_3495874', etc. I gather that the IDE renames them when it encounters duplicate names and cautiously retains each. (But not with the sort of names that I think would be more helpful like DS3231-A, DS3231-B, etc). Anyway, after studying their contents, I renamed them, if possible using the name given on line 1 of the library.properties file. So libraries\ now has four potentially relevant installed entries. I'm curious why the RinkyDinky one doesn't appear in the Include Library or Manage Libraries section.

Any feedback would be appreciated please.

I use adafruit RTCLib. It’s convenient and working

I removed all the others that I had tried or needed for providing input in the forum so that the IDE does not get confused

1 Like

Thanks, appreciate that quick and helpful reply.

Did you install it from the IDE or by downloading from github? I've had two occasions recently when the IDE method resulted in problems, which did not arise using the 'manual' approach.

EDIT Wed 9 Aug 2023 19:38
But in this case both result in identical folders, so I will next try an example from the already installed version. Can you perhaps recall the sketch you first used to set up and run your DS3231 module?

That library has examples.

This one looks simple enough:

HTH

a7

1 Like

One thing to consider is how the day of week is handled (if you care). Some libraries use the 1-7 numbering of the chip for Sun - Sat. Others map the numbers to 0-6, which is consistent with some C date functions.

I use the Rtc by Makuna library which uses the 0-6 numbering.

Both worked for me

Thanks a bunch, works a treat.

That's now that I ran it less impatiently! I duly downloaded and saved as 'DS3231-RTClib-alto.ino and on examination it was identical to one (of several) I had unsuccessfully tried already, DS3231-RTClib.ino.

I now see that was down to me. I had impatiently used an existing UNO-LCD-MP3 Player circuit, my current project, but not surprisingly had some conflict.

On a fresh board with that dedicated sketch it worked immediately.

A particular attraction IMO is that it automatically set its time from the PC system date/time. Several other libraries require that to be done manually by uncommenting a couple of code lines etc.

Will now work on integrating it with the full project.

I'll mark as solved, although still welcome any further advice/tips about using the module with 16x2 LCDs.

I think that you will find that it sets the date/time to the compile time. What happens to the time if you upload the sketch, wait a couple of minutes and reset the Arduino ? Is the time correct now ?

1 Like

Thanks for the tip. I am likely to include DOW in the eventual project and will probably set Monday as my week's start.

I will later explore Makuna's library but for now will focus on using DS3231_RTClib.

Ah, yes indeed, my mistake, thanks.

Now running as it should, although I'm surprised to see 'minutes' are not padded?

2023/8/10 (Thursday) 11:2:25

It's your application code that does the printing. You can pad it however you like.

With a new device and an example program it is a good idea, as you have discovered, to have the identical hardware setup.

Or as close as you can manage. Substituting an UNO for a Mega isn't gonna kill you. Usually.

If you find the library you picked does things you don't like, as an example the day numbering 0..6 instead of 1..7 mentioned above, remember that you are the programmer and you wield a certain amount of control over annoyances like that.

In this case, addition (or subtraction) of one (1) at appropriate points in the code lets everyone think about it however they would like. You can often do it in just one or two places, coming and going from the library.

Lastly, be sure if you have the cheap RTC module that seems to be everywhere these days, read and heed the advice at the site Iink here, or google "ds3231 charging circuit" and take your pick:

Modify the DS3231 module.

HTH

a7

1 Like

Thanks. Happily my module came with the Lithium battery and reports 3.27 V, so I can avoid what sounds like fiddly surface-mount work.

Yes, I've done so. I was just surprised it wasn't already padded. I think hours, minutes and seconds are universally shown in that format?

what you are printing is likely a number, so if the value is 2 and you ask that to be printed, it's normal to get 2. if you want a 0 in front of it, you need to tell the arduino to add that

if (minute < 10) Serial.write('0'); // add padding 
Serial.print(minute);

To offer another option, I like to use the DS3232RTC library. It was written specifically to work with the Time libary, so no worry about conflicts in how the date/time is represented, and easy to swap between the DS1307/DS3231/DS3232 RTCs.

1 Like

I think that you are conflating the display format, designed to be read by human beings, and the native format, designed to be used by the program

I'm sure the library's author knew that too. :slightly_smiling_face:

what function do you call to print the minutes? is that a library function returning a string?
if you are just asking the value of minutes as a number, and then you do the printing, then it's on you, not the library's author

If only @Terrypin had posted the code whose behavior he's complaining about ....