Unable to get Day of Week from DS1307 RTC

I'm not sure if this is the right place to ask this question, but it's worth a shot. I'm using the ReadTest sketch in the examples included in the library. Everything verifies and runs fine, except I can't get the day of the week number. It was not included in the sketch, so I added these two lines in the section that displays the time and date:
Serial.print("Day: "); // print day-of-week number
Serial.println(tm.Wday); // print day-of-week number

As best I can tell, this should return a number that corresponds to the day# (1-7). All I get back is 0. What am I doing wrong? Has anyone else run into this?

The included libraries are:
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>

I am using an Arduino UNO. I have attached the ReadTest example sketch. If there is somewhere else I should be posting this question, let me know.

ReadTest.ino (1.29 KB)

This is the right place. I'm surprised there is no DoW code included, but I don't use the library anyway. The code below has a section which equates day number with DoW using the "case" commands.

http://bildr.org/2011/03/ds1307-arduino/

With the TimeLib, I use the weekDay() with the epoch time as parameter. That works, sunday is 1 and saterday is 7. I'm using the DS3231.
That bypasses the 'day of the week' register of the DS3231.
The data is read from the DS3231, and makeTime() converts it to the epoch time without using the Wday. Then when I call weekDay() the epoch time is converted into values of the 'tm' structure. The 'tm.Wday' is calculated in breakTime() without ever using the 'day of the week' register.

Do you use this "DS1307RTC" library ? GitHub - PaulStoffregen/DS1307RTC: Use a DS1307 Real Time Clock chip with the Time library. It reads that value. Perhaps it should be set to a value 1...7 to get it started. That register is written when a new time is set into the DS1307.
Sorry, I have no clue why it is zero.

Thanks.
I am using Timelib and that worked using the internal software clock and the weekDay() function. Once I started using the DS1307, it stopped working, but the other time functions work fine. I am using the DS1307RTC library recommended by Adafruit since that is where I got the device. The read and settime examples are the same as ones in the library I'm using. I will look into using another library.

Can you give a link to which DS1307 library you use ?

The Adafruit RTClib is not compatible with the TimeLib.

On one side is the Adafruit RTClib: https://github.com/adafruit/RTClib/blob/master/RTClib.cpp.
It has code for the DS1307 included.

On the other side is the TimeLib maintained by Paul Stoffregen: GitHub - PaulStoffregen/Time: Time library for Arduino.
This is the one that I use.
It had no code for RTC included. An extra library is needed and that library should work together with TimeLib.
This one is for the DS1307: GitHub - PaulStoffregen/DS1307RTC: Use a DS1307 Real Time Clock chip with the Time library.
The TimeLib is more based on the 'epoch' time. That is the number of seconds since 1970.
The TimeAlarms library works together with TimeLib: GitHub - PaulStoffregen/TimeAlarms: Time library add-on, schedule alarms to occur at specific dates/times.

A third good option is the time of the 'c' library that is used for decades in every 'c' program.
It is not often used, but it is available, even for the Arduino Uno.

The SAMD Arduino boards (Arduino Zero, M0, MKR) have a RTC in the processor and the Arduino team made a seperate library for that: RTCZero - Arduino Reference.

Fixed it!

I got rid of the DS1307RTC, TimeLib and Wire libraries and used just RTClib. Thanks so much for your suggestions. This is the library: GitHub - adafruit/RTClib: A fork of Jeelab's fantastic RTC Arduino library

Regards,
Tom