Start a new topic

General help please nextion arduino.

Hi all. Need a hand understanding returning commands from the arduino to the nextion. I have a new 7.0 and mega board that controls some relays. Via a dual state button I can turn the relay on off. No issues. But I would like the arduino when it sets the output to on (either high or low) to return a command (or code) to the nextion to change a picture from red to green confirming the bit has changed and displaying the item is on. What is the serial code from the arduino What does or how does the nextion listed for it And what is the item ie "picture/crop eg" that I need to install on the screen Yes I can make the dual state button change green to red. But I want to confirm the change in the arduino code. Thanks in andvance. Ben.

Basic help starts with making sure you have the latest Editor v0.43

Choose Help under the Help Menu - this launches Nextion HMI Solutions

From here you get needed Data Sheets, Quick Start Guides, Nextion Instruction Set

Arduino Nextion Library, Examples.

Thanks for that. Sorry to mention have all of the above and am looking for a hand. There are 1000s of pages few YouTubes and other pages. But can't pin point the actual direct way of doing what is stated above (if you can). Hence asking the question. Agree the question is generic and the answer is out there. But an equally generic response is not helpful as is if I was able to find it and work it out I would not have asked the question. Been looking for 2 weeks. So a bit more direction would go a long way. Ben.

I call bs on you looking here for two weeks - The Help Menu is in the Editor.

So, I will be clear. I don't mind lending a hand when the users are willing to put in an effort.

But I know I have explained this many many times, so I find myself wondering why I am

explaining it once again.  YouTube vs Itead Manufacture support?  Really - drop YouTube.

There certainly isn't 1000 pages of documentation for the Nextion.

Help --> Help = HMI Solutions --> Nextion Instruction Set.

page.component.attribute=simplex_statement // terminated with 0xFF 0xFF 0xFF

If you looked at all at the code in the Arduino Library you would see

NexPicture.cpp and NexPicture.h clearly lay out available functions

Arduino Examples show how to use these functions

2 weeks?  Sorry, I find that to be exaggerated and little user effort.

the Arduino, and every other MCU too, just send out what you code ... they won't return any which is not defined in your code. So, just write your code, define what is send out, and you are done ...


1 person likes this
Thanks for your reply. Don't like been Called BS. If I wanted to justify myself I would paste my search and browsing history up. It may come down to I have been searching the wrong key words or wrong searches as one can't search for the right answer if one does not know what the actual term is. Your reply above is typical of there are more than one way to do this hence some of the confusion. Have found just recently the Nextion LCD Touch Screen Tutorial for Arduino. It looks like that is what I am looking for. (Been searching for turn button on from arduino) or thinks like that not send command. As stated above could have beeen searching for wrong thing. It states to use the myNextion.sendCommand to change the picture state of the button. Thanks anyway. Approcate help. Don't like been called a lier
to be honest, the Nextion is a real great device. Visual things became really much more easy for embedded developers ... but to handle the Nextion you also must first understand how the Nextion philosophy works ...

that told, the best beginning is, just to read quickly the command reference, around 20 pages, and try to understand the commands of the Nextion.

    - which commands do I have
    - how must a command be defined
    - what does the Nextion expect and what not
    - ...

You surely won't need any command at the beginning ... But read about is your best start ...

Only when you know what a Nextion expect, what a Nextion need to do something, you also will be able to feed your Nextion ... independent which MCU you finally use ...

And a serial out command is just a serial out, defined by your used Programming Language. The send out command is defined by the Nextion, and that you already know ...

And from this part, just go ahead step by step ...

1 person likes this

The Nextion Editor has components

Components have attributes

To change an attribute

    bt1.val=1 or bt.val=0

This is what must be sent over serial and data terminated with 0xFF 0xFF 0xFF

Want to change a picture attribute

Put a picture component on Editor Canvas

Look at attributes

 - gray are enumerated, black are read only, green you can change at runtime

what attributes are green?  What is objname?  What pagename are you on.

    page0.p1.pic=5 - but this must be data terminated with 0xFF 0xFF 0xFF

But your biggest clues would be from the library

The Library contains the source code for you to read, understand and use

This when installed into your Arduino IDE is placed in your documents

Expecting to know how to use a library without looking at code its requires a fortune teller.

But I will stand by it being mostly impossible to spend 2 weeks on

Nextion Instruction Set, Library Code, Examples, Quick Start Guide

All of which are launched from Help Menu

1 person likes this

Anyrate - you have found the Nextion Forum

I will put this two week thing aside and answer some questions you have.

1 person likes this
Thanks everyone. Yes. All some good advice. I am good with the Arduino have done many projects 5000lines or more and using every spare input/output to control my train set (3x mega 256 boards). As you stated correct. Getting your head around the new codes for the Nextion. Correct it's a great product. Thanks all for the help.

So you understand the Arduino Nextion Library?

setValue or setText (or the likes)

parses the "name" from your Arduino Side Nextion Component declaration

NexPicture myPic = NexPicture(0,1,"p3");

NexPicture myPic = NexPicture(2,5,"page2.p1");

in the set function it parse taking the name

  and adding attribute and your value


This is sent over to the sendCommand function which

adds the needed three 0xFF 0xFF 0xFF to terminate the command.

When Nextion receives the three 0xFF bytes, it processes.

Number values Arduino side are uint32_t type

Text values are char type and must be encased in double quotes.

The first two parameters of NexPicture(0,1,"p2")

  first is page number, second is component .id

This allows nexListen to watch for this component

Nextion Send Component ID checkbox will cause

  0x65 0x00 0x01 0x01 0xFF 0xFF 0xFF - when page 0 id 1 is pressed

  0x65 0x00 0x01 0x00 0xFF 0xFF 0xFF - when page 0 is 1 is released

for these you set up callback functions

  .attachPop will catch the released event

  .attachPush will catch the pressed event

nexListen(nex_listen_list) needs to be in the loop() event

components that will be listened for needs to be listed

   nexTouch nex_listen_list[] = {

      &p2, &p1, NULL


nexInit() has to be in the setup() function

NexConfig.h needs to be adjusted for which Serial you use

and nexInit() is in the NexHardware.cpp where baud is set

Curious Ben, is such Train Set like the DCC++?

No. the mega boards control only the signalling (operates in the background to the trains). Ie the signals changes when the trains pass or the points change. Quite complex. As the train moves to the next section the light goes from red to yellow. Then to great as the Train moves again.. if you change the points the mega assess the Noew route and shows the train that the points are moved and if the ahead is clear or blocked. Just like a real one.
Also yes. Just found the libs. Have always been programming with 1.6. By hand. Not 1.8. So yes. Make sure you have the lates version.
Login or Signup to post a comment