Date on RTC DS3231

How to change the date of the DS3231 automatically that is shown on an LCD without manually changing the codes? Example, when it is 11:59pm of 01.07.2018, when it goes to 00:00am the date will also change to 01.08.2018. Thanks

#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <DS3231.h> 

// Init the DS3231 using the hardware interface

#define I2C_ADDR          0x3F        //Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN      3
#define En_pin             2
#define Rw_pin             1
#define Rs_pin             0
#define D4_pin             4
#define D5_pin             5
#define D6_pin             6
#define D7_pin             7

//Initialise the LCD
LiquidCrystal_I2C      lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
DS3231  rtc(SDA, SCL);
void setup()
{
  // Setup Serial connection
  Serial.begin(115200);

  // Initialize the rtc object
  rtc.begin();
  //Define the LCD as 16 column by 2 rows
  lcd.begin (16, 2);

  // The following lines can be uncommented to set the date and time
  //  rtc.setTime(06, 58, 40);     // Set the time to 12:00:00 (24hr format)
  // rtc.setDate(1, 8, 2018);   // Set the date to January 1st, 2014
}

void loop()
{
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");

  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());

  //Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);

  //goto first column (column 0) and first line (Line 0)
  lcd.setCursor(0, 0);

  //Print at cursor Location
  lcd.print("Time: ");
  lcd.print(rtc.getTimeStr());

  //goto first column (column 0) and second line (line 1)
  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(rtc.getDateStr());

  // Wait one second before repeating :)
  delay (1000);
}

Which library are you using?

why do you think it does not work?
every second your Arduino will do

  //Print at cursor Location
  lcd.print("Time: ");
  lcd.print(rtc.getTimeStr());

  //goto first column (column 0) and second line (line 1)
  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(rtc.getDateStr());

so will update both the time and the date


side note — This belongs to the setup()

  //Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);

I want to make the date change whenever the time goes 00:00:00. I have no idea what codes I should use. Should I use if statements? for-loop? etc

i'm using the DS3231 library

matoito:
i'm using the DS3231 library

WHICH ONE? there are hundreds of them... a link to the one you picked would be appropriate...

I want to make the date change whenever the time goes 00:00:00.

The DS3231 does that automatically.

The date on the display won't change until you read the date and display it.

matoito:
I want to make the date change whenever the time goes 00:00:00. I have no idea what codes I should use. Should I use if statements? for-loop? etc

are you saying that when the time is 00:00:00 the date shown is still the previous day and has not moved to the new day?

http://www.rinkydinkelectronics.com/library.php?id=73 i got it here

jremington:
The DS3231 does that automatically.

The date on the display won't change until you read the date and display it.

how to read the date?

J-M-L:
are you saying that when the time is 00:00:00 the date shown is still the previous day and has not moved to the new day?

yes. that's what happening right now. it's still the previous day

matoito:
DS3231 - Rinky-Dink Electronics i got it here

OK

yes. that's what happening right now. it's still the previous day

and 1 second later at 00:00:01 it becomes correct?

J-M-L:
OK and 1 second later at 00:00:01 it becomes correct?

nope. it stays the same. the date does not update.

does the date ever display on your LCD? (I usually use adafruit RTClib and never got any issue)

J-M-L:
does the date ever display on your LCD?

Yep. It does.

gee can you provide full sentences and description of what's going on exactly? or do I need to ask for every single detail?

take pictures of what happens and post them. do something... help us understand what you see... how you wired stuff, how it's powered etc...

I'll gonna try that library u said and then Imma update you when its working or not. So, when I set the date and time using the codes I used, the date will usually update when the time goes 00:00 for example? Am I right? Hehehe

@matoito: Please read the "How to use this forum" post and follow the directions.

Try my code from the post at this link:
https://forum.arduino.cc/index.php?topic=444702.msg3060986#msg3060986

What happens this time?