I have been some days trying to send any kind of data (numbers, text, etc) to my Nextion screen but I can't make it work and I don't know how. I beg for help.
I'm writting the Serial.write(0xFF) three times too but it never works for me, it only sends the data to the monitor serie instead of sending it to the Nextion. I am using the #include <Nextion.h> library.
I have another tutorial about using Nextion HMI at the top of the display category of the forum, I suggest you will find it useful.
Your code is way too complicated for trying to send a number. Start again with some simple code that just sends a slowly incrementing number and nothing else. Get that right before adding anything else.
I've yet to read a comment here where someone says how good the official Nextion libraries are.
These are the connections. The model of Arduino is Mega 2560. I will try to write an easier and send it here, but I already did that too and I was just getting the same result.
I will also take a look at that other way witgout using the Nextion libraries.
Still need a schematic and to see how it's actually hooked up while you are trying to use it. I'm not seeing power going to the Arduino board and if you don't have the 0v commons tied together, that could stop communications too.
There is no power going to the Arduino because I gave up on it today so I disconnected it. But even conecting the 0v commons together it still doesn't work. I don't know how to make a schematic here, but these connections are simple, the 5v and GND of the Nextion are connected to the microUSB, the TX of the nextion os connected to the RX of Arduino, and the RX of Nextion to the TX of Arduino.
As PaulRB said, I also tried using Serial2.write() and didn't work either. I even tried Serial1 and Serial3 desesperately but nothing worked.
Okay. When you're ready to try again, please connect it with the commons tied together, the code writing to Serial2 and a copy to Serial so you can see it in the serial monitor, and share the exact state and code you're testing while asking for help.
Please also share which model screen you're using. Preferably with a link to the product and a data sheet.
Hello!
I wrote it again today using the Serial2 and it works now, probably I was missing something yesterday since I was burned out. Anyways thanks everyone because I know I'm not very good at programming and your messages have helped me to solve this problem.
Have a good day!