Hello, I wanted to add a HMI to my project and went for the 7" nextion screen. Using the current library I have been able to get it running using serial1 at 9600.
However, now I have problems with the ethernet2. It will receive data from my client; but when it sends back; nothing arrives at my client. If I comment all the code that communicates with the nextion screen; then it works again. If I have one simply statement such as number1.setValue(0,1,100) then the ethernet2 stops sending again?
Any pointers and/or help please!
I downloaded it with the IDE library manager. V2.2.0
this is the library https://dannixon.github.io/NeoNextion
which is the official library I should use?
on the website it is clearly stated
"The code is heavily based on the official library but aims to be cleaner, more user friendly and with a bit of luck, faster."
so, when you use this, I guess it is also a good idea to contact the author for some more help ... if somebody knows this library, then him ...
There is no direct "official" library existing for the Due, sorry ...
All boards, which has one or more hardware serial, can be supported.
For example:Iteaduino MEGA2560Iteaduino UNOArduino MEGA2560Arduino UNO
so is there any plans to make the library compatible with the due; would be a shame to bin the screens I have just received and have to begin again looking at a different screen?
The Nextion is a serial device. This means you need to have an ability to write to a byte via serial. To write via serial, one must send HIGHs and LOWs over the wire at timed and spaced intervals. The interval is known loosely as the baudrate or preferably as bits per second. A HIGH or a LOW for one interval is a bit. The Serial protocol provides for several other data-handling functions like error-checking, flow control, etc, but with Nextion the parameters are simple None 8 1. Which is to say None Parity, 8 Data Bits and 1 Stop Bit. (No flow-control, no compression, no error-checking, no-encoding, just the simplest straight forward 10 Bits of N81).
Now to send out a single byte, the first interval (bit) is a LOW holding the time length of the Interval - this represents our None. Then for each of the 8 Bits of our Byte, the Least Significant Bit is sent: If the bit is a 1 then a HIGH is held for the length of the Interval, or if the bit is a 0 then a LOW is held for the length of the Interval - then the register is shifted right to position for the next bit. This continues for each of the 8 bits of our byte we are sending. Finally to finish up with this byte the Stop Bit is sent holding LOW for the length of the Interval. 10 Intervals used, this is how N81 is processed to send a single byte.
What is the interval? 9600 baud or bps is 9600 such intervals every second. On a 84MHz MCU, one 9600 baud interval is 8750 clock cycles (with many other things dependant). At 115200 baud or bps, 115200 intervals every second. On a 84MHz MCU, one 115200 baud interval is around 729 clock cycles, and not even divided, so slight error rate in the timing. Techniques such as 8x or 16x oversampling helps to correct this timing error with an average determined over the Interval.
Hardware Serial is more "user friendly" as it works directly with your board's UART module. Think of your UART module in the MCU as a Helper or Apprentice assigned to the task of shipping and receiving the bytes over RX/TX. As such your MCU can be busy doing other things and simply be informed when a byte has arrived in the port, handle this byte and be back to other things the MCU is handling - such as your Ethernet.
Then there are the bit-banging techniques. SoftwareSerial bit-bangs the serial protocol. SoftwareSPI bit-bangs the SPI protocol, Software I2C bit-bangs the I2C protocol and so on. In a bit-banging scenario the MCU doesn't have his extra Helper and must manage all these things by himself.
Now, Arduino provides for a Hardware Serial which matches your board's UART modules. This too is dependant on if the Manufacturer of your board has sent the proper definitions to Arduino. Some boards are close enough to others, but hey many many things to be considered when "why something just don't work". This is an important issue if Arduino actually has a proper board definition for your board or if it is handled by Arduino as a loosely "close enough" scenario. There is NO MCU Manufacturer that has manufactured their chip expressly to the specifications and requirements of the Arduino group. And the Arduino group has indeed made their efforts to find some semblance of compatibility so their environment can spread further - so for Arduino a "loosely close enough" is good enough for them.
BTW have you even seen the size of your MCU documentation? Assuming you are using a brand-name Arduino DUE and not a DUE compatible (this goes back to the loosely close enough scenario I mentioned) https://www.arduino.cc/en/Main/arduinoBoardDue The MCU datasheet for the Atmel SAM3X8E ARM Cortex-M3 CPU is whopping 1479 pages! http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf.
This is in no way my responsibility to become familiar with your MCU, and my reading the 1479 pages of your MCU documentation in no means increases your understandings of the MCU you have chosen and in no means will assist you to use your MCU. This is your responsibility to do and to your benefit to ensure that you do.
SO I found out your problem - and I will not need to remind you it is not my job to debug your code.
This you must DUE for YOURSELF ...
So why does your Ethernet suddenly stop when you issue number1.setValue(0,1,100) ?
Well what do you suppose was suppose to happen when you make a coding error
- where such error now needs to raise an exception
- where you have made no coding mechanism for such exceptions
- where you have made no coding provisions for handling such exceptions
You MCU runs into an invalid situation and code halts to protect the MCU.
Now on most MCUs there is simply not enough resources available to build up such coding mechanisms and as such the code you provide your MCU needs to be exacting. You could use your Serial Monitor and Serial.print statements to build debugging so you can see what is happening on your MCU side. But this you did not do, too lazy to make simple Serial.prints to investigate your own code. Too lazy to read the provided documentation NeoNextion created. To lazy to pull up a simple ino text files of the many examples NeoNextion provided - like NeoNextion's Number.ino found here:
Instead you come here and jump quickly blame the Nextion for your coding mistakes when you open a BUG Report - must be Nextions fault, since I was trying to send something to the Nextion. I resent that users use the Bug Report channel to jump queue for priority handling of their coding issues. Coding issues are to be handled in Free Chat. Bug Reports are for Nextion Editor Bugs and Firmware Bugs - not for help with user coding errors. But how quick you are to blame Nextion when it isn't even our code. The library is NeoNextion the code is yours.
Of course such a line of code would cause the MCU to choke.
Properly formatted NeoNextion style is merely Number1.setValue(100);
It has no clue what to do with all the extra parameters you tried passing to it.
Thank you for critique!
I have already tried the above which did not work; I hope this shows some effort on my part; ultimately I am reaching out for help, to see if someone else in the community has experience of this and therefore a solution?
Unfortunately my knowledge and time doesn't allow me to easily debug the inner workings!
The nextion screen is "perfect" for my project; for reasons I wont bore you with; I have had to move from the mega to the due .. and thus I find myself with this problem to resolve or to change hardware and move on .. the first option is my preferred choice!
My suggestion if you want community help - Post in Free Chat
Bug Reports are for reporting bugs in the Nextion Editor of the firmware.
A Bug Report usually means that we have to find the BUG you are reporting (prove or debunk), our day workflow becomes interrupted to chase down the BUG to make report on what is causing such a BUG. So when this is a general user question that should have been posted in Free Chat, the other users see this as queue jumping. It isn't a fair means to the rest of the community to jump queue. Also the Community doesn't generally think of going through the Bug Reports to locate user questions. So I hope you understand. As this queue jumping continues, it's going to lead to a result of the Bug Reports being ignored.
I'll also state my post was not meant to be a critique. You state now that your knowledge of and time doesn't allow you to easily debug the inner workings. But I provided a fairly accurate overview of how serial works, how the software works, how Arduino works, and links to your documentation for your quick reference. When you don't have the knowledge - that is where you find the knowledge you are missing. I have now spent about 4 hours skimming Due related materials and even now have setup a Due (Atmel ATSAM3X8E AU) on my desk. So you will have more time and experience with your Due than I have. Understand this is not my task - but yours.
But as you have posted, and I can not move the thread to Free Chat, continue to use this thread.
You state your knowledge and time doesn't allow you to easily debug the inner works So let's demark your side, and my side. Mine is the Nextion - screen side of the RX/TX pair. Ask about things on the screen side of those RX/TX wires - happy to help, more than happy to help. I need you to give the Nextion a clean 5V on the Nexion 5V line, I need you to tie Nextion GND common to your DUE GND, Nextion TX to your DUEs RX2 and Nextion RX to your DUEs TX2 line. Now the Nextion is my side. The DUE will be your side. Everything that is not on my Nextion side of that RX/TX pair is your side. So I will help you Nextion, you will need to dig into that 1479 pages for your side if need be and do what ever it takes for your side.
When you say you have already tried the above I need to know without me assuming, of which you speak?
Also which DUE do you have? - I now have IteadLib working on the Iteaduino DUE
Also which Nextion do you have?