As many people are aware, the Arduino library provided by Nextion is, well, cr@p. The way it handles the serial communications is about as brain-dead as it can be, and often causes lost messages, especially event messages, and sometimes causes the whole system to just hang.
I looked at the code, and found whoever wrote had not the slightest clue what they were doing, as the code does some monumentally STOOOOPID things, like randomly tossing anything from a single character to entire messages! So, I basically scrapped virtually all of their communications code, and re-wrote it so it now works as it should. I've been using the modified library for weeks, and it works perfectly. The ONLY change I made to the interface is to the init call, to make it easier to work with other baud rates. ALL other interfaces are unchanged, except that they now work reliably.
I thought it would be nice to pass the updated library back to Nextion, but they apparently no longer have ANY interest in communication with customers. Their forum is no longer available, and apparently all support is now paid. You can'y even send them a message without creating an account on their website. So, what should I do? Just keep it to myself, or is there somewhere else I can post it that it might be easy for others to find and use?
My advice is to fork their library on GitHub and then publish your changes to the fork. Submit a PR for your changes back to their repository. It seems like Itead is not actively maintaining that library any more so there is a good chance your PR won't get merged, but it will make it so that people can easily find and use your fork.
There are some issues with the structure of the Nextion library that have been causing problems recently. I was thinking of submitting a PR to fix them, but there has already been a dedicated issue report about the most important one for the last year with no response, and another issue report that mentions it that's 2 years old with no response, and I don't have interest in maintaining my own fork of the library for such a trivial change so I haven't bothered. If you made a fork for your improved version of the library, I'd be happy to submit my PRs to your fork instead.
It seems like Itead is not actively maintaining that library any more
When I first used Nextion displays there were frequent updates to the Nextion design tool. I've not seen any updates for ages. This makes me wonder if they are going to continue to support the product. I hope they do, I've become rather fond of using them, they do what I need and I am familiar with their quirks and how to use them.
Since the library has a "flat" layout (header file in the root folder of the library), this is no problem for the Arduino IDE, which supports this older style of library for backwards compatibility. However, Arduino Web Editor requires that all libraries have a library.properties file. If the library does not have that file then importing it to the Arduino Web Editor fails:
The file names of the library's example sketches don't match the folder names
It's pretty sad that Itead didn't catch this obvious bug and doesn't understand this absolutely fundamental Arduino concept. From a hobbyist who is just creating a library as a labor of love on the weekends and sharing it with the world with no expectation of profit, that sort of thing is understandable, but I expect more from a company that wrote a library to support a product they're targeting to Arduino users. It makes me feel like they don't really care about the Arduino community and just want to cash in on us.
Excessive size
The library is also problematic for Arduino Web Editor users because it has a bunch of .HMI, .tft, and documentation files that make it huge. Arduino Web Editor has limits on the size of the library and the disk space you can use. This means that users must manually sort through the library to remove all the bloat before importing it.
The solution would be to add the library to Arduino Library Manager. All the libraries in the Arduino Library Manager index are pre-installed on Arduino Web Editor so the users would not need to worry about unzipping the library, removing a bunch of files, then zipping it back up before they can import it. The Arduino Library Manager also provides the easiest way for Arduino IDE users to install and update libraries.
These are very simple fixes that would only take a few minutes to do, but they could save beginners from hours of frustration and confusion.
I can't understand why a company with a financial interest in making their product attractive to hobbyists wouldn't take the time to do these things. Even if they don't care about doing the right thing for their customers, it's worth doing solely for the sake of profitability.
pert:
I can't understand why a company with a financial interest in making their product attractive to hobbyists wouldn't take the time to do these things. Even if they don't care about doing the right thing for their customers, it's worth doing solely for the sake of profitability.
I notice the displays are no sold by a number of big retailers, like Digikey, AutomationDirect, and others. I think they just have no interest in supporting hobbyists, and other small customers, which is understandable. Their market is commercial users who will pay for support.
RayLivingston:
Their market is commercial users who will pay for support.
Here's the description at the very top of the main page for Nextion:
Nextion LCD TFT HMI Display allows users to design their own interfaces all by themselves, even if they don't have any coding background knowledge. It can work with Arduino, Raspberry Pi, Raspberry Pi A+, B+ as well as Raspberry Pi 2/3. It is the best solution to replace traditional TFT LCD and LED Nixie tube. Customers can use the software - Nextion Editor to design interfaces.
That sure sounds to me like they specifically targeted this product to Arduino users and similar markets.
Maybe Itead is interested in selling product to the big resellers, but they still need to support the end users who buy from those resellers to have success.
I'm not very knowledgeable on this topic, but I don't see Nextion displays being used in commercial products that are manufactured in any significant quantities. I see it as something for prototyping, one-off, and small run projects. At least for the first two, even a commercial user would benefit from a properly written Arduino library.
They charge $200 for a font file that doesn't look like flaming diarrhea on their screens, rather than fix the numerous issues with the way it handles fonts and font generation to begin with.
That's all you really need to know about Itead & Nextion - good idea, sleazy execution. Between their editor and PerryBebbington's method at the top of this board, you can still get a lot done though - just gotta be creative with your coding.
The repository maintainer shouldn't have even allowed the PR that introduced that problem to be merged. OK, everyone makes mistakes, but when someone reports an obvious, easy to fix problem, any conscientious adult would fix it.
There also appears to be multiple copies of the documentation strewn about through the repository. The repo is already huge enough with only one copy of the docs and this makes it hard to figure out which documentation files I should be looking at.
Whilst we're pointing out the Nextion flaws, I started using PerryBebbington's serial method after realizing that any global variables created in the Nextion editor aren't actually global at all. One library claimed to actually fix the way global variables were handled, but that was 100% false.
The idea of a global variable is such a basic concept that you'd think would be absolutely imperative here, but Itead just doesn't feel that way..
I have a problem and I'm not sure if its the Itead arduino library or me.
In nextion editor it claims a number is a 32 bit signed integer.
Using the nextion library from itead, and using NexNumber object, and sending a 32bit int I'm only getting the lower 16bits on the screen. (0-65535).
I get similar issues when setting and getting NexVariable's.
Using an arduino nano if that makes a difference.
Anyhow if this turns out to be a library issue I would welcome RayLivingston's library if it fixes this sort of thing as well.
I gotta say nextion arduino library seems really buggy at least to a novice like me.
NexNumber just doesn't work above 16 bits (modified mine)
All NexTouch objects are setup specifying page id/object id/name but if you happen to use the same names on different pages set functions will change the values on whatever page the nextion screen happens to be on. (get around this by specifying name to object as page0. .. page1. etc)
Serail communication is so poor it gets unusable. I use that ray guys modification and it works fine however if I load the original library many commands are not always received by the arduino (at baud rate of 115200 I haven't tested other speeds). For example page changes are missed.
I'm only posting to point out to newcomers not to assume anything really works in the nextion arduino library. So much time was wasted chasing things I thought must have been an issue with my code because they are so basic.
Nextion Editor seems pretty darn good though.
Nextion HMI pricing seems pretty darn good though.
I wish they hadn't bothered with the arduino library as I'm sure without it someone would have made a full featured one that worked.
Ray, I really wish you would fork your library on github as Pert suggested. I'm a super noob and wish I had a more reliable library. I don't yet have the skills to write my own, or modify the ones already there
Hope I can ask a quick question that I think is on topic here. I am just getting started with the nextion and would like to see how I can get ahold of Ray Livingston’s code. Want to start out right. The only thing I need to be able to do between my nextion and my arduino is for my arduino to know what page my nextion is on. Is this accomplished via serial monitoring of the nextion? Sorry I’d this sounds stupid but I have been trying to understand it
Hope I can ask a quick question that I think is on topic here. I am just getting started with the nextion and would like to see how I can get ahold of Ray Livingston’s code. Want to start out right. The only thing I need to be able to do between my nextion and my arduino is for my arduino to know what page my nextion is on. Is this accomplished via serial monitoring of the nextion? Sorry I’d this sounds stupid but I have been trying to understand it
You have to hope that Ray sees your question here and replies. As this is Ray's topic I imagine he is monitoring replies, but whether he wants to respond is up to him.
You could also try my tutorial 'using Nextion displays with Arduino' which is at the top of the displays' forum. There is an answer in the tutorial to your question, but please note that the methods I set out do not use the Nextion libraries and also require that you understand how my code works. Only you can decide which you prefer; using Ray's libraries (don't use the original Itead ones, you'll only have grief!) or using my method, the two don't mix.
I hope too Ray Livingston shows up again here. Meanwhile I found this as an possible alternative: Nextion - Arduino Libraries
Is this a viable/reliable/useful altnernative to the Itead library?