Nextion gui coding help

Hi, I’m working on a pill management system using an Arduino with a Nextion Nx3224T028_011 touchscreen.

Features

Main Screen Page

  • Displays the current time
  • Shows how many hours remain until the next pill needs to be taken
  • Indicates which pill is starting to run low

Settings Menu Page

  • Change language
  • Reset all pill data

Information Screen Page

  • Shows:
    • How many different pills are registered
    • How many of each pill are left
    • How many days the remaining pills will last (based on dosage)
  • You can update pill quantities:
    • Select a pill from a dropdown list
    • Press positive button to add more
    • Press negative button to reduce the amount

Add New Pill Page

  • Select which days of the week the pill should be taken (multi-select) using multiple buttons
  • Set the time for taking the pill using + and - button
  • Enter total quantity using + and - button
  • Enter dosage per intake using + and - button

Design Choices

  • Pills are automatically named when saved (Pill1, Pill2, etc.), instead of manually entering names
  • For dosage and total quantity, I use β€œ+” and β€œβ€“β€ buttons instead of typing values, to make it easier to adjust

If anyone has suggestions for improving the UI, structure, or logic (especially on the Nextion side or Arduino handling), I’d really appreciate the feedback i havent coded anything on the arduino yet because i wanted to make a working gui the arduino has everything i need i just need to code it which i havent done and dont have a full idea on how to do.

here are the pictures and i think nearly all of the code somne stuff also doesnt work for instance the edit_amount etc



couldnt upload all pictures so took of the most important pages

program.s

int sys0=0,sys1=0,sys2=0
baud=9600
dim=100
recmod=0
printh 00 00 00 ff ff ff 88 ff ff ff
page home

add page
bDosePlus button

nDose.val+=1
tDose.txt="Dose: "+nDose.val
tDays.txt="Days left: "+(nTotal.val/nDose.val)

bDoseMinus button

if(nDose.val>1)
{
  nDose.val-=1
}
tDose.txt="Dose: "+nDose.val
tDays.txt="Days left: "+(nTotal.val/nDose.val)

bTotalPlus Button

nTotal.val+=1
tTotal.txt="Total: "+nTotal.val
tDays.txt="Days left: "+(nTotal.val/nDose.val)

bTotalMinus Button

if(nTotal.val>0)
{
  nTotal.val-=1
}
tTotal.txt="Total: "+nTotal.val
tDays.txt="Days left: "+(nTotal.val/nDose.val)

i would appreactiate if someone could help me also if i could get it explained because i am pretty new to this and i feel like its very hard to code it.

if possible would appreciate help coding the nexion because i am having a hard time understand it and the information online is limited

Here are the last pictures


Does it work?

Looks interesting!
Can you post your annotated schematic and also post links to the technical data of the non Arduino hardware items.

So the code doesnt work no and i havent made any arduino code because i am trying to understand how to make the gui and then after be able to communicate with the arduino to show data etc

The hardware we are using is

  • 1 KY-006 Passiv buzzer
  • 4 TLC5940 16 Kanal LED Driver
  • 21 RGB LED common cathode
  • 2 CD74HC4067 16-kanals analog
  • 21 Light SensorPhotoresistor (LDR)
  • 1 LCD touch screen NEXTION NX3224T028
  • 1 Toggle switch
  • 1 DS3231 RTC

and then some other stuff like wires and resistors etc
but basically the function is that we have a grid of 3x7 and every grid has 1 led and 1 light sensor and bascially the system we want to make is the one i already explained with being able to add pills and it calucaletes the days etc and also how long until next pills have to be taken but also it has to have a grid system fro instance if they choose mon and thu then the lights on the mon and thu light up from red to green etc so bascailly like a sorting system where it keeps track of it. Short said i just need a basic understand on how to make the gui work and how to make the arduino work with it. The rest i should be able to code by my self.

Thanks for your help.

Unless you plan to use the Nextion on its own without an associated Arduino or other micro-controller then I suggest you do all the processing on the Arduino. So, you press a button, the button press is sent to the Arduino, the Arduino does whatever processing is required and the result sent back to the Nextion. Doing things this way ensures that all the data about what the system is doing is all in one place: the Arduino.

If you do any processing on the Nextion then the Arduino doesn't know about it, so, if the Arduino is to do anything then there has to be something that updates the Arduino about what has happened on the Nextion.

There are 2 tutorials on this forum about using Nextion displays, mine is here:

Within the introduction to mine there is a link to the other one. The methods used in each are entirely different, use whichever works best for you.

Based on what you have posted I am not clear what specifically you want help with.

Sorry if what I wrote was a bit confusing. Basically I just want help with understanding how to send button presses to the arduino and how to make the arduino change the text boxes for instance the one in the picture that looks like a clock and make it work with a real time clock so it updates and shows the current time on the screen. This si somewhat what I need help with understanding

See my tutorial.

I thought the GUI was shown in Post #1... but I guess that is just the editor...

There are examples on the internet... for example... Nextion Display with Arduino - Getting Started | Random Nerd Tutorials

I can recommend the use of the Easy Nextion Library which is also linked in the tutorial by @PerryBebbington.

It is the experience of many Nextion users that the ITEAD library has many issues and is not recommended. Either use the methods of @PerryBebbington or the Easy Nextion Library.

This is a want-a-be word salad. There are thousands of ways to interconnect these devices and without know the way you are doing it I cannot be of much help.

These two statements indicate to me this is a class project, If so what is the class and when is it due?

So i have gotten som of it to work and communicate with the arduino mega. All of the buttons have a printh on the Touch Release Event for instance the main home page has 3 buttons Add Pill, Info and Settings they have the printh
printh 23 02 54 01 printh 23 02 54 01 printh 23 02 54 03 etc
but for some reason it doesnt work on the arduino code because when i press a button it doesnt print anything in the serial monitor. What did i do wrong?
Here is my current script

#include <EasyNextionLibrary.h>
#include <DS1302.h>

// ─── NEXTION ─────────────────────────
EasyNex myNex(Serial1);

// ─── RTC PINS ────────────────────────
#define RST_PIN 8
#define DAT_PIN 7
#define CLK_PIN 6

DS1302 rtc(RST_PIN, DAT_PIN, CLK_PIN);

// ─── VARIABLES ───────────────────────
int totalPills = 10;
int dosePerDay = 1;

char buf[32];

// ─── HELPERS ─────────────────────────
void setTxt(const char* obj, const char* txt) {
  myNex.writeStr(obj, txt);
}

void setTxtInt(const char* obj, int val) {
  itoa(val, buf, 10);
  myNex.writeStr(obj, buf);
}

// ═════════════════════════════════════
// BUTTON TRIGGERS
// ═════════════════════════════════════

void trigger1() {
  Serial.println("Add pressed");
  setTxt("tWarning.txt", "Add pressed");
}

void trigger2() {
  Serial.println("Info pressed");
  setTxt("tWarning.txt", "Info pressed");
}

void trigger3() {
  Serial.println("Settings pressed");
  setTxt("tWarning.txt", "Settings pressed");
}

void trigger11() {
  totalPills++;
  setTxtInt("tTotal.txt", totalPills);
  Serial.println("Total +");
}

void trigger12() {
  totalPills--;
  setTxtInt("tTotal.txt", totalPills);
  Serial.println("Total -");
}

void trigger13() {
  dosePerDay++;
  setTxtInt("tDose.txt", dosePerDay);
  Serial.println("Dose +");
}

void trigger14() {
  dosePerDay--;
  setTxtInt("tDose.txt", dosePerDay);
  Serial.println("Dose -");
}

void trigger15() {
  setTxt("tWarning.txt", "Saved!");
  Serial.println("Saved");
}

// ═════════════════════════════════════
// SETUP
// ═════════════════════════════════════
void setup() {
  Serial.begin(9600);
  myNex.begin(9600);

  rtc.halt(false);
  rtc.writeProtect(false);

  // SET TIME (RUN ONCE THEN COMMENT OUT)
  rtc.setTime(16, 38, 0);   // hour, minute, second
  rtc.setDate(14, 4, 2026); // day, month, year

  delay(500);

  setTxt("tWarning.txt", "System Ready");
}

// ═════════════════════════════════════
// LOOP
// ═════════════════════════════════════
unsigned long lastTime = 0;

void loop() {
  myNex.NextionListen();

  if (millis() - lastTime > 1000) {
    lastTime = millis();

    Time t = rtc.getTime();

    sprintf(buf, "%02d:%02d:%02d", t.hour, t.min, t.sec);

    setTxt("tTime.txt", buf);

    Serial.println(buf);
  }
}

Im using the easy nextion library and the DS1302 library from GitHub - msparks/arduino-ds1302: Arduino library for the DS1302 Real Time Clock chip Β· GitHub

The timer "tTime" does update and show the current time using the DS1302 so that works.

but for some reason it doesnt work on the arduino code because when i press a button it doesnt print anything in the serial monitor. What did i do wrong?

One possibility is that you have the send component id box checked.

If that is not the cause, then ifyou look on the github page for the Easy Nextion Library there is example code for a trigger function. There is both Arduino and HMI code for the example.

Can you run the example code?

i am unable to get anything to work with the screen it also now doesnt update the time anymore and just shows the placeholder string. I tried making like a debug code to see what page im on and what button is pressed but it doesnt show the correct page and also doesnt print when i press a button

i have checked all of my buttons and checked that the printh are correct
for instance on the add pill button i have in the Touch press event a page add
and then in the Touch release event printh 23 02 54 01
and it also prints it when i press the button in debug but when i try it with my code nothing happens. I tried using claude ai to help me code some of it because i wasent understanding it and it helped get the DS1302 working but the lcd + arduino i wasnt able to get it working neither with the help from claude.

The code also says tWarning that it changes it to "System Ready" but it just keeps saying "All good"
here is the code

/*
 * Medicine Box
 * Arduino Mega + DS1302 (msparks library) + Nextion + EasyNextionLibrary
 *
 * WIRING:
 *   Nextion TX  -> Mega pin 19 (RX1)
 *   Nextion RX  -> Mega pin 18 (TX1)
 *   Nextion VCC -> 5V PSU rail (NOT Mega 5V pin)
 *   Nextion GND -> GND
 *
 *   DS1302 RST  -> Mega pin 28
 *   DS1302 DAT  -> Mega pin 27
 *   DS1302 CLK  -> Mega pin 26
 *   DS1302 VCC  -> 5V
 *   DS1302 GND  -> GND
 *
 * LIBRARIES (Library Manager):
 *   EasyNextionLibrary  by Seithan
 *   DS1302              by msparks
 *
 * NEXTION EDITOR - each button Touch Release Event:
 *   printh 23 02 54 XX   (XX = trigger number from table below)
 *   Each page Preinitialize Event:
 *   printh 23 02 50 XX   (XX = page number: 00..05)
 *
 * TRIGGER TABLE:
 *   01=bAdd  02=bInfo  03=bSettings
 *   04=bMon  05=bTue   06=bWed  07=bThu  08=bFri  09=bSat  0A=bSun
 *   0B=bTotalPlus  0C=bTotalMinus  0D=bDosePlus  0E=bDoseMinus
 *   0F=bSave  10=bBack(add)
 *   11=bEdit  12=bBack(info)
 *   13=bLang  14=bReset  15=bBack(settings)
 *   16=bSelectPlus  17=bSelectMinus  18=bApply  19=bBack(edit_amount)
 *   1A=bDanishLan  1B=bEnglishLan  1C=bBack(language)
 */

#include <EasyNextionLibrary.h>
#include <DS1302.h>

// ─── Nextion on Serial1 ───────────────────────────────────────────────────────
EasyNex myNex(Serial1);

// ─── DS1302: RST=8, DAT=7, CLK=6  (matches wiring comment above) ──────────
DS1302 rtc(8, 7, 6);

#define DEBUG true

// ─── Days of week ─────────────────────────────────────────────────────────────
// msparks: dow Sun=1, Mon=2, Tue=3, Wed=4, Thu=5, Fri=6, Sat=7
const char* DOW[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};

// ─── App state ────────────────────────────────────────────────────────────────
int  totalPills = 10;
int  dosePerDay = 1;
int  editIndex  = 0;
bool isEnglish  = true;
bool days[7]    = {false};  // 0=Mon 1=Tue 2=Wed 3=Thu 4=Fri 5=Sat 6=Sun

char buf[40];

// ─── Helpers ─────────────────────────────────────────────────────────────────
void sendStr(const char* comp, const char* val) {
  myNex.writeStr(comp, val);
  if (DEBUG) {
    Serial.print(F("  -> ")); Serial.print(comp);
    Serial.print(F(" = \"")); Serial.print(val); Serial.println(F("\""));
  }
}

void sendInt(const char* comp, int v) {
  itoa(v, buf, 10);
  sendStr(comp, buf);
}

void buildDaysString() {
  const char* labels[] = {"Mo","Tu","We","Th","Fr","Sa","Su"};
  buf[0] = '\0';
  bool any = false;
  for (uint8_t i = 0; i < 7; i++) {
    if (!days[i]) continue;
    if (any) strlcat(buf, " ", sizeof(buf));
    strlcat(buf, labels[i], sizeof(buf));
    any = true;
  }
  if (!any) strlcpy(buf, isEnglish ? "None" : "Ingen", sizeof(buf));
}

void refreshAddPage() {
  sendInt("tTotal.txt",   totalPills);
  sendInt("tDose.txt",    dosePerDay);
  sendStr("tTimeSet.txt", "08:00");
  buildDaysString();
  sendStr("tDays.txt", buf);
}

// ─── Page change handler ──────────────────────────────────────────────────────
void onPageChange(int newPage) {
  if (DEBUG) {
    Serial.print(F("[PAGE] -> ")); Serial.println(newPage);
  }
  switch (newPage) {
    case 1:
      refreshAddPage();
      break;
    case 2:
      sendStr("tList.txt",
        "1. Paracetamol\n   500mg 2x/day Mo-Fr\n\n"
        "2. Vitamin D\n   1000IU 1x/day daily");
      break;
    case 4:
      snprintf(buf, sizeof(buf), "Medicine %d", editIndex + 1);
      sendStr("tSelected.txt",     buf);
      sendStr("tListofpills.txt",  "1. Paracetamol\n2. Vitamin D");
      sendStr("tSelectedPill.txt", "Paracetamol");
      break;
  }
}

// ═══════════════════════════════════════════════════════════════════════════════
//  TRIGGER FUNCTIONS  (called automatically by NextionListen)
// ═══════════════════════════════════════════════════════════════════════════════

void trigger1()  { if(DEBUG) Serial.println(F("[BTN] bAdd"));      refreshAddPage(); }
void trigger2()  { if(DEBUG) Serial.println(F("[BTN] bInfo")); }
void trigger3()  { if(DEBUG) Serial.println(F("[BTN] bSettings")); }

// Day toggles – each one updates the display immediately
void trigger4()  { days[0]^=1; buildDaysString(); sendStr("tDays.txt",buf); if(DEBUG){Serial.print(F("[DAY] Mon="));Serial.println(days[0]);} }
void trigger5()  { days[1]^=1; buildDaysString(); sendStr("tDays.txt",buf); if(DEBUG){Serial.print(F("[DAY] Tue="));Serial.println(days[1]);} }
void trigger6()  { days[2]^=1; buildDaysString(); sendStr("tDays.txt",buf); if(DEBUG){Serial.print(F("[DAY] Wed="));Serial.println(days[2]);} }
void trigger7()  { days[3]^=1; buildDaysString(); sendStr("tDays.txt",buf); if(DEBUG){Serial.print(F("[DAY] Thu="));Serial.println(days[3]);} }
void trigger8()  { days[4]^=1; buildDaysString(); sendStr("tDays.txt",buf); if(DEBUG){Serial.print(F("[DAY] Fri="));Serial.println(days[4]);} }
void trigger9()  { days[5]^=1; buildDaysString(); sendStr("tDays.txt",buf); if(DEBUG){Serial.print(F("[DAY] Sat="));Serial.println(days[5]);} }
void trigger10() { days[6]^=1; buildDaysString(); sendStr("tDays.txt",buf); if(DEBUG){Serial.print(F("[DAY] Sun="));Serial.println(days[6]);} }

void trigger11() { totalPills++;          sendInt("tTotal.txt",totalPills); if(DEBUG){Serial.print(F("[TOTAL] "));Serial.println(totalPills);} }
void trigger12() { if(totalPills>1)totalPills--; sendInt("tTotal.txt",totalPills); if(DEBUG){Serial.print(F("[TOTAL] "));Serial.println(totalPills);} }
void trigger13() { dosePerDay++;          sendInt("tDose.txt",dosePerDay);  if(DEBUG){Serial.print(F("[DOSE] ")); Serial.println(dosePerDay);} }
void trigger14() { if(dosePerDay>1)dosePerDay--; sendInt("tDose.txt",dosePerDay); if(DEBUG){Serial.print(F("[DOSE] ")); Serial.println(dosePerDay);} }

void trigger15() { if(DEBUG)Serial.println(F("[BTN] bSave"));     sendStr("tWarning.txt", isEnglish?"Saved!":"Gemt!"); }
void trigger16() { if(DEBUG)Serial.println(F("[BTN] bBack add")); }

void trigger17() { if(DEBUG)Serial.println(F("[BTN] bEdit")); editIndex=0; }
void trigger18() { if(DEBUG)Serial.println(F("[BTN] bBack info")); }

void trigger19() { if(DEBUG)Serial.println(F("[BTN] bLang")); }
void trigger20() {
  if(DEBUG)Serial.println(F("[BTN] bReset"));
  totalPills=10; dosePerDay=1; isEnglish=true;
  memset(days,0,sizeof(days));
  sendStr("tWarning.txt","System reset!");
  sendStr("tNext.txt","--:--");
}
void trigger21() { if(DEBUG)Serial.println(F("[BTN] bBack settings")); }

void trigger22() {
  editIndex++;
  snprintf(buf,sizeof(buf),"Medicine %d",editIndex+1);
  sendStr("tSelected.txt",buf);
  if(DEBUG){Serial.print(F("[EDIT] "));Serial.println(editIndex);}
}
void trigger23() {
  if(editIndex>0) editIndex--;
  snprintf(buf,sizeof(buf),"Medicine %d",editIndex+1);
  sendStr("tSelected.txt",buf);
  if(DEBUG){Serial.print(F("[EDIT] "));Serial.println(editIndex);}
}
void trigger24() { if(DEBUG)Serial.println(F("[BTN] bApply")); sendStr("tWarning.txt",isEnglish?"Updated!":"Opdateret!"); }
void trigger25() { if(DEBUG)Serial.println(F("[BTN] bBack edit")); }

void trigger26() { isEnglish=false; if(DEBUG)Serial.println(F("[BTN] Danish"));  sendStr("tWarning.txt","Sprog: Dansk"); }
void trigger27() { isEnglish=true;  if(DEBUG)Serial.println(F("[BTN] English")); sendStr("tWarning.txt","Language: English"); }
void trigger28() { if(DEBUG)Serial.println(F("[BTN] bBack lang")); }

// ═══════════════════════════════════════════════════════════════════════════════
//  SETUP
// ═══════════════════════════════════════════════════════════════════════════════
void setup() {
  Serial.begin(9600);
  Serial.println(F("=== Medicine Box booting ==="));

  rtc.halt(false);
  rtc.writeProtect(false);

  // ── Set time ONCE: uncomment, upload, re-comment, upload again ────────────
  // Time t(2026, 4, 14, 12, 0, 0, Time::kMonday);
  // rtc.time(t);

  Serial.println(F("[RTC] DS1302 OK"));

  myNex.begin(9600);
  Serial.println(F("[NEX] Serial1 ready"));

  delay(600);
  sendStr("tWarning.txt", "System ready");
  sendStr("tNext.txt",    "Next: --:--");

  Serial.println(F("[INIT] Boot complete."));
}

// ═══════════════════════════════════════════════════════════════════════════════
//  LOOP  β€” RTC polled with millis(), NOT every iteration
// ═══════════════════════════════════════════════════════════════════════════════
int  lastPageId  = -1;
unsigned long lastRtcMs = 0;   // ← replaces lastSecond check with millis()

void loop() {
  // ── 1. Always listen first β€” give serial the most CPU time ───────────────
  myNex.NextionListen();

  // ── 2. Page change detection ──────────────────────────────────────────────
  if (myNex.currentPageId != lastPageId) {
    lastPageId = myNex.currentPageId;
    onPageChange(lastPageId);
  }

  // ── 3. RTC update β€” only once per second, not every loop iteration ────────
  //    This prevents the bit-bang DS1302 read from blocking NextionListen()
  if (millis() - lastRtcMs >= 1000) {
    lastRtcMs = millis();

    Time t = rtc.getTime();   // only called ~1x per second now

    // msparks dow: Sun=1 ... Sat=7  β†’  DOW[t.dow - 1]
    snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
             DOW[t.dow - 1], t.hour, t.min, t.sec);

    if (myNex.currentPageId == 0) {
      myNex.writeStr("tTime.txt", buf);
    }

    if (DEBUG) {
      Serial.print(F("[RTC] ")); Serial.print(buf);
      Serial.print(F("  page=")); Serial.println(myNex.currentPageId);
    }
  }
}

this is the output from clicking a bit around in the screen with the code

β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
===========================================
  Medicine Box booting...
===========================================
[RTC] DS1302 OK
[NEX] Nextion ready on Serial1 (pins 18/19)
  -> tWarning.txt = "System ready"
  -> tNext.txt = "Next: --:--"
[INIT] Boot complete.
[PAGE] Switched to page 0
[RTC] Sun 21:32:21  page=0
[RTC] Sun 21:32:22  page=0
[RTC] Sun 21:32:23  page=0
[RTC] Sun 21:32:24  page=0
[RTC] Sun 21:32:25  page=0
[RTC] Sun 21:32:26  page=0
[RTC] Sun 21:32:27  page=0
[RTC] Sun 21:32:28  page=0
[RTC] Sun 21:32:29  page=0
[RTC] Sun 21:32:30  page=0
[RTC] Sun 21:32:31  page=0
[RTC] Sun 21:32:32  page=0
[RTC] Sun 21:32:33  page=0
[RTC] Sun 21:32:34  page=0
[RTC] Sun 21:32:35  page=0
[RTC] Sun 21:32:36  page=0
[RTC] Sun 21:32:37  page=0
[RTC] Sun 21:32:38  page=0
[RTC] Sun 21:32:39  page=0
[RTC] Sun 21:32:40  page=0
[RTC] Sun 21:32:41  page=0
[RTC] Sun 21:32:42  page=0
[RTC] Sun 21:32:43  page=0
[RTC] Sun 21:32:44  page=0
[RTC] Sun 21:32:45  page=0
[RTC] Sun 21:32:46  page=0
[RTC] Sun 21:32:47  page=0
[RTC] Sun 21:32:48  page=0
[RTC] Sun 21:32:49  page=0
[RTC] Sun 21:32:50  page=0
[RTC] Sun 21:32:51  page=0
[RTC] Sun 21:32:52  page=0
[RTC] Sun 21:32:53  page=0
[RTC] Sun 21:32:54  page=0
[RTC] Sun 21:32:55  page=0
[RTC] Sun 21:32:56  page=0
[RTC] Sun 21:32:57  page=0
[RTC] Sun 21:32:58  page=0
[RTC] Sun 21:32:59  page=0
[RTC] Sun 21:33:00  page=0
[RTC] Sun 21:33:01  page=0
[RTC] Sun 21:33:02  page=0
[RTC] Sun 21:33:03  page=0
[RTC] Sun 21:33:04  page=0
[RTC] Sun 21:33:05  page=0
[RTC] Sun 21:33:06  page=0
[RTC] Sun 21:33:07  page=0
[RTC] Sun 21:33:08  page=0
[RTC] Sun 21:33:09  page=0
[RTC] Sun 21:33:10  page=0
[RTC] Sun 21:33:11  page=0
[RTC] Sun 21:33:12  page=0
[RTC] Sun 21:33:13  page=0
[RTC] Sun 21:33:14  page=0
[RTC] Sun 21:33:15  page=0
[RTC] Sun 21:33:16  page=0
[RTC] Sun 21:33:17  page=0
[RTC] Sun 21:33:18  page=0
[RTC] Sun 21:33:19  page=0
[RTC] Sun 21:33:20  page=0
[RTC] Sun 21:33:21  page=0
[RTC] Sun 21:33:22  page=0
[RTC] Sun 21:33:23  page=0
[RTC] Sun 21:33:24  page=0
[RTC] Sun 21:33:25  page=0
[RTC] Sun 21:33:26  page=0
[RTC] Sun 21:33:27  page=0
[RTC] Sun 21:33:28  page=0
[RTC] Sun 21:33:29  page=0
[RTC] Sun 21:33:30  page=0
[RTC] Sun 21:33:31  page=0
[RTC] Sun 21:33:32  page=0
[RTC] Sun 21:33:33  page=0
[RTC] Sun 21:33:34  page=0
[RTC] Sun 21:33:35  page=0

===========================================
  Medicine Box booting...
===========================================
[RTC] DS1302 OK
[NEX] Nextion ready on Serial1 (pins 18/19)
  -> tWarning.txt = "System ready"
  -> tNext.txt = "Next: --:--"
[INIT] Boot complete.
[PAGE] Switched to page 0
[RTC] Sun 21:42:12  page=0
[RTC] Sun 21:42:13  page=0
[RTC] Sun 21:42:14  page=0
β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘IQ
uοΏ½οΏ½=== Medicine Box booting ===
[RTC] DS1302 OK
[NEX] Serial1 ready
  -> tWarning.txt = "System ready"
  -> tNext.txt = "Next: --:--"
[INIT] Boot complete.
[PAGE] -> 0
[RTC] Sun 21:42:18  page=0
[RTC] Sun 21:42:19  page=0
[RTC] Sun 21:42:20  page=0
[RTC] Sun 21:42:21  page=0
[RTC] Sun 21:42:22  page=0
[RTC] Sun 21:42:23  page=0
[RTC] Sun 21:42:24  page=0
[RTC] Sun 21:42:25  page=0
[RTC] Sun 21:42:26  page=0
[RTC] Sun 21:42:27  page=0
[RTC] Sun 21:42:28  page=0
[RTC] Sun 21:42:29  page=0
[RTC] Sun 21:42:30  page=0
[RTC] Sun 21:42:31  page=0
[RTC] Sun 21:42:32  page=0
[RTC] Sun 21:42:33  page=0
[RTC] Sun 21:42:34  page=0
[RTC] Sun 21:42:35  page=0
[RTC] Sun 21:42:36  page=0
[RTC] Sun 21:42:37  page=0
[RTC] Sun 21:42:38  page=0
[RTC] Sun 21:42:39  page=0
[RTC] Sun 21:42:40  page=0
[RTC] Sun 21:42:41  page=0
[RTC] Sun 21:42:42  page=0
[RTC] Sun 21:42:44  page=0
[RTC] Sun 21:42:45  page=0
[RTC] Sun 21:42:46  page=0
[RTC] Sun 21:42:47  page=0
[RTC] Sun 21:42:48  page=0
[RTC] Sun 21:42:49  page=0
[RTC] Sun 21:42:50  page=0
[RTC] Sun 21:42:51  page=0
[RTC] Sun 21:42:52  page=0
[RTC] Sun 21:42:53  page=0
[RTC] Sun 21:42:54  page=0
[RTC] Sun 21:42:55  page=0
[RTC] Sun 21:42:56  page=0
[RTC] Sun 21:42:57  page=0
[RTC] Sun 21:42:58  page=0
[RTC] Sun 21:42:59  page=0
[RTC] Sun 21:43:00  page=0
[RTC] Sun 21:43:01  page=0
[RTC] Sun 21:43:02  page=0
[RTC] Sun 21:43:03  page=0
[RTC] Sun 21:43:04  page=0
[RTC] Sun 21:43:06  page=0
[RTC] Sun 21:43:07  page=0
[RTC] Sun 21:43:08  page=0
[RTC] Sun 21:43:09  page=0

and this is one of the buttons

i also have added in the preinzialize in every page a printh for instance in the home page i have printh 23 02 50 00

im a bit lost on what i have done wrong as nothing seems to fix this
i alos switch the board from a uno to a mega

The timer "tTime" does update and show the current time using the DS1302 so that works.

i am unable to get anything to work with the screen it also now doesn' t update the time anymore and just shows the placeholder string.

I recommend that you start coding from simple things that work, and build from there. You have way to much hmi and arduino code for this stage of the process.

Start with a single page with a text field to display the time. Fill that with a text string constructed from the ds1302 and sent from the Arduino.

Add a simple button on that page with a trigger1 as a release event.

Once you have those two simple things going, you can proceed from there.

How is the Nextion powered? Is the ground connected to the Mega ground?
Sometimes the dupont wire connectors can be defective so you may want to verify those with a multimeter.

Yeah I did just that and it worked and I am not sure why it worked because the only things I did was remove some page β€œid” from the nextion editor and finally understood the trigger system.

Great news. You obviously have the Nextion/Arduino Serial communication issues worked out and you can build from here.

If you need more help as you move forward and develop a more complex program, it will be important to post the complete Arduino code and the associated .hmi file. You will need to zip the hmi file and add it using the upload icon.