DS3231 RTC - can it provide dayOfTheWeek information?

One recent project to learn about RTCs is a clock using a 16x2 I2C LCD. I found it difficult to find easy to understand tutorials online. I’m using a DS3231 with an Arduino UNO. I was hoping to display the day of the week on the LCD - although abbreviated to Sun, Mon, Tue, etc. So, can it be done? My code is below.

Thank you,

Tony

#include <Wire.h>                     // Library for I2C communication
#include <LiquidCrystal_I2C.h>        // Library for LCD

#include "DS3231.h"                   // include DS3231 library

RTClib RTC;

byte second, minute, hour, day, dayOfTheWeek, month, year;

LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);

void setup() {
  // Initiate the LCD:
  lcd.init();
  lcd.backlight();

}

void loop() {

  DateTime now = RTC.now();


  lcd.setCursor(0, 0); 
  lcd.print(now.month(), DEC);
  lcd.print("-");
  if (now.month()<10) {
    lcd.print("0");
  }
  if (now.day()<10) {
    lcd.print("0");
  }
  lcd.print(now.day(), DEC);
  lcd.print("-");
  lcd.print(now.year(), DEC);


  lcd.setCursor(0, 1); 
  if (hour<10) {
    lcd.print("0");
  }
  lcd.print(now.hour()-12, DEC);
  lcd.print(":");
  
  if (now.minute()<10) {
    lcd.print("0");
  }
  lcd.print(now.minute(), DEC);
  lcd.print(":");
  if (now.second()<10){
    lcd.print("0");
  }
  lcd.print(now.second(), DEC);
  lcd.print(" ");
  lcd.print(dayOfTheWeek);

}

Probably. The first library I found for that clock on github has a getDoW function.

Did you try the dayOfTheWeek() function? It returns 0-6 to represent Sun-Sat

I tried both but I'm not getting any results.

Here
https://github.com/PaulStoffregen/Time/blob/master/DateStrings.cpp

So this code

char* dayShortStr(uint8_t day) 
{
   uint8_t index = day*dt_SHORT_STR_LEN;
   for (int i=0; i < dt_SHORT_STR_LEN; i++)      
      buffer[i] = pgm_read_byte(&(dayShortNames_P[index + i]));  
   buffer[dt_SHORT_STR_LEN] = 0; 
   return buffer;
}

Allows you to

Serial.print(dayShortStr(day));

and it will print something like “Mon” from the array in flash:

const char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThuFriSat";

All you have to do to use it, is include the DateTime library.

Or, as another alternative, instead of interpreting the output of the ds3231 directly, or using supplied functions within the specific library, you can use the standard Arduino time library (TimeLib) functions.
This can also be useful, especially if you always run the RTC in the UTC time zone and convert to local time (including daylight saving time) for display.
To do this, do :

setTime( RTC.now() ) ; // aligns the Arduino system time with the RTC but see also setSyncProvider()

Then you can use all the functions described here: Arduino Playground - Time including the 12hour time format which you appear to use.

Thanks all. I will give these suggestions a try. I'm just starting out so it could take me a while.