I’m very happy to see this topic.
Before I learned, I used the Nextion MASSIVE libraries.
Not only do they suck up much needed memory, but their syntaxes are so convoluted.
I’m not sure if I"m allowed to mention a YouTube channel, so I won’t right now, but I found a channel that focuses on Nextion without libraries!
Yes, NO LIBRARIES NEEDED!
Which I believe Perry is getting at.
I mostly use Nanos for most projects and as can be expected, with Nextion libraries, you have so little memory left to write code in.
Keeping in mind too that the Nanos (probably other boards too) complain about things may not work right after you get over 55% or 60%. And in fact, things DO stop working.
So by using just serial you don’t waste memory and you can do pretty much anything without the Libs as you can with.
That also includes Nextion SENDING data back to Arduino.
For the Nanos, I do use the following (not for Mega):
SoftwareSerial Serial2(6,7); // RX, TX These can be any digital pins, but I use 6 and 7
Then to save “Serial.print” statements, that can really suck up memory, I set up a single string:
String endChar = String(char(0xff)) + String(char(0xff)) + String(char(0xff));
In setup, I do this:
I do add the delay (which you need to do at every “SEND” because the Nextion takes a bit of time to process the request.
If you don’t use a delay, which can be as low as 2, or 5 or 10, then often things don’t work right.
On a first startup, I like to assure that the Nextion is on page 0.
So I send:
Serial2.print("page "+(String)currentPageName+ endChar);
This can just be:
Serial2.print(“page 0”+ endChar);
But I use an array for retaining my page names (instead of numbers).
To send static text, all you have to do is:
Serial2.print(“t0Temp.txt=“SAVE”” + endChar); (use whatever your object name is)
If you have a number object, I send like this:
Serial2.print((String)currentPageName+".j0Level.val=" + String(yourVariableHere) + endChar);
I actually put things like that in functions and call as needed, using parameters to display what I need.
There’s so much more, but to keep it short, that’s all I do here.
But yeah, now due to no longer using libaraires, my entire code takes up so much less memory, that I can now do larger projects than ever before.
I highly recommend others to search YouTube for Nextion without Libraries.
If I am allowed to post a link and someone confirms that, I’ll happily share the link.
The guy who does these videos is an excellent teacher and very patient. He’s also very responsive if you have a question.
I haven’t even counted how many videos he has on Nextion without Libraries, but it’s a lot.
You will learn everything you need to know.
I hope this helps others.
What can I say. I love Nextions. I have a bunch of these displays, from 2.8" Basics (for building projects and for projects that don’t need Enhanced displays).
I have several 3.2" Enhanced displays, 1, 7" Basci and 2, 7" Enhanced.
Yes, I love these things that much. LOL