How to use the command "sendme" from nextion in arduino. I've got a nextion display, and I used "sendme" in every page, at the "preinitialize page" to send in which page I'm, but i don't know how to read this in my arduino. Is there any tutorial I can see or could you give me an example?
Have you seen this: https://forum.arduino.cc/t/using-nextion-displays-with-arduino/580289
Take some time to read it.
Some use the variables in Nextion and try to communicate with Nextion about it. Some keep all the variables in the Arduino. Some use the ITEAD library that comes with the Nextion display. Some use the commands to write their own interface.
I decided to put as much as possible in the Arduino. I send commands for the display elements or to change the page. Clicking on a display button goes to the Arduino. I don't use the ITEAD library.
How do you use the Nextion display ?
I don't use the ITEAD library.
Agreed. It has a very bad reputation on this forum.
As an alternative to the methods of the Bebbington Nextion tutorial there is the EasyNextionLibrary by Seithan which is available through the Arduino IDE library manager.
I have used it extensively and it has very easy methods for interpreting the serial returns from the Nextion, including the page number information from the page preinitialize event.
https://forum.arduino.cc/t/how-to-know-the-current-page-of-my-nextion-screen-with-arduino/1240273/4
I've tried to use the EasyNextionLibrary, and it works in the simulator of the Nextion Editor, but when I connect it to my Nextion Display (NX4827P043_011), it doesn't send me the page in which I'm, and it just tell me that I'm the whole time in page 0.
I don't know if someone could have a look to my code. I let you my Arduino code and the Nextion example in this zip, with photographies of what's happening to me in both cases. I'm using an Arduino Mega (16TX2, 17RX2).
NextionExample.zip (394,2 KB)
I have seen Perry's publication but (correct me if I'm wrong) he doesn't use any library.
I'm trying to use the ITEAD library or the Easy Nextion Library.
In my case, I wanted to know in which page I'm to activate/desactivate servos, waveform, etc., because when the waveform starts, the program stops reading anything I send from de display. I don't know if it is normal or I'm doing something wrong.
Thanks for the pacjage. I'll get set up to have closer look with my set up, but I do see some things you can try to correct.
I'm using an Arduino Mega (16TX2, 17RX2).
But your code has
EasyNex myNex(Serial); //usb serial shared with monitor
It should be
EasyNex myNex(Serial2); //Serial2 16tx 17rx
I think that the button touch events should be
page pagex
I actually prefer to make all my button events release events and I have found that to be more reliable.
The way that I have found best to manage the page information is to read the page once at the start of loop just like .listen().
currentPage = myNex.currentPageId;
myNex.NextionListen(); //NE listen for triggers coming from Nextion
I'll need to take a closer look at your refresh page code but for my page management on reentering a page. I don't use the library function lastCurrentPageId. Using an if else or switch case like you have the code looks like this
//variables for pageId declared global
int currentPage;
int lastPage;
//actions to take when switching to a page
if (currentPage != lastPage)
{
if (currentPage == 0)
{
//fill fields
//read data
}
else if (currentPage == 1)
{
//fill fields
//read data
}
else if (currentPage == 2) //fill fields
{
//fill fields
//read data
}
lastPage = currentPage;
}
The most important thing is to change the Serial, and then see if the button events need to be page pagex
Thank you so much! It now perfectly recognizes the page it is on. It had to be because of the Serial. Now the question I have is, can you start the "nexLoop(nex_listen_list);" for example if it is within page 1 for example? I don't know if it has to go a specific way. I ask this because I wanted to put a button and a slider inside page 1.
Thank you very much for taking a look at the code and the nextion program!!
nex_listen_list is not an EasyNextion library command.
Arduino knowledge of and response to events within pages is typically done with the trigger functions. Study the library examples.
You really need to select a single path of action. No Library, EasyNextion, or ITEAD Nextion.h
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.