Adding ds1307 rtc time to LiquidLine?

#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;
// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;
char* dateTime;

enum FunctionTypes {
  increase = 1,
  decrease = 2,
};

//char onOFF[] = {'ON', 'OFF'};

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidLine welcome_line3(1, 2, dateTime);
LiquidScreen welcome_screen(welcome_line1, welcome_line2, welcome_line3);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
   LiquidSystem object combines the LiquidMenu objects to form
   a menu system. It provides the same functions as LiquidMenu
   with the addition of add_menu() and change_menu().
*/
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
  if (right.check() == LOW) {
    menu_system.next_screen();
  }
  if (left.check() == LOW) {
    menu_system.previous_screen();
  }
  if (up.check() == LOW) {
    menu_system.call_function(increase);
  }
  if (down.check() == LOW) {
    menu_system.call_function(decrease);
  }
  if (enter.check() == LOW) {
    menu_system.switch_focus();
  }
}

// Callback function that will be attached to back_line.
void go_back() {
  // This function takes reference to the wanted menu.
  menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
  menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
  menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
  if (pin6_level < 225) {
    pin6_level += 25;
  }
  else {
    pin6_level = 250;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void decrease_pin6() {
  if (pin6_level > 25) {
    pin6_level -= 25;
  }
  else {
    pin6_level = 0;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void save_input() {
  EEPROM.put(11, sample_period);
  input_saved = (char*)" *";
}

void save_output() {
  EEPROM.put(9, pin6_level);
  output_saved = (char*)" *";
}

void increase_samplePeriod() {
  if (sample_period < 10) {
    sample_period++;
    input_saved = (char*)"  ";
  }
}

void decrease_samplePeriod() {
  if (sample_period > 0) {
    sample_period--;
    input_saved = (char*)"  ";
  }
}



void setup() {
  Serial.begin(250000);
  //DateTime now = rtc.now();

  pinMode(pin6, OUTPUT);

  // Reads the values recorded in the EEPROM
  EEPROM.get(9, pin6_level);
  EEPROM.get(11, sample_period);
  analogWrite(pin6, pin6_level);


  lcd.init();
  lcd.begin(20,4);
  lcd.backlight();

  back_line.set_focusPosition(Position::LEFT);

  back_line.attach_function(1, go_back);
  back_line.attach_function(2, go_back);

  outputs_line.attach_function(1, goto_outputs_menu);
  outputs_line.attach_function(2, goto_outputs_menu);
  inputs_line.attach_function(1, goto_inputs_menu);
  inputs_line.attach_function(2, goto_inputs_menu);

  pin6_line.attach_function(increase, increase_pin6);
  pin6_line.attach_function(decrease, decrease_pin6);

  oSave_line.attach_function(1, save_output);
  oSave_line.attach_function(2, save_output);
  iSave_line.attach_function(1, save_input);
  iSave_line.attach_function(2, save_input);
  iSample_line.attach_function(increase, increase_samplePeriod);
  iSample_line.attach_function(decrease, decrease_samplePeriod);

  input_saved = (char*)" *";
  output_saved = (char*)" *";
  //relayState(onOFF) takes over for the code below, accepts onOFF and changes the string assignment to onOFF
  //onOFF = (char *)"ON";

  menu_system.update();
}
void rtcSet(char* dateTime){
  //char* dateTime;
  DateTime now;
  now = rtc.now();
  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  if (!rtc.isrunning()) {
    Serial.println("RTC lost power, lets set the time!");
    // Comment out below lines once you set the date & time.
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));
    char buffer[25] = "";
    sprintf(buffer, "%04d/%02d/%02d, %02d:%02d:%02d", now.year(), now.month(), now.day(), now.hour(), now.minute(), now.second());
    dateTime = buffer;
  }
rtcSet(dateTime);
}


void loop() {
  rtc.begin();
  buttonsCheck();
  static unsigned long lastMillis_sample = 0;
  if (millis() - lastMillis_sample > (sample_period * 1000)) {
    lastMillis_sample = millis();
    menu_system.update();
  }
}

Replaced onOFF char* variable in previous post with the dateTime variable so it can be initialized in liquidline. It compiles which is nice, just nervous to upload haha, if this doesn’t work I dont know what direction to go.

I need to try and move the function call above the welcome menu lines it seems

#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;
// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;
//char* dateTime;

enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

char* rtcSet() {
	if (!rtc.begin()) {
		Serial.println("Couldn't find RTC");
		while (1);
	}
	if (!rtc.isrunning()) {
		Serial.println("RTC lost power, lets set the time!");
		// Comment out below lines once you set the date & time.
		// Following line sets the RTC to the date & time this sketch was compiled
		rtc.adjust(DateTime(__DATE__, __TIME__));
	}
	DateTime now;
	now = rtc.now();
	char buffer[25] = "";
	sprintf(buffer, "%04d/%02d/%02d, %02d:%02d:%02d", now.year(), now.month(), now.day(), now.hour(), now.minute(), now.second());
	char* dateTime = buffer;
	return dateTime;
}


//char onOFF[] = {'ON', 'OFF'};

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidLine welcome_line3(1, 2, "");
LiquidScreen welcome_screen(welcome_line1, welcome_line2, welcome_line3);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
   LiquidSystem object combines the LiquidMenu objects to form
   a menu system. It provides the same functions as LiquidMenu
   with the addition of add_menu() and change_menu().
*/
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
  if (right.check() == LOW) {
    menu_system.next_screen();
  }
  if (left.check() == LOW) {
    menu_system.previous_screen();
  }
  if (up.check() == LOW) {
    menu_system.call_function(increase);
  }
  if (down.check() == LOW) {
    menu_system.call_function(decrease);
  }
  if (enter.check() == LOW) {
    menu_system.switch_focus();
  }
}

// Callback function that will be attached to back_line.
void go_back() {
  // This function takes reference to the wanted menu.
  menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
  menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
  menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
  if (pin6_level < 225) {
    pin6_level += 25;
  }
  else {
    pin6_level = 250;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void decrease_pin6() {
  if (pin6_level > 25) {
    pin6_level -= 25;
  }
  else {
    pin6_level = 0;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void save_input() {
  EEPROM.put(11, sample_period);
  input_saved = (char*)" *";
}

void save_output() {
  EEPROM.put(9, pin6_level);
  output_saved = (char*)" *";
}

void increase_samplePeriod() {
  if (sample_period < 10) {
    sample_period++;
    input_saved = (char*)"  ";
  }
}

void decrease_samplePeriod() {
  if (sample_period > 0) {
    sample_period--;
    input_saved = (char*)"  ";
  }
}



void setup() {
  Serial.begin(250000);
  //DateTime now = rtc.now();

  pinMode(pin6, OUTPUT);

  // Reads the values recorded in the EEPROM
  EEPROM.get(9, pin6_level);
  EEPROM.get(11, sample_period);
  analogWrite(pin6, pin6_level);


  lcd.init();
  lcd.begin(20,4);
  lcd.backlight();

  back_line.set_focusPosition(Position::LEFT);

  back_line.attach_function(1, go_back);
  back_line.attach_function(2, go_back);

  outputs_line.attach_function(1, goto_outputs_menu);
  outputs_line.attach_function(2, goto_outputs_menu);
  inputs_line.attach_function(1, goto_inputs_menu);
  inputs_line.attach_function(2, goto_inputs_menu);

  pin6_line.attach_function(increase, increase_pin6);
  pin6_line.attach_function(decrease, decrease_pin6);

  oSave_line.attach_function(1, save_output);
  oSave_line.attach_function(2, save_output);
  iSave_line.attach_function(1, save_input);
  iSave_line.attach_function(2, save_input);
  iSample_line.attach_function(increase, increase_samplePeriod);
  iSample_line.attach_function(decrease, decrease_samplePeriod);

  input_saved = (char*)" *";
  output_saved = (char*)" *";

  menu_system.update();
}


void loop() {
  rtc.begin();
  buttonsCheck();
  static unsigned long lastMillis_sample = 0;
  if (millis() - lastMillis_sample > (sample_period * 1000)) {
    lastMillis_sample = millis();
    menu_system.update();
  }
}

Surprisingly compiles with no warning or errors.

C:\Users\Bob\Documents\Arduino\Sep8LiqFinalExp\Sep8LiqFinalExp.ino: In function 'char* rtcSet()':

C:\Users\Bob\Documents\Arduino\Sep8LiqFinalExp\Sep8LiqFinalExp.ino:54:7: warning: address of local variable 'buffer' returned [-Wreturn-local-addr]

char buffer[25] = "";

Does the above have any importance to me if sprintf processes buffer to the time returned to the function?

Your programming technique seems to be one of continually throwing random crap at the wall and hoping something will eventually stick. That’s going to lead to endless frustration and horrible code.

You need to think about what you’re doing. You shouldn’t try to return a pointer to a local variable because that variable ceases to exist after the function exits. The result of dereferencing that pointer will be undefined. In fact, I don’t even know why you’re trying to return a ‘char *’ from that function to begin with. Just allocate a global char array for the time and use that in the ‘LiquidLine’ constructor:

char timeBuffer[25] = "";
LiquidLine welcome_line3(1, 2, timeBuffer);

Then, just sprintf() directly into THAT array when you want to update the time. Obviously, any changes to that array won’t show up on the screen until the next call to ‘menu_system.update();’.

gfvalvo:
Your programming technique seems to be one of continually throwing random crap at the wall and hoping something will eventually stick. That’s going to lead to endless frustration and horrible code.

You need to think about what you’re doing. You shouldn’t try to return a pointer to a local variable because that variable ceases to exist after the function exits. The result of dereferencing that pointer will be undefined. In fact, I don’t even know why you’re trying to return a ‘char *’ from that function to begin with. Just allocate a global char array for the time and use that in the ‘LiquidLine’ constructor:

char timeBuffer[25] = "";

LiquidLine welcome_line3(1, 2, timeBuffer);



Then, just sprintf() directly into THAT array when you want to update the time. Obviously, any changes to that array won’t show up on the screen until the next call to ‘menu_system.update();’.

I have nothing else to fall back on, can only research the areas that I believe my problems are, which I am not confident in always being the culprit, so that's why I come here to get help and progress in my learning.

Ok ill give that a go.

I thought functions stayed in the program so they can be called on, didn't know after it goes through the code the local variable no longer exists

I thought functions stayed in the program so they can be called on

They do. It is variables declared in the function (local variables) or pointers to them that disappear when the function ends. The clue is in the word local

#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;
// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;
char timeBuffer[25] = "";

enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidLine welcome_line3(1, 2, timeBuffer);
LiquidScreen welcome_screen(welcome_line1, welcome_line2, welcome_line3);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
   LiquidSystem object combines the LiquidMenu objects to form
   a menu system. It provides the same functions as LiquidMenu
   with the addition of add_menu() and change_menu().
*/
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
  if (right.check() == LOW) {
    menu_system.next_screen();
  }
  if (left.check() == LOW) {
    menu_system.previous_screen();
  }
  if (up.check() == LOW) {
    menu_system.call_function(increase);
  }
  if (down.check() == LOW) {
    menu_system.call_function(decrease);
  }
  if (enter.check() == LOW) {
    menu_system.switch_focus();
  }
}

// Callback function that will be attached to back_line.
void go_back() {
  // This function takes reference to the wanted menu.
  menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
  menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
  menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
  if (pin6_level < 225) {
    pin6_level += 25;
  }
  else {
    pin6_level = 250;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void decrease_pin6() {
  if (pin6_level > 25) {
    pin6_level -= 25;
  }
  else {
    pin6_level = 0;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void save_input() {
  EEPROM.put(11, sample_period);
  input_saved = (char*)" *";
}

void save_output() {
  EEPROM.put(9, pin6_level);
  output_saved = (char*)" *";
}

void increase_samplePeriod() {
  if (sample_period < 10) {
    sample_period++;
    input_saved = (char*)"  ";
  }
}

void decrease_samplePeriod() {
  if (sample_period > 0) {
    sample_period--;
    input_saved = (char*)"  ";
  }
}



void setup() {
  Serial.begin(250000);
  DateTime now = rtc.now();
  rtc.begin();
  if (!rtc.begin()) {
	  Serial.println("Couldn't find RTC");
	  while (1);
  }
  if (!rtc.isrunning()) {
	  Serial.println("RTC lost power, lets set the time!");
	  // Comment out below lines once you set the date & time.
		// Following line sets the RTC to the date & time this sketch was compiled
	  rtc.adjust(DateTime(__DATE__, __TIME__));
  }
  pinMode(pin6, OUTPUT);

  // Reads the values recorded in the EEPROM
  EEPROM.get(9, pin6_level);
  EEPROM.get(11, sample_period);
  analogWrite(pin6, pin6_level);


  lcd.init();
  lcd.begin(20,4);
  lcd.backlight();

  back_line.set_focusPosition(Position::LEFT);

  back_line.attach_function(1, go_back);
  back_line.attach_function(2, go_back);

  outputs_line.attach_function(1, goto_outputs_menu);
  outputs_line.attach_function(2, goto_outputs_menu);
  inputs_line.attach_function(1, goto_inputs_menu);
  inputs_line.attach_function(2, goto_inputs_menu);

  pin6_line.attach_function(increase, increase_pin6);
  pin6_line.attach_function(decrease, decrease_pin6);

  oSave_line.attach_function(1, save_output);
  oSave_line.attach_function(2, save_output);
  iSave_line.attach_function(1, save_input);
  iSave_line.attach_function(2, save_input);
  iSample_line.attach_function(increase, increase_samplePeriod);
  iSample_line.attach_function(decrease, decrease_samplePeriod);

  input_saved = (char*)" *";
  output_saved = (char*)" *";
  sprintf(timeBuffer, "%04d/%02d/%02d, %02d:%02d:%02d", now.year(), now.month(), now.day(), now.hour(), now.minute(), now.second());

  menu_system.update();
}


void loop() {
  DateTime now = rtc.now();
  buttonsCheck();
  static unsigned long lastMillis_sample = 0;
  if (millis() - lastMillis_sample > (sample_period * 1000)) {
    lastMillis_sample = millis();
    menu_system.update();
  }
}
C:\Users\Bob\Documents\Arduino\Sep8LiqFinalExp\Sep8LiqFinalExp.ino: In function 'void loop()':

C:\Users\Bob\Documents\Arduino\Sep8LiqFinalExp\Sep8LiqFinalExp.ino:224:12: warning: variable 'now' set but not used [-Wunused-but-set-variable]

   DateTime now = rtc.now();

That warning makes sense, since it’s only local to loop, but thought would want it updated but the clock should hold the time and get updated on the menu after menu_system.update();

that person uses wire.h to communicate data by converting to a int in a void, was wondering if that could be another solution of having a int function that holds the time like in the link above and pass it to liquidline.

Ok that just fills the screen with random characters, deleted datetime in the loop since it wasn't needed but unfortunately this isn't the solution. I also wondered about writing the time using lcd.print to the top line and have it stay there for every screen change and write the menu's below the displayed clock on the 1st line, this should work as well right?

So maybe that way would work or follow the above link write a int function that passes the time through return?

You only sprintf() into timeBuffer once, in setup(). How can you possibly think the value in there will stay current as time passes?

What did you see when you Serial.print the value of timeBuffer after the sprintf()? That should have been the FIRST thing you did to make sure it was formatted correctly.

gfvalvo:
You only sprintf() into timeBuffer once, in setup(). How can you possibly think the value in there will stay current as time passes?

What did you see when you Serial.print the value of timeBuffer after the sprintf()? That should have been the FIRST thing you did to make sure it was formatted correctly.

Got ya, trying that now.

11:49:20.864 → ⸮

It prints the above.

#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;
// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;
char timeBuffer[25] = "";

enum FunctionTypes {
  increase = 1,
  decrease = 2,
};

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidLine welcome_line3(1, 2, timeBuffer);
LiquidScreen welcome_screen(welcome_line1, welcome_line2, welcome_line3);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
   LiquidSystem object combines the LiquidMenu objects to form
   a menu system. It provides the same functions as LiquidMenu
   with the addition of add_menu() and change_menu().
*/
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
  if (right.check() == LOW) {
    menu_system.next_screen();
  }
  if (left.check() == LOW) {
    menu_system.previous_screen();
  }
  if (up.check() == LOW) {
    menu_system.call_function(increase);
  }
  if (down.check() == LOW) {
    menu_system.call_function(decrease);
  }
  if (enter.check() == LOW) {
    menu_system.switch_focus();
  }
}

// Callback function that will be attached to back_line.
void go_back() {
  // This function takes reference to the wanted menu.
  menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
  menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
  menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
  if (pin6_level < 225) {
    pin6_level += 25;
  }
  else {
    pin6_level = 250;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void decrease_pin6() {
  if (pin6_level > 25) {
    pin6_level -= 25;
  }
  else {
    pin6_level = 0;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void save_input() {
  EEPROM.put(11, sample_period);
  input_saved = (char*)" *";
}

void save_output() {
  EEPROM.put(9, pin6_level);
  output_saved = (char*)" *";
}

void increase_samplePeriod() {
  if (sample_period < 10) {
    sample_period++;
    input_saved = (char*)"  ";
  }
}

void decrease_samplePeriod() {
  if (sample_period > 0) {
    sample_period--;
    input_saved = (char*)"  ";
  }
}



void setup() {
  Serial.begin(250000);
  pinMode(pin6, OUTPUT);

  // Reads the values recorded in the EEPROM
  EEPROM.get(9, pin6_level);
  EEPROM.get(11, sample_period);
  analogWrite(pin6, pin6_level);


  lcd.init();
  lcd.begin(20,4);
  lcd.backlight();

  back_line.set_focusPosition(Position::LEFT);

  back_line.attach_function(1, go_back);
  back_line.attach_function(2, go_back);

  outputs_line.attach_function(1, goto_outputs_menu);
  outputs_line.attach_function(2, goto_outputs_menu);
  inputs_line.attach_function(1, goto_inputs_menu);
  inputs_line.attach_function(2, goto_inputs_menu);

  pin6_line.attach_function(increase, increase_pin6);
  pin6_line.attach_function(decrease, decrease_pin6);

  oSave_line.attach_function(1, save_output);
  oSave_line.attach_function(2, save_output);
  iSave_line.attach_function(1, save_input);
  iSave_line.attach_function(2, save_input);
  iSample_line.attach_function(increase, increase_samplePeriod);
  iSample_line.attach_function(decrease, decrease_samplePeriod);

  input_saved = (char*)" *";
  output_saved = (char*)" *";
  
  menu_system.update();
  DateTime now = rtc.now();
  Serial.print(timeBuffer);
  Serial.print(now.hour());
}


void loop() {
  rtc.begin();
  DateTime now = rtc.now();
  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  if (!rtc.isrunning()) {
    Serial.println("RTC lost power, lets set the time!");
    // Comment out below lines once you set the date & time.
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }
  sprintf(timeBuffer, "%04d/%02d/%02d, %02d:%02d:%02d", now.year(), now.month(), now.day(), now.hour(), now.minute(), now.second());
  buttonsCheck();
  static unsigned long lastMillis_sample = 0;
  if (millis() - lastMillis_sample > (sample_period * 1000)) {
    lastMillis_sample = millis();
    menu_system.update();
  }
  Serial.print(timeBuffer);
  //Serial.print(now.hour());
}

⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮

prints the above but with very odd characters, now.hour only prints those types of q marks but timeBuffer produces that with a bunch of odd symbols

by converting to a int in a void

Please stop referring to functions as voids. If you were using a function that returned an int would you refer to it as an int ?

I tried a old sketch to make sure the sensor works fine, which uses the same clock code for setting the time to the sketch upload time by pc. The sensor does work fine.

UKHeliBob:
Please stop referring to functions as voids. If you were using a function that returned an int would you refer to it as an int ?

Just trying to make it simple when looking for the right part of the code, thought by saying void instead of declaration, definition, or function might be simpler and straighter to the point to avoid confusion.

thought by saying void instead of declaration, definition, or function might be simpler and straighter to the point to avoid confusion.

Then you thought wrongly

It would make much more sense to say

"that person uses wire.h to communicate data by converting to a int in a function"

UKHeliBob:
Then you thought wrongly

It would make much more sense to say

“that person uses wire.h to communicate data by converting to a int in a function”

I appreciate the grammar correction, but would like to stay on task.

#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;
// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;
char timeBuffer[25] = "";

enum FunctionTypes {
  increase = 1,
  decrease = 2,
};

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidLine welcome_line3(1, 2, timeBuffer);
LiquidScreen welcome_screen(welcome_line1, welcome_line2, welcome_line3);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
   LiquidSystem object combines the LiquidMenu objects to form
   a menu system. It provides the same functions as LiquidMenu
   with the addition of add_menu() and change_menu().
*/
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
  if (right.check() == LOW) {
    menu_system.next_screen();
  }
  if (left.check() == LOW) {
    menu_system.previous_screen();
  }
  if (up.check() == LOW) {
    menu_system.call_function(increase);
  }
  if (down.check() == LOW) {
    menu_system.call_function(decrease);
  }
  if (enter.check() == LOW) {
    menu_system.switch_focus();
  }
}

// Callback function that will be attached to back_line.
void go_back() {
  // This function takes reference to the wanted menu.
  menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
  menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
  menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
  if (pin6_level < 225) {
    pin6_level += 25;
  }
  else {
    pin6_level = 250;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void decrease_pin6() {
  if (pin6_level > 25) {
    pin6_level -= 25;
  }
  else {
    pin6_level = 0;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void save_input() {
  EEPROM.put(11, sample_period);
  input_saved = (char*)" *";
}

void save_output() {
  EEPROM.put(9, pin6_level);
  output_saved = (char*)" *";
}

void increase_samplePeriod() {
  if (sample_period < 10) {
    sample_period++;
    input_saved = (char*)"  ";
  }
}

void decrease_samplePeriod() {
  if (sample_period > 0) {
    sample_period--;
    input_saved = (char*)"  ";
  }
}



void setup() {
  Serial.begin(250000);
  lcd.begin(20,4);
  Wire.begin();
  pinMode(pin6, OUTPUT);

  // Reads the values recorded in the EEPROM
  EEPROM.get(9, pin6_level);
  EEPROM.get(11, sample_period);
  analogWrite(pin6, pin6_level);


  lcd.init();
  lcd.begin(20,4);
  lcd.backlight();

  back_line.set_focusPosition(Position::LEFT);

  back_line.attach_function(1, go_back);
  back_line.attach_function(2, go_back);

  outputs_line.attach_function(1, goto_outputs_menu);
  outputs_line.attach_function(2, goto_outputs_menu);
  inputs_line.attach_function(1, goto_inputs_menu);
  inputs_line.attach_function(2, goto_inputs_menu);

  pin6_line.attach_function(increase, increase_pin6);
  pin6_line.attach_function(decrease, decrease_pin6);

  oSave_line.attach_function(1, save_output);
  oSave_line.attach_function(2, save_output);
  iSave_line.attach_function(1, save_input);
  iSave_line.attach_function(2, save_input);
  iSample_line.attach_function(increase, increase_samplePeriod);
  iSample_line.attach_function(decrease, decrease_samplePeriod);

  input_saved = (char*)" *";
  output_saved = (char*)" *";
  
  menu_system.update();
  Serial.print(timeBuffer);
}


void loop() {
  buttonsCheck();
  static unsigned long lastMillis_sample = 0;
  if (millis() - lastMillis_sample > (sample_period * 1000)) {
    lastMillis_sample = millis();
    menu_system.update();
  }
}

Theres the menu cleaned up from the rtc, besides the include in the beginning. I plan on splicing in a rtc example that works into this, well… hope to.

I tried this example:

Doesn’t produce readable output, just nonstop unreadable characters.

This one works:

However I see it states if wanting to use for alarms and extras besides time, should use the rtc library that was previously attempting to use.
Even though only using wire.h and not the rtc library, it prints time to serial fine just how i’d like it printed to the lcd, and each time variable(hour min sec) are all defined, so I would imagine that it should be simple to write a condition that turns a pin HIGH or LOW if the time is after or between a set point.

#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"

#define DS1307_ADDRESS 0x68

LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;

// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val) {
	return ((val / 16 * 10) + (val % 16));
}
int printDate() {

	// Reset the register pointer
	Wire.beginTransmission(DS1307_ADDRESS);

	byte zero = 0x00;
	Wire.write(zero);
	Wire.endTransmission();

	Wire.requestFrom(DS1307_ADDRESS, 7);

	int second = bcdToDec(Wire.read());
	int minute = bcdToDec(Wire.read());
	int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
	int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
	int monthDay = bcdToDec(Wire.read());
	int month = bcdToDec(Wire.read());
	int year = bcdToDec(Wire.read());
	//print the date EG   3/1/11 23:59:59
	int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);
	return printTime;
}
int lcdTime = printDate();

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;

enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidLine welcome_line3(1, 2, lcdTime);
LiquidScreen welcome_screen(welcome_line1, welcome_line2, welcome_line3);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
   LiquidSystem object combines the LiquidMenu objects to form
   a menu system. It provides the same functions as LiquidMenu
   with the addition of add_menu() and change_menu().
*/
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
	if (right.check() == LOW) {
		menu_system.next_screen();
	}
	if (left.check() == LOW) {
		menu_system.previous_screen();
	}
	if (up.check() == LOW) {
		menu_system.call_function(increase);
	}
	if (down.check() == LOW) {
		menu_system.call_function(decrease);
	}
	if (enter.check() == LOW) {
		menu_system.switch_focus();
	}
}

// Callback function that will be attached to back_line.
void go_back() {
	// This function takes reference to the wanted menu.
	menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
	menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
	menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
	if (pin6_level < 225) {
		pin6_level += 25;
	}
	else {
		pin6_level = 250;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void decrease_pin6() {
	if (pin6_level > 25) {
		pin6_level -= 25;
	}
	else {
		pin6_level = 0;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void save_input() {
	EEPROM.put(11, sample_period);
	input_saved = (char*)" *";
}

void save_output() {
	EEPROM.put(9, pin6_level);
	output_saved = (char*)" *";
}

void increase_samplePeriod() {
	if (sample_period < 10) {
		sample_period++;
		input_saved = (char*)"  ";
	}
}

void decrease_samplePeriod() {
	if (sample_period > 0) {
		sample_period--;
		input_saved = (char*)"  ";
	}
}



void setup() {
	Serial.begin(250000);
	lcd.begin(20, 4);
	//Wire.begin();
	pinMode(pin6, OUTPUT);

	// Reads the values recorded in the EEPROM
	EEPROM.get(9, pin6_level);
	EEPROM.get(11, sample_period);
	analogWrite(pin6, pin6_level);


	lcd.init();
	lcd.begin(20, 4);
	lcd.backlight();

	back_line.set_focusPosition(Position::LEFT);

	back_line.attach_function(1, go_back);
	back_line.attach_function(2, go_back);

	outputs_line.attach_function(1, goto_outputs_menu);
	outputs_line.attach_function(2, goto_outputs_menu);
	inputs_line.attach_function(1, goto_inputs_menu);
	inputs_line.attach_function(2, goto_inputs_menu);

	pin6_line.attach_function(increase, increase_pin6);
	pin6_line.attach_function(decrease, decrease_pin6);

	oSave_line.attach_function(1, save_output);
	oSave_line.attach_function(2, save_output);
	iSave_line.attach_function(1, save_input);
	iSave_line.attach_function(2, save_input);
	iSample_line.attach_function(increase, increase_samplePeriod);
	iSample_line.attach_function(decrease, decrease_samplePeriod);

	input_saved = (char*)" *";
	output_saved = (char*)" *";

	menu_system.update();
}


void loop() {
	buttonsCheck();
	static unsigned long lastMillis_sample = 0;
	if (millis() - lastMillis_sample > (sample_period * 1000)) {
		lastMillis_sample = millis();
		menu_system.update();
	}
}
In file included from C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:4:0:

C:\Users\Bob\Documents\Arduino\libraries\LiquidMenu-1.4.1\src/LiquidMenu.h:55:97: note: #pragma message: LiquidMenu: Configured for I2C. Edit 'LiquidMenu_config.h' file to change it.

 #pragma message ("LiquidMenu: Configured for I2C. Edit 'LiquidMenu_config.h' file to change it.")

                                                                                                 ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino: In function 'int printDate()':

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:25: warning: left operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                         ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:29: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                             ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:38: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                      ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:42: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                          ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:47: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                               ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:51: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                                   ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:56: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                                        ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:60: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                                            ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:67: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                                                   ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:44:71: warning: right operand of comma operator has no effect [-Wunused-value]

  int printTime = (month,'/',monthDay,'/',year,' ',hour,':',minute,':',second);

                                                                       ^

C:\Users\Bob\Documents\Arduino\sep12rtc\sep12rtc.ino:39:6: warning: unused variable 'weekDay' [-Wunused-variable]

  int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday

      ^
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"

#define DS1307_ADDRESS 0x68

LiquidCrystal_I2C lcd(0x27, 20, 4);

// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val) {
  return ((val / 16 * 10) + (val % 16));
}
int printDate() {

  // Reset the register pointer
  Wire.beginTransmission(DS1307_ADDRESS);

  byte zero = 0x00;
  Wire.write(zero);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_ADDRESS, 7);

  int second = bcdToDec(Wire.read());
  int minute = bcdToDec(Wire.read());
  int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
  int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
  int monthDay = bcdToDec(Wire.read());
  int month = bcdToDec(Wire.read());
  int year = bcdToDec(Wire.read());
  //print the date EG   3/1/11 23:59:59
  int printTime = (month, '/', monthDay, '/', year, ' ', hour, ':', minute, ':', second);
  Serial.print(month);
  Serial.print("/");
  Serial.print(monthDay);
  Serial.print("/");
  Serial.print(year);
  Serial.print(" ");
  Serial.print(hour);
  Serial.print(":");
  Serial.print(minute);
  Serial.print(":");
  Serial.println(second);
}

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;

enum FunctionTypes {
  increase = 1,
  decrease = 2,
};

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidLine welcome_line3(1, 2, printDate);
LiquidScreen welcome_screen(welcome_line1, welcome_line2, welcome_line3);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
   LiquidSystem object combines the LiquidMenu objects to form
   a menu system. It provides the same functions as LiquidMenu
   with the addition of add_menu() and change_menu().
*/
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
  if (right.check() == LOW) {
    menu_system.next_screen();
  }
  if (left.check() == LOW) {
    menu_system.previous_screen();
  }
  if (up.check() == LOW) {
    menu_system.call_function(increase);
  }
  if (down.check() == LOW) {
    menu_system.call_function(decrease);
  }
  if (enter.check() == LOW) {
    menu_system.switch_focus();
  }
}

// Callback function that will be attached to back_line.
void go_back() {
  // This function takes reference to the wanted menu.
  menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
  menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
  menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
  if (pin6_level < 225) {
    pin6_level += 25;
  }
  else {
    pin6_level = 250;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void decrease_pin6() {
  if (pin6_level > 25) {
    pin6_level -= 25;
  }
  else {
    pin6_level = 0;
  }
  analogWrite(pin6, pin6_level);
  output_saved = (char*)"  ";
}

void save_input() {
  EEPROM.put(11, sample_period);
  input_saved = (char*)" *";
}

void save_output() {
  EEPROM.put(9, pin6_level);
  output_saved = (char*)" *";
}

void increase_samplePeriod() {
  if (sample_period < 10) {
    sample_period++;
    input_saved = (char*)"  ";
  }
}

void decrease_samplePeriod() {
  if (sample_period > 0) {
    sample_period--;
    input_saved = (char*)"  ";
  }
}



void setup() {
  Serial.begin(9600);
  lcd.begin(20, 4);
  //Wire.begin();
  pinMode(pin6, OUTPUT);

  // Reads the values recorded in the EEPROM
  EEPROM.get(9, pin6_level);
  EEPROM.get(11, sample_period);
  analogWrite(pin6, pin6_level);


  lcd.init();
  lcd.begin(20, 4);
  lcd.backlight();

  back_line.set_focusPosition(Position::LEFT);

  back_line.attach_function(1, go_back);
  back_line.attach_function(2, go_back);

  outputs_line.attach_function(1, goto_outputs_menu);
  outputs_line.attach_function(2, goto_outputs_menu);
  inputs_line.attach_function(1, goto_inputs_menu);
  inputs_line.attach_function(2, goto_inputs_menu);

  pin6_line.attach_function(increase, increase_pin6);
  pin6_line.attach_function(decrease, decrease_pin6);

  oSave_line.attach_function(1, save_output);
  oSave_line.attach_function(2, save_output);
  iSave_line.attach_function(1, save_input);
  iSave_line.attach_function(2, save_input);
  iSample_line.attach_function(increase, increase_samplePeriod);
  iSample_line.attach_function(decrease, decrease_samplePeriod);

  input_saved = (char*)" *";
  output_saved = (char*)" *";

  menu_system.update();
}


void loop() {
  buttonsCheck();
  printDate();
  static unsigned long lastMillis_sample = 0;
  if (millis() - lastMillis_sample > (sample_period * 1000)) {
    lastMillis_sample = millis();
    menu_system.update();
  }
}

Hmm the baud rate of serial in setup matters when it comes to the output printed to the serial monitor.
This example prints the time repeatedly to serial but the 3rd line on the lcd says “2”