Changing out LCD display to Nextion Display

Greetings,

For my very first project, I have made a simple clock using an Arduino Nano, DS3231 RTC and an I2C 1602 Serial LCD Module, and it works great!

I was thinking about adding some buttons so I can change the date and time but decided to add a small Nextion touch screen instead.

I can get the code to print the day of the week, but am having problems getting it to print the month day and year as well as the time.

I have included the code I have so far and a Photoshopped image on how I would like it to look.

Can anyone point me in the right direction and maybe some links to examples? I’ve watched many YouTube videos, but still can’t find what I’m looking for.

Thank in advance for any help. :slight_smile:

#include <SparkFunDS1307RTC.h>
#include <Nextion.h>

//Declare your Nextion objects , pageid, component id., component name
NexText t0 = NexText(0,2,"t0"); // Text box for day of the week. i.e. Wednesday
NexText t1 = NexText(0,3,"t1"); // Text box for date. i.e. June 16, 2019
NexText t2 = NexText(0,4,"t2"); // Text box for time. i.e. 8:46 PM 

void setup() 
{
Serial.begin(9600); // Set the baud rate to use the serial monitor to view time/date output
rtc.begin();        // Call rtc.begin() to initialize the library
}

void loop() 
{
rtc.update();

// Print the day of the week in text box t0 on the Nextion display. i.e. Wednesday
t0.setText (rtc.dayStr()); // THIS LINE WORKS GREAT!

// Print the month, day and year in text box t1 on the Nextion display. i.e. June 16, 2019
// I HAVE NO IDEA HOW TO STRUCTURE THIS LINE.

// Print the time in text box t2 on the Nextion display. i.e. 8:46 PM
// I HAVE NO IDEA HOW TO STRUCTURE THIS LINE.

delay(5000);
}

Home_Screen.png