Regarding the connection between the Mega and the Nextion, are you cross connected rx>tx and tx>rx? What pins are you using for Serial1 on the Mega? Is the ground of the Nextion connected to the ground of the Arduino? How is the Nextion being powered?
Are there multiple pages in your HMI program on the Nextion. Are you on the correct page when you try to write the text box?
I would give the Nextion some time to start before sending the text.
I only have one page
Its just for testing
I originally intend to make a page where 2 analog input will show value of the input.
a button below it where once pressed, the values on both analogs will freeze
But before doing any of tht, I couldn't even get the communications right
All of the pins connecting are correct
I cross connect the rx and tx as u mentioned
I am using serial1
The nextion is on
But not showing the text "Hello"
In my Nextion I set it as "newtext", the objname is t0
What pins are you using for Serial1 on the Mega? Is the ground of the Nextion connected to the ground of the Arduino? How is the Nextion being powered?
You did not answer these questions. If the grounds are not connected the communication will fail like you are seeing.
Did you try adding the delay( ) as suggested?
Did you ever change the baud rate of the Nextion from the default 9600?
If the issue is not the grounds or the delay( ) please make a zip file of your HMI program and attach it to your post.
Try taking the delay to 2000. I was testing with my hmi code and I was not reliably writing on startup with 500ms.
I'll take a look at your hmi code next.