RTC DS1307 day reading issue

Hello folks,
So I’m doing a project that needs an alarm function.
I’m using the DS1307 module for the time, an Nano, and some other components not worth naming.

So, the issue is that I can’t read, or don’t know to, the current day (name?). Basically, all I want to know is the day name, not date-wise, but week-wise (eg. saturday, sunday… not 3.11…)

Issue is that; the days of week is up to you how to name them, so I did, but, when I want to know the current day, using an IF loop, I try to find out, and regarding to it [do something]. But, I don’t know the format of it. You name it as a string (“Monday”…), but reading the main files of the library I’m using, it seems like that the days are set as uint8_t format. Also, when reading it, as: if day = 0, which is supposed to be Sunday, and doing something regarding to that information, the if loop turns out as positive, NO matter what day I write down, it’s always positive.
Also tried changing formats, from int to char, still nothing, “int” as the day variable in the serial monitor gives 256 no matter what, char doesn’t show anything, and uint8_t shows 0, since it’s Sunday. (look at “char daysOfTheWeek[7][12]” line)
(note: code is from the lib’s example, it is slightly edited, removed not needed parts, also ignore some lines)

tl;dr: can’t read the current day of the week, logic not proper

The library I’m using: GitHub - adafruit/RTClib: A fork of Jeelab's fantastic RTC library

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
   #define Serial SerialUSB
#endif

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {

#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

  Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
   
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
}

void loop () {
    DateTime now = rtc.now();
    uint8_t day = (daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.println(dan); //printing the current day number, Sunday is "0" 
if (day == 5); //this is where I'm reading it, look above at "daysOfTheWeek[7][12]" line
{                   // this is where you set the names
    Serial.println("TODAY IS THE DAY");
}

    delay(200);
}

It should work with some minor code changes:

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {

#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

  Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled

    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
}

void loop () {
  DateTime now = rtc.now();
  uint8_t weekDay = now.dayOfTheWeek();
  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(" (");
  Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
  Serial.print(") ");
  Serial.println(weekDay); //printing the current day number, Sunday is "0"
  Serial.println(daysOfTheWeek[weekDay]);
  if (weekDay == 5)        // no ; at the end of if statements! 
  { 
    Serial.println("TODAY IS THE DAY");
  }

  delay(200);
}

uxomm:
It should work with some minor code changes:

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include “RTClib.h”

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”};

void setup () {

#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println(“Couldn’t find RTC”);
    while (1);
  }

if (! rtc.isrunning()) {
    Serial.println(“RTC is NOT running!”);
    // following line sets the RTC to the date & time this sketch was compiled

// This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
}

void loop () {
  DateTime now = rtc.now();
  uint8_t weekDay = now.dayOfTheWeek();
  Serial.print(now.year(), DEC);
  Serial.print(’/’);
  Serial.print(now.month(), DEC);
  Serial.print(’/’);
  Serial.print(now.day(), DEC);
  Serial.print(" (");
  Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
  Serial.print(") ");
  Serial.println(weekDay); //printing the current day number, Sunday is “0”
  Serial.println(daysOfTheWeek[weekDay]);
  if (weekDay == 5)        // no ; at the end of if statements!
  {
    Serial.println(“TODAY IS THE DAY”);
  }

delay(200);
}

Wow, what a common mistake… I guess that’s the result of learning multiple langauges at once.
So small, but so important.

Thanks a lot! Fixed it.